Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

GraphicsLayer Class Reference

A layer is a collection of non-overlapping DisplayRegions within a Channel that will be rendered together. More...

#include <graphicsLayer.h>

Inheritance diagram for GraphicsLayer:

TypedReferenceCount TypedObject ReferenceCount List of all members.

Public Member Functions

virtual ~GraphicsLayer ()
DisplayRegionmake_display_region ()
 Creates a new DisplayRegion that covers the entire layer.

DisplayRegionmake_display_region (float l, float r, float b, float t)
 Creates a new DisplayRegion that covers the indicated sub-rectangle within the layer.

int get_num_drs () const
 Returns the number of DisplayRegions associated with the layer.

DisplayRegionget_dr (int index) const
 Returns the nth DisplayRegion associated with the layer.

void remove_dr (int index)
 Removes (and possibly deletes) the nth DisplayRegion associated with the layer.

bool remove_dr (DisplayRegion *display_region)
 Removes (and possibly deletes) the indicated DisplayRegion associated with the layer.

GraphicsChannelget_channel () const
 Returns the GraphicsChannel that this layer is associated with.

GraphicsWindowget_window () const
 Returns the GraphicsWindow that this layer is ultimately associated with, or NULL if no window is associated.

GraphicsPipeget_pipe () const
 Returns the GraphicsPipe that this layer is ultimately associated with, or NULL if no pipe is associated.

void set_active (bool active)
 Sets the active flag on the layer.

bool is_active () const
 Returns the active flag on the layer.

void channel_resized (int x, int y)
 This is called whenever the parent channel has been resized; it should do whatever needs to be done to adjust the layer to account for it.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.

int get_ref_count () const
 Returns the current reference count.

int ref () const
 Explicitly increments the reference count.

int unref () const
 Explicitly decrements the reference count.

void test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Private Types

typedef pvector< PointerTo<
DisplayRegion > > 
DisplayRegions

Private Member Functions

 GraphicsLayer ()
 Use GraphicsChannel::make_layer() to make a new layer.

 GraphicsLayer (GraphicsChannel *channel)
 Use GraphicsChannel::make_layer() to make a new layer.

 GraphicsLayer (const GraphicsLayer &copy)
void operator= (const GraphicsLayer &copy)
void win_display_regions_changed ()
 Intended to be called when the active state on a nested channel or layer or display region changes, forcing the window to recompute its list of active display regions.


Private Attributes

Mutex _lock
GraphicsChannel_channel
bool _is_active
DisplayRegions _display_regions

Static Private Attributes

TypeHandle _type_handle

Friends

class GraphicsChannel
class GraphicsWindow
class DisplayRegion

Detailed Description

A layer is a collection of non-overlapping DisplayRegions within a Channel that will be rendered together.

When the channel renders, it will render all of its layers in index number order; each layer may overlap some or all of its DisplayRegions with other layers, and they will be drawn sequentially without clearing the framebuffer between layers.

Definition at line 57 of file graphicsLayer.h.


Member Typedef Documentation

typedef pvector< PointerTo< DisplayRegion > > GraphicsLayer::DisplayRegions [private]
 

Definition at line 95 of file graphicsLayer.h.


Constructor & Destructor Documentation

GraphicsLayer::GraphicsLayer  )  [private]
 

Use GraphicsChannel::make_layer() to make a new layer.

Definition at line 45 of file graphicsLayer.cxx.

References _is_active.

GraphicsLayer::GraphicsLayer GraphicsChannel channel  )  [private]
 

Use GraphicsChannel::make_layer() to make a new layer.

Definition at line 61 of file graphicsLayer.cxx.

References nassertv.

GraphicsLayer::GraphicsLayer const GraphicsLayer &  copy  )  [private]
 

Definition at line 75 of file graphicsLayer.cxx.

GraphicsLayer::~GraphicsLayer  )  [virtual]
 

Definition at line 99 of file graphicsLayer.cxx.


Member Function Documentation

void GraphicsLayer::channel_resized int  x,
int  y
 

This is called whenever the parent channel has been resized; it should do whatever needs to be done to adjust the layer to account for it.

Definition at line 342 of file graphicsLayer.cxx.

virtual TypeHandle GraphicsLayer::force_init_type void   )  [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 111 of file graphicsLayer.h.

GraphicsChannel * GraphicsLayer::get_channel  )  const
 

Returns the GraphicsChannel that this layer is associated with.

It is possible that the GraphicsChannel might have been deleted while an outstanding PT(GraphicsLayer) prevented all of its children layers from also being deleted; in this unlikely case, get_channel() may return NULL.

Definition at line 269 of file graphicsLayer.cxx.

References _display_regions, _lock, x, and y.

Referenced by DisplayRegion::get_top().

TypeHandle GraphicsLayer::get_class_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 100 of file graphicsLayer.h.

DisplayRegion * GraphicsLayer::get_dr int  index  )  const
 

Returns the nth DisplayRegion associated with the layer.

This might return NULL if another thread has recently removed a DisplayRegion.

Definition at line 189 of file graphicsLayer.cxx.

References _display_regions, DisplayRegion::_layer, _lock, NULL, PT, and win_display_regions_changed().

int GraphicsLayer::get_num_drs void   )  const
 

Returns the number of DisplayRegions associated with the layer.

Definition at line 171 of file graphicsLayer.cxx.

References _display_regions, _lock, nassertv, NULL, and win_display_regions_changed().

GraphicsPipe * GraphicsLayer::get_pipe  )  const
 

Returns the GraphicsPipe that this layer is ultimately associated with, or NULL if no pipe is associated.

Definition at line 305 of file graphicsLayer.cxx.

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

virtual TypeHandle GraphicsLayer::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Definition at line 108 of file graphicsLayer.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

GraphicsWindow * GraphicsLayer::get_window  )  const
 

Returns the GraphicsWindow that this layer is ultimately associated with, or NULL if no window is associated.

Definition at line 287 of file graphicsLayer.cxx.

References _channel, NULL, and GraphicsChannel::win_display_regions_changed().

Referenced by DisplayRegion::set_dimensions().

void GraphicsLayer::init_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Definition at line 103 of file graphicsLayer.h.

bool GraphicsLayer::is_active  )  const [inline]
 

Returns the active flag on the layer.

Definition at line 32 of file graphicsLayer.I.

Referenced by GraphicsWindow::process_events().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

DisplayRegion * GraphicsLayer::make_display_region float  l,
float  r,
float  b,
float  t
 

Creates a new DisplayRegion that covers the indicated sub-rectangle within the layer.

Definition at line 150 of file graphicsLayer.cxx.

References _display_regions, _lock, and NULL.

DisplayRegion * GraphicsLayer::make_display_region  ) 
 

Creates a new DisplayRegion that covers the entire layer.

Definition at line 130 of file graphicsLayer.cxx.

References _display_regions.

void GraphicsLayer::operator= const GraphicsLayer &  copy  )  [private]
 

Definition at line 87 of file graphicsLayer.cxx.

References _display_regions, and NULL.

int ReferenceCount::ref  )  const [inline, inherited]
 

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 225 of file referenceCount.I.

Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering().

bool GraphicsLayer::remove_dr DisplayRegion display_region  ) 
 

Removes (and possibly deletes) the indicated DisplayRegion associated with the layer.

All subsequent index numbers will shift down one. Returns true if the DisplayRegion was removed, false if it was not a member of the layer.

Definition at line 236 of file graphicsLayer.cxx.

References _channel, _lock, GraphicsChannel::get_pipe(), and NULL.

void GraphicsLayer::remove_dr int  index  ) 
 

Removes (and possibly deletes) the nth DisplayRegion associated with the layer.

All subsequent index numbers will shift down one.

Definition at line 211 of file graphicsLayer.cxx.

References _channel, and _lock.

void GraphicsLayer::set_active bool  active  ) 
 

Sets the active flag on the layer.

If the layer is marked as inactive, nothing will be rendered.

Definition at line 321 of file graphicsLayer.cxx.

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

Does some easy checks to make sure that the reference count isn't completely bogus.

Definition at line 328 of file referenceCount.I.

References INLINE.

Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount().

int ReferenceCount::unref  )  const [inline, inherited]
 

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 293 of file referenceCount.I.

References INLINE.

Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds().

void GraphicsLayer::win_display_regions_changed  )  [private]
 

Intended to be called when the active state on a nested channel or layer or display region changes, forcing the window to recompute its list of active display regions.

It is assumed the lock is already held.

Definition at line 371 of file graphicsLayer.cxx.

Referenced by get_dr(), and get_num_drs().


Friends And Related Function Documentation

friend class DisplayRegion [friend]
 

Definition at line 118 of file graphicsLayer.h.

friend class GraphicsChannel [friend]
 

Definition at line 116 of file graphicsLayer.h.

friend class GraphicsWindow [friend]
 

Definition at line 117 of file graphicsLayer.h.


Member Data Documentation

GraphicsChannel* GraphicsLayer::_channel [private]
 

Definition at line 92 of file graphicsLayer.h.

Referenced by get_window(), and remove_dr().

DisplayRegions GraphicsLayer::_display_regions [private]
 

Definition at line 96 of file graphicsLayer.h.

Referenced by get_channel(), get_dr(), get_num_drs(), make_display_region(), operator=(), and GraphicsWindow::process_events().

bool GraphicsLayer::_is_active [private]
 

Definition at line 93 of file graphicsLayer.h.

Referenced by GraphicsLayer().

Mutex GraphicsLayer::_lock [private]
 

Definition at line 91 of file graphicsLayer.h.

Referenced by get_channel(), get_dr(), get_num_drs(), make_display_region(), and remove_dr().

TypeHandle GraphicsLayer::_type_handle [static, private]
 

Reimplemented from TypedReferenceCount.

Definition at line 32 of file graphicsLayer.cxx.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:51:21 2003 for Panda by doxygen1.3