Panda3D
vertexDataBlock.I
1 // Filename: vertexDataBlock.I
2 // Created by: drose (04Jun07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: VertexDataBlock::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE VertexDataBlock::
22 VertexDataBlock(VertexDataPage *page, size_t start, size_t size) :
23  SimpleAllocatorBlock(page, start, size)
24 {
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: VertexDataBlock::get_page
29 // Access: Published
30 // Description: Returns the page from which this buffer was
31 // allocated.
32 ////////////////////////////////////////////////////////////////////
34 get_page() const {
35  return (VertexDataPage *)get_allocator();
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: VertexDataBlock::get_pointer
40 // Access: Public
41 // Description: Returns a pointer to the start of the allocated
42 // memory for this buffer, or NULL if the data is not
43 // currently resident. If the data is not currently
44 // resident, this will implicitly request it to become
45 // resident soon.
46 //
47 // If force is true, this method will never return NULL,
48 // but may block until the data is available.
49 ////////////////////////////////////////////////////////////////////
50 INLINE unsigned char *VertexDataBlock::
51 get_pointer(bool force) const {
52  nassertr(get_page() != (VertexDataPage *)NULL, NULL);
53  unsigned char *page_data = get_page()->get_page_data(force);
54  if (page_data == (unsigned char *)NULL) {
55  return NULL;
56  } else {
57  return page_data + get_start();
58  }
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: VertexDataBlock::get_next_block
63 // Access: Published
64 // Description: Returns a pointer to the next allocated block in the
65 // chain, or NULL if there are no more allocated blocks.
66 ////////////////////////////////////////////////////////////////////
68 get_next_block() const {
70 }
A block of bytes that holds one or more VertexDataBlocks.
unsigned char * get_pointer(bool force) const
Returns a pointer to the start of the allocated memory for this buffer, or NULL if the data is not cu...
VertexDataBlock * get_next_block() const
Returns a pointer to the next allocated block in the chain, or NULL if there are no more allocated bl...
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object...
A single block as returned from SimpleAllocator::alloc().
SimpleAllocatorBlock * get_next_block() const
Returns a pointer to the next allocated block in the chain, or NULL if there are no more allocated bl...
VertexDataPage * get_page() const
Returns the page from which this buffer was allocated.
size_t get_start() const
Returns the starting point of this block.
unsigned char * get_page_data(bool force)
Returns a pointer to the page's data area, or NULL if the page is not currently resident.
SimpleAllocator * get_allocator() const
Returns the SimpleAllocator object that owns this block.