Dali 3D User Interface Engine
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
Dali::Internal::Texture Class Referenceabstract

Texture class. More...

#include <texture.h>

Inheritance diagram for Dali::Internal::Texture:
Inheritance graph
[legend]
Collaboration diagram for Dali::Internal::Texture:
Collaboration graph
[legend]

Public Types

typedef Rect< int > PixelArea
 Used to define the area of the texture to display. More...
 
typedef Rect< unsigned int > RectArea
 Used to define a region of a bitmap. More...
 

Public Member Functions

virtual bool Init ()=0
 Initialization method for Texture. More...
 
virtual void Update (Integration::Bitmap *bitmap)
 Update the texture with the bitmap. More...
 
virtual void UpdateArea (const RectArea &area)
 Update the texture from the modified bitmap. More...
 
virtual void Update (Integration::Bitmap *srcBitmap, std::size_t xOffset, std::size_t yOffset)
 Update part of the texture with a different bitmap. More...
 
virtual void Update (PixelData *srcPixelData, std::size_t xOffset, std::size_t yOffset)
 Update part of the texture with a pixel buffer. More...
 
virtual bool UpdateOnCreate ()
 
virtual bool Bind (GLenum target, TextureUnit textureunit)
 Binds the texture for use. More...
 
unsigned int GetTextureId ()
 Returns GL texture ID. More...
 
virtual unsigned int GetWidth () const
 Return the width of image in pixels. More...
 
virtual unsigned int GetHeight () const
 Return the height of image in pixels. More...
 
virtual bool HasAlphaChannel () const =0
 Query whether the texture data has an alpha channel. More...
 
virtual bool IsFullyOpaque () const =0
 Query whether the texture is completely opaque. More...
 
void SetTextureId (GLuint id)
 Sets the texture id. More...
 
void ApplySampler (TextureUnit unit, unsigned int samplerBitfield)
 Apply the given sampler to the texture. More...
 
virtual bool CreateGlTexture ()=0
 Initialize texture for rendering. More...
 
virtual ~Texture ()
 Destructor. More...
 
virtual void GlContextDestroyed ()
 Reset all GL resources. More...
 
virtual void GlCleanup ()
 Release all GL resources. More...
 
- Public Member Functions inherited from Dali::RefObject
void Reference ()
 Increment the object's reference count. More...
 
void Unreference ()
 Decrement the object's reference count. More...
 
int ReferenceCount ()
 Retrieve the object's reference count. More...
 
- Public Member Functions inherited from Dali::Internal::GlResourceOwner
virtual ~GlResourceOwner ()
 Virtual destructor. More...
 

Protected Member Functions

 Texture (Context &context, unsigned int width, unsigned int height, unsigned int imageWidth, unsigned int imageHeight)
 Constructor. More...
 
 Texture (Context &context, unsigned int width, unsigned int height)
 Constructor. More...
 
- Protected Member Functions inherited from Dali::RefObject
 RefObject ()
 Default constructor. More...
 
virtual ~RefObject ()
 RefObject is intended as a base class. More...
 
 RefObject (const RefObject &rhs)
 Copy constructor. More...
 
RefObjectoperator= (const RefObject &rhs)
 Assignment operator. More...
 

Protected Attributes

ContextmContext
 The GL Context. More...
 
GLuint mId
 Texture id. More...
 
unsigned int mSamplerBitfield
 The packed bitfield of the current sampler. More...
 
unsigned int mWidth
 texture width, may be scaled power of 2 (if not in an atlas) More...
 
unsigned int mHeight
 texture width, may be scaled power of 2 (if not in an atlas) More...
 
unsigned int mImageWidth
 width of the original image (may be smaller than texture width) More...
 
unsigned int mImageHeight
 height of the original image (may be smaller than texture height) More...
 

Private Member Functions

 Texture (const Texture &)
 
Textureoperator= (const Texture &rhs)
 
void ApplyFilterModeParameter (TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault)
 Apply the given texture filtering parameters. More...
 
void ApplyWrapModeParameter (TextureUnit unit, GLint wrapType, WrapMode::Type currentWrapMode, WrapMode::Type newWrapMode)
 Apply the given texture wrap mode. More...
 

Detailed Description

Texture class.

Definition at line 49 of file texture.h.

Member Typedef Documentation

Used to define the area of the texture to display.

Definition at line 57 of file texture.h.

typedef Rect<unsigned int> Dali::Internal::Texture::RectArea

Used to define a region of a bitmap.

rectangular area (x,y,w,h)

Definition at line 62 of file texture.h.

Constructor & Destructor Documentation

Dali::Internal::Texture::Texture ( Context context,
unsigned int  width,
unsigned int  height,
unsigned int  imageWidth,
unsigned int  imageHeight 
)
protected

Constructor.

Parameters
[in]contextThe GL context
[in]widthThe buffer width
[in]heightThe buffer height
[in]imageWidthThe image width
[in]imageHeightThe image height

Definition at line 112 of file texture.cpp.

Dali::Internal::Texture::Texture ( Context context,
unsigned int  width,
unsigned int  height 
)
protected

Constructor.

Parameters
[in]contextThe GL context
[in]widthBoth the buffer width and the image width (they are equal)
[in]heightBoth the buffer height and the image height.

Definition at line 127 of file texture.cpp.

Dali::Internal::Texture::~Texture ( )
virtual

Destructor.

Delete the GL texture associated with it.

Definition at line 140 of file texture.cpp.

Dali::Internal::Texture::Texture ( const Texture )
private

Member Function Documentation

void Dali::Internal::Texture::ApplyFilterModeParameter ( TextureUnit  unit,
GLint  filterType,
FilterMode::Type  currentFilterMode,
FilterMode::Type  newFilterMode,
GLint  daliDefault,
GLint  systemDefault 
)
private

Apply the given texture filtering parameters.

Parameters
[in]textureunit to use
[in]filterTypeMinification or magnification.
[in]currentFilterModeThe current filter mode.
[in]newFilterModeThe new filter mode.
[in]daliDefaultThe default dali filter mode for the given filterType.
[in]systemDefaultThe default system filter mode for the given filterType.

Definition at line 214 of file texture.cpp.

References Dali::Internal::Context::ActiveTexture(), Dali::Internal::FilterModeToGL(), GL_TEXTURE_2D, mContext, and Dali::Internal::Context::TexParameteri().

Referenced by ApplySampler().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Texture::ApplySampler ( TextureUnit  unit,
unsigned int  samplerBitfield 
)
void Dali::Internal::Texture::ApplyWrapModeParameter ( TextureUnit  unit,
GLint  wrapType,
WrapMode::Type  currentWrapMode,
WrapMode::Type  newWrapMode 
)
private

Apply the given texture wrap mode.

Parameters
[in]textureunit to use
[in]wrapTypeUWrap or VWrap
[in]currentWrapModeThe current wrap mode.
[in]newWrapModeThe new wrap mode.

Definition at line 226 of file texture.cpp.

References Dali::Internal::Context::ActiveTexture(), GL_TEXTURE_2D, mContext, Dali::Internal::anonymous_namespace{texture.cpp}::SYSTEM_WRAP_DEFAULT, Dali::Internal::Context::TexParameteri(), and Dali::Internal::WrapModeToGL().

Referenced by ApplySampler().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Texture::Bind ( GLenum  target,
TextureUnit  textureunit 
)
virtual

Binds the texture for use.

If there is no GL texture yet, it tries to create one.

Parameters
target(e.g. GL_TEXTURE_2D)
textureunitto bind to
Returns
True if the opengl texture was created, false if there was already a texture or no texture could be created yet ( e.g. no bitmap data after context loss )

Reimplemented in Dali::Internal::NativeTexture.

Definition at line 166 of file texture.cpp.

References Dali::Internal::Context::BindTextureForUnit(), CreateGlTexture(), DALI_ASSERT_DEBUG, GL_TEXTURE_2D, mContext, and mId.

Referenced by Dali::Internal::SceneGraph::TextureCache::BindTexture(), and Dali::Internal::FrameBufferTexture::Prepare().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool Dali::Internal::Texture::CreateGlTexture ( )
pure virtual

Initialize texture for rendering.

Returns
true on success

Implemented in Dali::Internal::BitmapTexture, Dali::Internal::FrameBufferTexture, Dali::Internal::CompressedBitmapTexture, and Dali::Internal::NativeTexture.

Referenced by Bind().

Here is the caller graph for this function:

unsigned int Dali::Internal::Texture::GetHeight ( ) const
virtual

Return the height of image in pixels.

Returns
height

Reimplemented in Dali::Internal::BitmapTexture, and Dali::Internal::CompressedBitmapTexture.

Definition at line 209 of file texture.cpp.

References mHeight.

Referenced by Dali::Internal::SceneGraph::RenderManager::DoRender().

Here is the caller graph for this function:

unsigned int Dali::Internal::Texture::GetTextureId ( )
inline

Returns GL texture ID.

Returns
texture id

Definition at line 118 of file texture.h.

References mId.

unsigned int Dali::Internal::Texture::GetWidth ( ) const
virtual

Return the width of image in pixels.

Returns
width

Reimplemented in Dali::Internal::BitmapTexture, and Dali::Internal::CompressedBitmapTexture.

Definition at line 204 of file texture.cpp.

References mWidth.

Referenced by Dali::Internal::SceneGraph::RenderManager::DoRender().

Here is the caller graph for this function:

void Dali::Internal::Texture::GlCleanup ( )
virtual

Release all GL resources.

This means releasing buffer objects, textures. etc Context can be used, unless GlContextDestroyed has been called

Precondition
This method can only be called from the render-thread.

Implements Dali::Internal::GlResourceOwner.

Reimplemented in Dali::Internal::FrameBufferTexture, and Dali::Internal::NativeTexture.

Definition at line 194 of file texture.cpp.

References Dali::Internal::Context::DeleteTextures(), mContext, and mId.

Referenced by Dali::Internal::NativeTexture::GlCleanup(), and Dali::Internal::FrameBufferTexture::GlCleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Texture::GlContextDestroyed ( )
virtual

