Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

VideoTexture Class Reference

The base class for a family of animated Textures that take their input from a video source, such as a movie file. More...

#include "videoTexture.h"

Inheritance diagram for VideoTexture:
Texture AnimInterface TypedWritableReferenceCount Namable TypedWritable ReferenceCount MemoryBase TypedObject MemoryBase MemoryBase

List of all members.

Public Member Functions

virtual bool cull_callback (CullTraverser *trav, const CullTraverserData &data) const
 If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
virtual TypeHandle force_init_type ()
virtual bool get_keep_ram_image () const
 Returns the flag that indicates whether this Texture is eligible to have its main RAM copy of the texture memory dumped when the texture is prepared for rendering.
virtual TypeHandle get_type () const
int get_video_height () const
 Returns the height in texels of the source video stream.
int get_video_width () const
 Returns the width in texels of the source video stream.
virtual bool has_cull_callback () const
 Should be overridden by derived classes to return true if cull_callback() has been defined.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

 VideoTexture (const string &name)
 VideoTexture (const VideoTexture &copy)
void clear_current_frame ()
 Resets the record of the current frame so that it will be forced to reload the next time it is requested.
virtual void consider_update ()
 Calls update_frame() if the current frame has changed.
virtual bool do_adjust_this_size (const Texture::CData *cdata, int &x_size, int &y_size, const string &name, bool for_padding) const
 Works like adjust_size, but also considers the texture class.
virtual bool do_can_reload (const Texture::CData *cdata) const
 Returns true if we can safely call do_unlock_and_reload_ram_image() in order to make the image available, or false if we shouldn't do this (because we know from a priori knowledge that it wouldn't work anyway).
virtual bool do_has_ram_image (const Texture::CData *cdata) const
 Returns true if the Texture has its image contents available in main RAM, false if it exists only in texture memory or in the prepared GSG context.
virtual void do_reload_ram_image (Texture::CData *cdata, bool allow_compression)
 Called when the Texture image is required but the ram image is not available, this will reload it from disk or otherwise do whatever is required to make it available, if possible.
virtual void do_update_frame (Texture::CData *cdata_tex, int frame)=0
virtual void reconsider_dirty ()
 Called by TextureContext to give the Texture a chance to mark itself dirty before rendering, if necessary.
void set_video_size (int video_width, int video_height)
 Should be called by a derived class to set the size of the video when it is loaded.
virtual Texture::CDataunlocked_ensure_ram_image (bool allow_compression)
 If the texture has a ram image already, this acquires the CData write lock and returns it.

Protected Attributes

int _current_frame
int _last_frame_update
int _video_height
int _video_width

Detailed Description

The base class for a family of animated Textures that take their input from a video source, such as a movie file.

These Textures may be stopped, started, etc. using the AnimInterface controls, similar to an animated character.

Definition at line 31 of file videoTexture.h.


Member Function Documentation

void VideoTexture::clear_current_frame ( ) [inline, protected]

Resets the record of the current frame so that it will be forced to reload the next time it is requested.

Definition at line 50 of file videoTexture.I.

void VideoTexture::consider_update ( ) [protected, virtual]

Calls update_frame() if the current frame has changed.

Definition at line 241 of file videoTexture.cxx.

References AnimInterface::get_frame(), ClockObject::get_frame_count(), and ClockObject::get_global_clock().

Referenced by do_reload_ram_image(), reconsider_dirty(), and unlocked_ensure_ram_image().

bool VideoTexture::cull_callback ( CullTraverser trav,
const CullTraverserData data 
) const [virtual]

If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time.

This is called each time the Texture is discovered applied to a Geom in the traversal. It should return true if the Geom is visible, false if it should be omitted.

Reimplemented from Texture.

Definition at line 101 of file videoTexture.cxx.

bool VideoTexture::do_adjust_this_size ( const Texture::CData cdata_tex,
int &  x_size,
int &  y_size,
const string &  name,
bool  for_padding 
) const [protected, virtual]

Works like adjust_size, but also considers the texture class.

Movie textures, for instance, always pad outwards, never scale down.

Reimplemented from Texture.

Definition at line 223 of file videoTexture.cxx.

References Texture::adjust_size().

bool VideoTexture::do_can_reload ( const Texture::CData cdata) const [protected, virtual]

Returns true if we can safely call do_unlock_and_reload_ram_image() in order to make the image available, or false if we shouldn't do this (because we know from a priori knowledge that it wouldn't work anyway).

Reimplemented from Texture.

Definition at line 211 of file videoTexture.cxx.

bool VideoTexture::do_has_ram_image ( const Texture::CData cdata) const [protected, virtual]

Returns true if the Texture has its image contents available in main RAM, false if it exists only in texture memory or in the prepared GSG context.

Reimplemented from Texture.

Definition at line 139 of file videoTexture.cxx.

References ClockObject::get_frame_count(), and ClockObject::get_global_clock().

void VideoTexture::do_reload_ram_image ( Texture::CData cdata,
bool  allow_compression 
) [protected, virtual]

Called when the Texture image is required but the ram image is not available, this will reload it from disk or otherwise do whatever is required to make it available, if possible.

Reimplemented from Texture.

Definition at line 197 of file videoTexture.cxx.

References consider_update().

bool VideoTexture::get_keep_ram_image ( ) const [virtual]

Returns the flag that indicates whether this Texture is eligible to have its main RAM copy of the texture memory dumped when the texture is prepared for rendering.

See set_keep_ram_image().

Reimplemented from Texture.

Definition at line 68 of file videoTexture.cxx.

int VideoTexture::get_video_height ( ) const [inline]

Returns the height in texels of the source video stream.

This is not necessarily the height of the actual texture, since the texture may have been expanded to raise it to a power of 2.

Definition at line 38 of file videoTexture.I.

int VideoTexture::get_video_width ( ) const [inline]

Returns the width in texels of the source video stream.

This is not necessarily the width of the actual texture, since the texture may have been expanded to raise it to a power of 2.

Definition at line 25 of file videoTexture.I.

bool VideoTexture::has_cull_callback ( ) const [virtual]

Should be overridden by derived classes to return true if cull_callback() has been defined.

Otherwise, returns false to indicate cull_callback() does not need to be called for this node during the cull traversal.

Reimplemented from Texture.

Definition at line 83 of file videoTexture.cxx.

void VideoTexture::reconsider_dirty ( ) [protected, virtual]

Called by TextureContext to give the Texture a chance to mark itself dirty before rendering, if necessary.

Reimplemented from Texture.

Definition at line 154 of file videoTexture.cxx.

References consider_update().

void VideoTexture::set_video_size ( int  video_width,
int  video_height 
) [protected]

Should be called by a derived class to set the size of the video when it is loaded.

Assumes the lock is held.

Definition at line 119 of file videoTexture.cxx.

References Texture::set_orig_file_size().

Texture::CData * VideoTexture::unlocked_ensure_ram_image ( bool  allow_compression) [protected, virtual]

If the texture has a ram image already, this acquires the CData write lock and returns it.

If the texture lacks a ram image, this performs do_reload_ram_image(), but without holding the lock on this particular Texture object, to avoid holding the lock across what might be a slow operation. Instead, the reload is performed in a copy of the texture object, and then the lock is acquired and the data is copied in.

In any case, the return value is a locked CData object, which must be released with an explicit call to release_write(). The CData object will have a ram image unless for some reason do_reload_ram_image() fails.

Reimplemented from Texture.

Definition at line 180 of file videoTexture.cxx.

References consider_update(), Thread::get_current_thread(), and PipelineCycler< CycleDataType >::write_upstream().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations