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

Texture class. More...

#include <bitmap-texture.h>

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

Public Member Functions

 BitmapTexture (Integration::Bitmap *const bitmap, const Integration::Bitmap::PackedPixelsProfile *const bitmapPackedPixelsProfile, Context &context, ResourcePolicy::Discardable discardPolicy)
 Constructor Creates a new texture object from a Bitmap. More...
 
 BitmapTexture (unsigned int width, unsigned int height, Pixel::Format pixelFormat, bool clearPixels, Context &context, ResourcePolicy::Discardable discardPolicy)
 Constructor Creates a new texture object. More...
 
virtual ~BitmapTexture ()
 Destructor. More...
 
Integration::BitmapGetBitmap ()
 Retrieve the bitmap. More...
 
virtual bool Init ()
 Initialization method for Texture. 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
 Query whether the texture data has an alpha channel. More...
 
virtual bool IsFullyOpaque () const
 Query whether the texture is completely opaque. More...
 
virtual void Update (Integration::Bitmap *bitmap)
 Replace current bitmap with a fresh one, for instance after a Bitmap has been reloaded. 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 void UpdateArea (const RectArea &area)
 Bitmap area has been modified - update the texture appropriately. More...
 
virtual bool UpdateOnCreate ()
 
- Public Member Functions inherited from Dali::Internal::Texture
virtual bool Bind (GLenum target, TextureUnit textureunit)
 Binds the texture for use. More...
 
unsigned int GetTextureId ()
 Returns GL texture ID. 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 ~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

virtual bool CreateGlTexture ()
 Initialize texture for rendering. More...
 
- Protected Member Functions inherited from Dali::Internal::Texture
 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...
 

Private Member Functions

void AreaUpdated (const RectArea &updateArea, const unsigned char *pixels)
 Uploads changes to GPU after Bitmap buffer has changed. More...
 
void AssignBitmap (bool generateTexture, const unsigned char *pixels)
 Assigns the bitmap data to an OpenGL texture Creates a new texture object and copies the image data held in the pixels parameter. More...
 
void DiscardBitmapBuffer ()
 If the discard policy is not RETAIN, then discards the bitmap's pixel buffer. More...
 
void Update (const unsigned char *pixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, std::size_t xOffset, std::size_t yOffset)
 Update part of the texture. More...
 

Private Attributes

Integration::BitmapPtr mBitmap
 The Bitmap the Texture was created from (may be NULL) More...
 
Pixel::Format mPixelFormat
 Pack pixel format into bitfield. More...
 
ResourcePolicy::Discardable mDiscardPolicy
 The bitmap discard policy. More...
 
bool mClearPixels
 true if initial texture should be cleared on creation More...
 
 DALI_LOG_OBJECT_STRING_DECLARATION
 

Additional Inherited Members

- Public Types inherited from Dali::Internal::Texture
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...
 
- Protected Attributes inherited from Dali::Internal::Texture
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...
 

Detailed Description

Texture class.

If you want to load a file to a BitmapTexture use TextureManager::GetTexture()

Definition at line 47 of file bitmap-texture.h.

Constructor & Destructor Documentation

Dali::Internal::BitmapTexture::BitmapTexture ( Integration::Bitmap *const  bitmap,
const Integration::Bitmap::PackedPixelsProfile *const  bitmapPackedPixelsProfile,
Context context,
ResourcePolicy::Discardable  discardPolicy 
)

Constructor Creates a new texture object from a Bitmap.

Parameters
[in]bitmapThe Bitmap
[in]bitmapPackedPixelsProfileThe Bitmap features related to an addressable array of raw pixel data
contextThe GL context

Definition at line 38 of file bitmap-texture.cpp.

References DALI_LOG_GET_OBJECT_STRING, DALI_LOG_SET_OBJECT_STRING, and DALI_LOG_TRACE_METHOD.

Dali::Internal::BitmapTexture::BitmapTexture ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelFormat,
bool  clearPixels,
Context context,
ResourcePolicy::Discardable  discardPolicy 
)

Constructor Creates a new texture object.

Parameters
[in]widthwidth in pixels
[in]heightheight in pixels
[in]pixelFormatpixel format
[in]clearPixelsTrue if the pixel data should be cleared before gl texture creation
[in]contextDali context

Definition at line 57 of file bitmap-texture.cpp.

References DALI_LOG_TRACE_METHOD.

Dali::Internal::BitmapTexture::~BitmapTexture ( )
virtual

Destructor.

Definition at line 75 of file bitmap-texture.cpp.

References DALI_LOG_TRACE_METHOD.

Member Function Documentation

void Dali::Internal::BitmapTexture::AreaUpdated ( const RectArea updateArea,
const unsigned char *  pixels 
)
private
void Dali::Internal::BitmapTexture::AssignBitmap ( bool  generateTexture,
const unsigned char *  pixels 
)
private

Assigns the bitmap data to an OpenGL texture Creates a new texture object and copies the image data held in the pixels parameter.

Precondition
The texture has to have a width/height that is a power of 2.
Parameters
[in]generateTextureTrue if we should generate a GL texture id
[in]pixelsThe pixel data

Definition at line 153 of file bitmap-texture.cpp.

References Dali::Internal::Context::ActiveTexture(), Dali::Internal::Context::Bind2dTexture(), Dali::Integration::ConvertToGlFormat(), DALI_ASSERT_DEBUG, DALI_LOG_INFO, DALI_LOG_TRACE_METHOD, DiscardBitmapBuffer(), Dali::Internal::Context::GenTextures(), Dali::Pixel::GetBytesPerPixel(), GL_CLAMP_TO_EDGE, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, INCREASE_BY, Dali::Internal::Texture::mContext, Dali::Internal::Texture::mHeight, Dali::Internal::Texture::mId, mPixelFormat, Dali::Internal::Texture::mWidth, Dali::Internal::Context::PixelStorei(), Dali::Internal::Context::TexImage2D(), Dali::Internal::Context::TexParameteri(), and Dali::Internal::TEXTURE_UNIT_UPLOAD.

Referenced by CreateGlTexture(), and Update().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::BitmapTexture::CreateGlTexture ( )
protectedvirtual
void Dali::Internal::BitmapTexture::DiscardBitmapBuffer ( )
private

If the discard policy is not RETAIN, then discards the bitmap's pixel buffer.

Definition at line 423 of file bitmap-texture.cpp.

References DALI_LOG_INFO, mBitmap, mDiscardPolicy, and Dali::ResourcePolicy::OWNED_DISCARD.

Referenced by AssignBitmap(), CreateGlTexture(), and Update().

Here is the caller graph for this function:

Integration::Bitmap* Dali::Internal::BitmapTexture::GetBitmap ( )
inline

Retrieve the bitmap.

Returns
The bitmap or NULL if already discarded

Definition at line 80 of file bitmap-texture.h.

References Dali::IntrusivePtr< T >::Get(), and mBitmap.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Return the height of image in pixels.

Returns
height

Reimplemented from Dali::Internal::Texture.

Definition at line 413 of file bitmap-texture.cpp.

References height, mBitmap, and Dali::Internal::Texture::mHeight.

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

Return the width of image in pixels.

Returns
width

Reimplemented from Dali::Internal::Texture.

Definition at line 403 of file bitmap-texture.cpp.

References mBitmap, Dali::Internal::Texture::mWidth, and width.

bool Dali::Internal::BitmapTexture::HasAlphaChannel ( ) const
virtual

Query whether the texture data has an alpha channel.

Returns
True if the texture data has an alpha channel.

Implements Dali::Internal::Texture.

Definition at line 83 of file bitmap-texture.cpp.

References Dali::Pixel::HasAlpha(), and mPixelFormat.

Referenced by IsFullyOpaque().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::BitmapTexture::Init ( )
virtual

Initialization method for Texture.

Might or might not be needed in specific implementations.

Returns
true if successful, false otherwise

Implements Dali::Internal::Texture.

Definition at line 396 of file bitmap-texture.cpp.

References DALI_LOG_TRACE_METHOD, and mBitmap.

bool Dali::Internal::BitmapTexture::IsFullyOpaque ( ) const
virtual

Query whether the texture is completely opaque.

Returns
True if all pixels of the texture data are opaque

Implements Dali::Internal::Texture.

Definition at line 88 of file bitmap-texture.cpp.

References HasAlphaChannel(), and mBitmap.

Here is the call graph for this function:

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

Replace current bitmap with a fresh one, for instance after a Bitmap has been reloaded.

Parameters
[in]bitmapThe new bitmap

! This should never happen.

Reimplemented from Dali::Internal::Texture.

Definition at line 185 of file bitmap-texture.cpp.

References AreaUpdated(), AssignBitmap(), DALI_ASSERT_DEBUG, DALI_LOG_ERROR, DALI_LOG_INFO, DiscardBitmapBuffer(), Dali::Integration::Bitmap::PackedPixelsProfile::GetBufferHeight(), Dali::Integration::Bitmap::PackedPixelsProfile::GetBufferWidth(), Dali::Integration::Bitmap::GetPackedPixelsProfile(), mBitmap, Dali::Internal::Texture::mHeight, Dali::Internal::Texture::mId, Dali::Internal::Texture::mImageHeight, Dali::Internal::Texture::mImageWidth, mPixelFormat, and Dali::Internal::Texture::mWidth.

Referenced by Update().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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 from Dali::Internal::Texture.

Definition at line 241 of file bitmap-texture.cpp.

References Dali::Integration::Bitmap::GetBuffer(), Dali::Integration::Bitmap::GetImageHeight(), Dali::Integration::Bitmap::GetImageWidth(), Dali::Integration::Bitmap::GetPixelFormat(), and Update().

Here is the call graph for this function:

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

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 from Dali::Internal::Texture.

Definition at line 250 of file bitmap-texture.cpp.

References Dali::PixelData::GetBuffer(), Dali::PixelData::GetHeight(), Dali::PixelData::GetPixelFormat(), Dali::PixelData::GetWidth(), and Update().

Here is the call graph for this function:

void Dali::Internal::BitmapTexture::Update ( const unsigned char *  pixels,
std::size_t  width,
std::size_t  height,
Pixel::Format  pixelFormat,
std::size_t  xOffset,
std::size_t  yOffset 
)
private
void Dali::Internal::BitmapTexture::UpdateArea ( const RectArea area)
virtual

Bitmap area has been modified - update the texture appropriately.

Precondition
The bitmap hasn't been discarded (should be external type)
Parameters
[in]areaThe updated area

Reimplemented from Dali::Internal::Texture.

Definition at line 323 of file bitmap-texture.cpp.

References AreaUpdated(), DALI_LOG_INFO, Dali::Rect< T >::height, Dali::Rect< T >::IsEmpty(), mBitmap, Dali::Internal::Texture::mId, Dali::Internal::Texture::mImageHeight, Dali::Internal::Texture::mImageWidth, Dali::Rect< T >::width, Dali::Rect< T >::x, and Dali::Rect< T >::y.

Here is the call graph for this function:

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

Reimplemented from Dali::Internal::Texture.

Definition at line 355 of file bitmap-texture.cpp.

Member Data Documentation

Dali::Internal::BitmapTexture::DALI_LOG_OBJECT_STRING_DECLARATION
private

Definition at line 192 of file bitmap-texture.h.

Integration::BitmapPtr Dali::Internal::BitmapTexture::mBitmap
private

The Bitmap the Texture was created from (may be NULL)

Definition at line 186 of file bitmap-texture.h.

Referenced by CreateGlTexture(), DiscardBitmapBuffer(), GetBitmap(), GetHeight(), GetWidth(), Init(), IsFullyOpaque(), Update(), and UpdateArea().

bool Dali::Internal::BitmapTexture::mClearPixels
private

true if initial texture should be cleared on creation

Definition at line 189 of file bitmap-texture.h.

Referenced by CreateGlTexture().

ResourcePolicy::Discardable Dali::Internal::BitmapTexture::mDiscardPolicy
private

The bitmap discard policy.

Definition at line 188 of file bitmap-texture.h.

Referenced by DiscardBitmapBuffer().

Pixel::Format Dali::Internal::BitmapTexture::mPixelFormat
private

Pack pixel format into bitfield.

Definition at line 187 of file bitmap-texture.h.

Referenced by AreaUpdated(), AssignBitmap(), CreateGlTexture(), HasAlphaChannel(), and Update().


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