Reset all GL resources.

This method is called when context is or has been deleted. Context cannot be called from this method.

Precondition
This method can only be called from the render-thread.

Implements Dali::Internal::GlResourceOwner.

Definition at line 186 of file texture.cpp.

References mId, and mSamplerBitfield.

virtual bool Dali::Internal::Texture::HasAlphaChannel ( ) const
pure virtual

Query whether the texture data has an alpha channel.

Returns
True if the texture data has an alpha channel.

Implemented in Dali::Internal::BitmapTexture, Dali::Internal::FrameBufferTexture, Dali::Internal::CompressedBitmapTexture, and Dali::Internal::NativeTexture.

virtual bool Dali::Internal::Texture::Init ( )
pure virtual

Initialization method for Texture.

Might or might not be needed in specific implementations.

Returns
true if successful, false otherwise

Implemented in Dali::Internal::FrameBufferTexture, Dali::Internal::BitmapTexture, Dali::Internal::NativeTexture, and Dali::Internal::CompressedBitmapTexture.

Referenced by Dali::Internal::TextureFactory::NewBitmapTexture().

Here is the caller graph for this function:

virtual bool Dali::Internal::Texture::IsFullyOpaque ( ) const
pure virtual

Query whether the texture is completely opaque.

Returns
True if all pixels of the texture data are opaque

Implemented in Dali::Internal::BitmapTexture, Dali::Internal::CompressedBitmapTexture, Dali::Internal::FrameBufferTexture, and Dali::Internal::NativeTexture.

Texture& Dali::Internal::Texture::operator= ( const Texture rhs)
private
void Dali::Internal::Texture::SetTextureId ( GLuint  id)

Sets the texture id.

Parameters
idOpenGL texture id

Definition at line 146 of file texture.cpp.

References mId.

void Dali::Internal::Texture::Update ( Integration::Bitmap bitmap)
virtual

Update the texture with the bitmap.

Reimplemented in Dali::Internal::BitmapTexture, and Dali::Internal::CompressedBitmapTexture.

Definition at line 151 of file texture.cpp.

References DALI_ASSERT_DEBUG.

virtual void Dali::Internal::Texture::Update ( Integration::Bitmap srcBitmap,
std::size_t  xOffset,
std::size_t  yOffset 
)
inlinevirtual

Update part of the texture with a different bitmap.

Parameters
[in]srcBitmapThe bitmap to copy from
[in]xOffsetSpecifies an offset in the x direction within the texture
[in]yOffsetSpecifies an offset in the y direction within the texture

Reimplemented in Dali::Internal::BitmapTexture.

Definition at line 88 of file texture.h.

virtual void Dali::Internal::Texture::Update ( PixelData srcPixelData,
std::size_t  xOffset,
std::size_t  yOffset 
)
inlinevirtual

Update part of the texture with a pixel buffer.

Parameters
[in]srcPixelDataThe pixel data to copy from
[in]xOffsetSpecifies an offset in the x direction within the texture
[in]yOffsetSpecifies an offset in the y direction within the texture

Reimplemented in Dali::Internal::BitmapTexture.

Definition at line 96 of file texture.h.

void Dali::Internal::Texture::UpdateArea ( const RectArea area)
virtual

Update the texture from the modified bitmap.

Parameters
areato update

Reimplemented in Dali::Internal::BitmapTexture.

Definition at line 156 of file texture.cpp.

References DALI_ASSERT_DEBUG.

bool Dali::Internal::Texture::UpdateOnCreate ( )
virtual
Returns
Return true if the texture should be updated on GL texture creation.

Reimplemented in Dali::Internal::BitmapTexture, and Dali::Internal::CompressedBitmapTexture.

Definition at line 161 of file texture.cpp.

Referenced by Dali::Internal::SceneGraph::TextureCache::BindTexture().

Here is the caller graph for this function:

Member Data Documentation

Context& Dali::Internal::Texture::mContext
protected
unsigned int Dali::Internal::Texture::mHeight
protected
GLuint Dali::Internal::Texture::mId
protected
unsigned int Dali::Internal::Texture::mImageHeight
protected

height of the original image (may be smaller than texture height)

Definition at line 252 of file texture.h.

Referenced by Dali::Internal::CompressedBitmapTexture::Update(), Dali::Internal::BitmapTexture::Update(), and Dali::Internal::BitmapTexture::UpdateArea().

unsigned int Dali::Internal::Texture::mImageWidth
protected

width of the original image (may be smaller than texture width)

Definition at line 251 of file texture.h.

Referenced by Dali::Internal::CompressedBitmapTexture::Update(), Dali::Internal::BitmapTexture::Update(), and Dali::Internal::BitmapTexture::UpdateArea().

unsigned int Dali::Internal::Texture::mSamplerBitfield
protected

The packed bitfield of the current sampler.

Definition at line 246 of file texture.h.

Referenced by ApplySampler(), and GlContextDestroyed().

unsigned int Dali::Internal::Texture::mWidth
protected

The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali