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

BufferImage represents an image resource that can be added to actors etc. More...

#include <buffer-image-impl.h>

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

Public Member Functions

 BufferImage (unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Create a new BufferImage. More...
 
 BufferImage (PixelBuffer *pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Create a new BufferImage, which uses external data source. More...
 
void Update (RectArea &updateArea)
 Notify Dali that the contents of the buffer have changed. More...
 
bool IsDataExternal () const
 Returns whether BufferImage uses external data source or not. More...
 
PixelBufferGetBuffer () const
 Returns the pixel buffer of the Image. More...
 
unsigned int GetBufferSize () const
 Returns buffer size in bytes. More...
 
unsigned int GetBufferStride () const
 Returns buffer stride (in bytes). More...
 
Pixel::Format GetPixelFormat () const
 Get the pixel format. More...
 
void UploadBitmap (ResourceId destId, std::size_t xOffset, std::size_t yOffset)
 Upload pixel data to another resource at an offset. More...
 
- Public Member Functions inherited from Dali::Internal::Image
ReleasePolicy GetReleasePolicy () const
 .3 More...
 
Dali::Image::ImageSignalTypeUploadedSignal ()
 This signal is emitted when the image data gets uploaded to GL. More...
 
ResourceId GetResourceId () const
 returns the Id used for lookups More...
 
virtual unsigned int GetWidth () const
 Get the width of the image. More...
 
virtual unsigned int GetHeight () const
 Get the height of the image. More...
 
virtual Vector2 GetNaturalSize () const
 Return the natural size of the image. More...
 
virtual void ResourceLoadingFailed (const ResourceTicket &ticket)
 Called when a resource fails to load. More...
 
virtual void ResourceLoadingSucceeded (const ResourceTicket &ticket)
 Called when a resource loads successfully. More...
 
virtual void ResourceUploaded (const ResourceTicket &ticket)
 Called when a resource is uploaded to graphics memory. More...
 
- Public Member Functions inherited from Dali::BaseObject
template<class T >
bool ConnectSignal (ConnectionTrackerInterface *connectionTracker, const std::string &signalName, const T &functor)
 Connects a void() functor to a specified signal. More...
 
bool DoAction (const std::string &actionName, const Property::Map &attributes)
 Perform action on this object with the given action name and attributes. More...
 
const std::string & GetTypeName () const
 Returns the type name for the Handle. More...
 
bool GetTypeInfo (Dali::TypeInfo &info) const
 Returns the type info for the Handle. More...
 
bool DoConnectSignal (ConnectionTrackerInterface *connectionTracker, const std::string &signalName, FunctorDelegate *functorDelegate)
 Not intended for application developers. 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...
 

Static Public Member Functions

static BufferImagePtr New (unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Create a new BufferImage. More...
 
static BufferImagePtr New (PixelBuffer *pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 .5. More...
 
- Static Public Member Functions inherited from Dali::Internal::Image
static bool DoConnectSignal (BaseObject *object, ConnectionTrackerInterface *tracker, const std::string &signalName, FunctorDelegate *functor)
 Connects a callback function with the object's signals. More...
 

Protected Member Functions

virtual ~BufferImage ()
 A reference counted object may only be deleted by calling Unreference() More...
 
virtual void Connect ()
 Indicates that the image is used. More...
 
virtual void Disconnect ()
 Indicates that the image is not used anymore. More...
 
- Protected Member Functions inherited from Dali::Internal::Image
virtual ~Image ()
 A reference counted object may only be deleted by calling Unreference() More...
 
 Image (ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Constructor, with default parameters. More...
 
void Initialize ()
 Second stage initialization. More...
 
- Protected Member Functions inherited from Dali::BaseObject
 BaseObject ()
 Default constructor. More...
 
virtual ~BaseObject ()
 A reference counted object may only be deleted by calling Unreference(). More...
 
void RegisterObject ()
 Registers the object as created with the Object registry. More...
 
void UnregisterObject ()
 Unregisters the object from Object registry. 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 SetupBuffer (unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int byteStride, ReleasePolicy releasePol)
 
void CreateHostBitmap ()
 
void UploadArea (ResourceId destId, const RectArea &area)
 
void UpdateBufferArea (PixelBuffer *src, PixelBuffer *dest, const RectArea &area)
 

Private Attributes

PixelBuffermInternalBuffer
 NULL if the data is supplied by an external buffer. More...
 
PixelBuffermExternalBuffer
 NULL if there is no external pixel data (this is never owned by BufferImage). More...
 
ResourceClientmResourceClient
 pointer to the resource client. More...
 
uint32_t mBufferSize
 size of the pixel buffer. More...
 
uint32_t mByteStride
 width of the pixel buffer in bytes. More...
 
uint32_t mBytesPerPixel
 width of a pixel in bytes. More...
 
uint32_t mBufferWidth
 cached pixel width of bitmap used for transport. More...
 
Pixel::Format mPixelFormat
 pixel format of bitmap. More...
 
ResourcePolicy::Discardable mResourcePolicy
 whether to discard the pixel buffer when removed from the stage or to retain the data. More...
 

Additional Inherited Members

- Protected Attributes inherited from Dali::Internal::Image
ResourceTicketPtr mTicket
 smart pointer to the ticket object that gets completed when load finishes More...
 
unsigned int mWidth
 natural width of the image, needs to be mutable for lazy resolving and as the API for GetWidth is const More...
 
unsigned int mHeight
 natural height of the image, needs to be mutable for lazy resolving and as the API for GetHeight is const More...
 
unsigned int mConnectionCount
 number of on-stage objects using this image More...
 
ReleasePolicy mReleasePolicy: 2
 2 bits is enough space More...
 

Detailed Description

BufferImage represents an image resource that can be added to actors etc.

Its pixel buffer data is provided by the application developer. Pixel buffer memory allocation can be handled by dali or application.

Definition at line 45 of file buffer-image-impl.h.

Constructor & Destructor Documentation

Dali::Internal::BufferImage::BufferImage ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)

Create a new BufferImage.

Also a pixel buffer for image data is allocated. Dali has ownership of the buffer. For better performance use power of two dimensions. The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.

Parameters
[in]widthimage width in pixels
[in]heightimage height in pixels
[in]pixelformatthe pixel format (rgba 32 bit by default)
[in]releasePoloptionally release memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 65 of file buffer-image-impl.cpp.

References mBufferSize, mInternalBuffer, and SetupBuffer().

Here is the call graph for this function:

Dali::Internal::BufferImage::BufferImage ( PixelBuffer pixBuf,
unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat,
unsigned int  stride,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)

Create a new BufferImage, which uses external data source.

Pixel buffer has to be allocated by application. An internal copy is made of the Pixel Buffer, which can then be freed by the Application, unless if there will be a call to Update() later. The buffer should only be freed when there is no chance of Update() being called again. Note: obtaining the buffer with GetBuffer(), writing changes, then Update() will cause any changes to be lost. In this case, the BufferImage will update from the external buffer and so changes should be written there. For better performance and portability use power of two dimensions. The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.

Parameters
[in]pixBufpixel buffer. has to be allocated by application.
[in]widthimage width in pixels
[in]heightimage height in pixels
[in]pixelformatthe pixel format (rgba 32 bit by default)
[in]stridethe internal stride of the pixelbuffer in pixels
[in]releasePoloptionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 83 of file buffer-image-impl.cpp.

References SetupBuffer().

Here is the call graph for this function:

Dali::Internal::BufferImage::~BufferImage ( )
protectedvirtual

A reference counted object may only be deleted by calling Unreference()

Definition at line 103 of file buffer-image-impl.cpp.

References mInternalBuffer.

Member Function Documentation

void Dali::Internal::BufferImage::Connect ( )
protectedvirtual

Indicates that the image is used.

Reimplemented from Dali::Internal::Image.

Definition at line 224 of file buffer-image-impl.cpp.

References Dali::Internal::Image::mConnectionCount, and Update().

Here is the call graph for this function:

void Dali::Internal::BufferImage::CreateHostBitmap ( )
private
void Dali::Internal::BufferImage::Disconnect ( )
protectedvirtual

Indicates that the image is not used anymore.

Reimplemented from Dali::Internal::Image.

Definition at line 233 of file buffer-image-impl.cpp.

References Dali::Internal::Image::mConnectionCount, Dali::Internal::Image::mReleasePolicy, Dali::Internal::Image::mTicket, Dali::IntrusivePtr< T >::Reset(), and Dali::Image::UNUSED.

Here is the call graph for this function:

PixelBuffer* Dali::Internal::BufferImage::GetBuffer ( ) const
inline

Returns the pixel buffer of the Image.

The application developer can write to the buffer. Upload the modified contents with Update().

Returns
the pixel buffer

Definition at line 153 of file buffer-image-impl.h.

References mExternalBuffer, and mInternalBuffer.

unsigned int Dali::Internal::BufferImage::GetBufferSize ( ) const
inline

Returns buffer size in bytes.

Returns
the buffer size in bytes

Definition at line 162 of file buffer-image-impl.h.

References mBufferSize.

unsigned int Dali::Internal::BufferImage::GetBufferStride ( ) const
inline

Returns buffer stride (in bytes).

Returns
the buffer stride

Definition at line 171 of file buffer-image-impl.h.

References mByteStride.

Pixel::Format Dali::Internal::BufferImage::GetPixelFormat ( ) const
inline

Get the pixel format.

Returns
The pixel format

Definition at line 180 of file buffer-image-impl.h.

References mPixelFormat.

bool Dali::Internal::BufferImage::IsDataExternal ( ) const

Returns whether BufferImage uses external data source or not.

If not, dali holds ownership of the PixelBuffer, otherwise the application is responsible for freeing it.

The application must not destroy an external PixelBuffer on a staged image if it has called Update() and hasn't received a SignalUploaded.

.0

Returns
true if application owns data, false otherwise

Definition at line 128 of file buffer-image-impl.cpp.

References mExternalBuffer.

BufferImagePtr Dali::Internal::BufferImage::New ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)
static

Create a new BufferImage.

Also a pixel buffer for image data is allocated. Dali has ownership of the buffer. For better performance and portability use power of two dimensions. The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.

Parameters
[in]widthimage width in pixels
[in]heightimage height in pixels
[in]pixelformatthe pixel format (rgba 32 bit by default)
[in]releasePoloptionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 43 of file buffer-image-impl.cpp.

Referenced by Dali::Internal::Atlas::ClearBackground(), Dali::Internal::NinePatchImage::CreateCroppedBufferImage(), and Dali::BufferImage::New().

Here is the caller graph for this function:

BufferImagePtr Dali::Internal::BufferImage::New ( PixelBuffer pixBuf,
unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat,
unsigned int  stride,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)
static

.5.

Support for externally owned Pixel Buffers is due to be removed TBA. It is recommended that a BufferImage owned Buffer be used instead.

Create a new BufferImage, which uses external data source.

Pixel buffer has to be allocated by application. An internal copy is made of the Pixel Buffer, which can then be freed by the Application, unless if there will be a call to Update() later. The buffer should only be freed when there is no chance of an Update() being called again. Obtaining the buffer with GetBuffer() and altering the contents, then Update() will not work with externally owned buffers. For better performance and portability use power of two dimensions. The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.

Parameters
[in]pixBufpixel buffer. has to be allocated by application.
[in]widthimage width in pixels
[in]heightimage height in pixels
[in]pixelformatthe pixel format (rgba 32 bit by default)
[in]stridethe internal stride of the pixelbuffer in pixels
[in]releasePoloptionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 53 of file buffer-image-impl.cpp.

void Dali::Internal::BufferImage::SetupBuffer ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat,
unsigned int  byteStride,
ReleasePolicy  releasePol 
)
private
void Dali::Internal::BufferImage::Update ( RectArea updateArea)

Notify Dali that the contents of the buffer have changed.

Parameters
[in]updateAreaarea that has changed in buffer. An empty rect means the whole buffer has changed.

Definition at line 133 of file buffer-image-impl.cpp.

References CreateHostBitmap(), DALI_ASSERT_DEBUG, Dali::Rect< T >::height, Dali::Internal::Image::mHeight, Dali::Internal::Image::mTicket, Dali::Internal::Image::mWidth, UploadArea(), Dali::Rect< T >::width, Dali::Rect< T >::x, and Dali::Rect< T >::y.

Referenced by Connect().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::BufferImage::UpdateBufferArea ( PixelBuffer src,
PixelBuffer dest,
const RectArea area 
)
private
void Dali::Internal::BufferImage::UploadArea ( ResourceId  destId,
const RectArea area 
)
private
void Dali::Internal::BufferImage::UploadBitmap ( ResourceId  destId,
std::size_t  xOffset,
std::size_t  yOffset 
)

Upload pixel data to another resource at an offset.

Parameters
destIdResourceId of the destination
xOffsetx offset in the destination
yOffsety offset in the destination

Definition at line 198 of file buffer-image-impl.cpp.

References CreateHostBitmap(), Dali::Internal::Image::mTicket, and UploadArea().

Referenced by Dali::Internal::Atlas::Upload().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

uint32_t Dali::Internal::BufferImage::mBufferSize
private

size of the pixel buffer.

Definition at line 224 of file buffer-image-impl.h.

Referenced by BufferImage(), GetBufferSize(), SetupBuffer(), and UploadArea().

uint32_t Dali::Internal::BufferImage::mBufferWidth
private

cached pixel width of bitmap used for transport.

Definition at line 227 of file buffer-image-impl.h.

Referenced by UpdateBufferArea(), and UploadArea().

uint32_t Dali::Internal::BufferImage::mBytesPerPixel
private

width of a pixel in bytes.

Definition at line 226 of file buffer-image-impl.h.

Referenced by CreateHostBitmap(), SetupBuffer(), UpdateBufferArea(), and UploadArea().

uint32_t Dali::Internal::BufferImage::mByteStride
private

width of the pixel buffer in bytes.

Definition at line 225 of file buffer-image-impl.h.

Referenced by GetBufferStride(), SetupBuffer(), UpdateBufferArea(), and UploadArea().

PixelBuffer* Dali::Internal::BufferImage::mExternalBuffer
private

NULL if there is no external pixel data (this is never owned by BufferImage).

Definition at line 222 of file buffer-image-impl.h.

Referenced by GetBuffer(), IsDataExternal(), and UploadArea().

PixelBuffer* Dali::Internal::BufferImage::mInternalBuffer
private

NULL if the data is supplied by an external buffer.

Definition at line 221 of file buffer-image-impl.h.

Referenced by BufferImage(), GetBuffer(), UploadArea(), and ~BufferImage().

Pixel::Format Dali::Internal::BufferImage::mPixelFormat
private

pixel format of bitmap.

Definition at line 228 of file buffer-image-impl.h.

Referenced by CreateHostBitmap(), GetPixelFormat(), SetupBuffer(), and UploadArea().

ResourceClient* Dali::Internal::BufferImage::mResourceClient
private

pointer to the resource client.

Definition at line 223 of file buffer-image-impl.h.

Referenced by CreateHostBitmap(), SetupBuffer(), and UploadArea().

ResourcePolicy::Discardable Dali::Internal::BufferImage::mResourcePolicy
private

whether to discard the pixel buffer when removed from the stage or to retain the data.

Definition at line 229 of file buffer-image-impl.h.

Referenced by CreateHostBitmap(), SetupBuffer(), and UploadArea().


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