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

Internal class for Dali::Atlas. More...

#include <atlas-impl.h>

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

Classes

struct  Tile
 Record of the url resource in the Atlas. More...
 

Public Member Functions

void Clear (const Vector4 &color)
 Clear the Atlas with the given color. More...
 
bool Upload (BufferImage &bufferImage, SizeType xOffset, SizeType yOffset)
  More...
 
bool Upload (const std::string &url, SizeType xOffset, SizeType yOffset)
 Upload a resource image to atlas. More...
 
bool Upload (PixelDataPtr pixelData, SizeType xOffset, SizeType yOffset)
  More...
 
virtual void RecoverFromContextLoss ()
 Restore the object after context loss. 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 AtlasNew (SizeType width, SizeType height, Pixel::Format pixelFormat, bool recoverContext)
 Create a new Atlas. 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

 Atlas (SizeType width, SizeType height, Pixel::Format pixelFormat, bool recoverContext)
 Protected constructor. More...
 
virtual ~Atlas ()
 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...
 
- Protected Member Functions inherited from Dali::Internal::ContextRecoveryInterface
 ContextRecoveryInterface ()
 Constructor. More...
 
virtual ~ContextRecoveryInterface ()
 Destructor. More...
 

Private Member Functions

bool IsInside (SizeType x, SizeType y)
 Helper for Upload methods. More...
 
void AllocateAtlas ()
 Helper to create the Atlas resource. More...
 
void ReleaseAtlas ()
 Helper to release the Atlas resource. More...
 
void ClearBackground (const Vector4 &color)
 Upload a bitmap with the given color to clear the background. More...
 
void ClearCache ()
 Clear all the current tiles and resources of the atlas. More...
 
Integration::BitmapPtr LoadBitmap (const std::string &url)
 Load the bitmap data from the url. More...
 

Private Attributes

ResourceClientmResourceClient
 
ImageFactorymImageFactory
 
Vector4 mClearColor
 The background clear color. More...
 
Vector< Tile * > mTiles
 The url resources, which would recover automatically when regaining context. More...
 
Pixel::Format mPixelFormat
 The pixel format (rgba 32 bit by default) More...
 
bool mClear:1
 Clear the backgound or not. More...
 
bool mRecoverContext:1
 Re-upload the url resources or not when regaining context. 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

Internal class for Dali::Atlas.

Definition at line 41 of file atlas-impl.h.

Constructor & Destructor Documentation

Dali::Internal::Atlas::Atlas ( SizeType  width,
SizeType  height,
Pixel::Format  pixelFormat,
bool  recoverContext 
)
protected

Protected constructor.

Precondition
width & height are greater than zero. The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
Parameters
[in]widthThe atlas width in pixels.
[in]heightThe atlas height in pixels.
[in]pixelFormatThe pixel format.
[in]recoverContextWhether re-uploading the resource images automatically when regaining the context

Definition at line 154 of file atlas-impl.cpp.

References height, Dali::Internal::Image::mHeight, Dali::Internal::Image::mWidth, and width.

Referenced by New().

Here is the caller graph for this function:

Dali::Internal::Atlas::~Atlas ( )
protectedvirtual

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

Definition at line 149 of file atlas-impl.cpp.

References ReleaseAtlas().

Here is the call graph for this function:

Member Function Documentation

void Dali::Internal::Atlas::AllocateAtlas ( )
private

Helper to create the Atlas resource.

Definition at line 209 of file atlas-impl.cpp.

References Dali::Internal::ResourceClient::AllocateTexture(), Dali::Internal::Image::mHeight, mImageFactory, mPixelFormat, mResourceClient, Dali::Internal::Image::mTicket, Dali::Internal::Image::mWidth, and Dali::Internal::ImageFactory::RegisterForContextRecovery().

Referenced by ClearBackground(), Connect(), and Upload().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Atlas::Clear ( const Vector4 color)

Clear the Atlas with the given color.

Note
The Atlas does not clear itself automatically during construction. Application should call this clear function to avoid getting garbage pixels in the atlas. By calling Clear, all the current uploaded image information will be lost.
Parameters
[in]colorThe color used to clear the Atlas.

Definition at line 53 of file atlas-impl.cpp.

References ClearBackground(), and ClearCache().

Here is the call graph for this function:

void Dali::Internal::Atlas::ClearBackground ( const Vector4 color)
private
void Dali::Internal::Atlas::ClearCache ( )
private

Clear all the current tiles and resources of the atlas.

Definition at line 276 of file atlas-impl.cpp.

References mTiles.

Referenced by Clear(), and ReleaseAtlas().

Here is the caller graph for this function:

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

Indicates that the image is used.

Reimplemented from Dali::Internal::Image.

Definition at line 169 of file atlas-impl.cpp.

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

Here is the call graph for this function:

void Dali::Internal::Atlas::Disconnect ( )
protectedvirtual

Indicates that the image is not used anymore.

Reimplemented from Dali::Internal::Image.

Definition at line 179 of file atlas-impl.cpp.

References Dali::Internal::Image::mConnectionCount, Dali::Internal::Image::mReleasePolicy, ReleaseAtlas(), and Dali::Image::UNUSED.

Here is the call graph for this function:

bool Dali::Internal::Atlas::IsInside ( SizeType  x,
SizeType  y 
)
private

Helper for Upload methods.

Returns
True if the size of the bitmap fits within the atlas at the specified offset

Definition at line 193 of file atlas-impl.cpp.

References DALI_LOG_ERROR, Dali::Internal::Image::mHeight, and Dali::Internal::Image::mWidth.

Referenced by Upload().

Here is the caller graph for this function:

Integration::BitmapPtr Dali::Internal::Atlas::LoadBitmap ( const std::string &  url)
private

Load the bitmap data from the url.

Definition at line 286 of file atlas-impl.cpp.

References Dali::Internal::ThreadLocalStorage::Get(), Dali::IntrusivePtr< T >::Get(), Dali::Internal::ThreadLocalStorage::GetPlatformAbstraction(), and Dali::Integration::PlatformAbstraction::LoadResourceSynchronously().

Referenced by RecoverFromContextLoss(), and Upload().

Here is the call graph for this function:

Here is the caller graph for this function:

Atlas * Dali::Internal::Atlas::New ( SizeType  width,
SizeType  height,
Pixel::Format  pixelFormat,
bool  recoverContext 
)
static

Create a new Atlas.

Precondition
width & height are greater than zero. The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
Parameters
[in]widthThe atlas width in pixels.
[in]heightThe atlas height in pixels.
[in]pixelFormatThe pixel format.
[in]recoverContextWhether re-uploading the resource images automatically when regaining the context
Returns
A pointer to a new Atlas.

Definition at line 45 of file atlas-impl.cpp.

References Atlas().

Referenced by Dali::Atlas::New().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Atlas::RecoverFromContextLoss ( )
virtual

Restore the object after context loss.

Implements Dali::Internal::ContextRecoveryInterface.

Definition at line 126 of file atlas-impl.cpp.

References ClearBackground(), Dali::Internal::Image::GetResourceId(), LoadBitmap(), mClear, mClearColor, mRecoverContext, mResourceClient, mTiles, and Dali::Internal::ResourceClient::UploadBitmap().

Here is the call graph for this function:

void Dali::Internal::Atlas::ReleaseAtlas ( )
private

Helper to release the Atlas resource.

Definition at line 219 of file atlas-impl.cpp.

References ClearCache(), mImageFactory, Dali::Internal::Image::mTicket, Dali::IntrusivePtr< T >::Reset(), and Dali::Internal::ImageFactory::UnregisterFromContextRecovery().

Referenced by Disconnect(), and ~Atlas().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Atlas::Upload ( BufferImage bufferImage,
SizeType  xOffset,
SizeType  yOffset 
)
bool Dali::Internal::Atlas::Upload ( const std::string &  url,
SizeType  xOffset,
SizeType  yOffset 
)

Upload a resource image to atlas.

Parameters
[in]urlThe URL of the resource image file to use
[in]xOffsetSpecifies an offset in the x direction within the atlas.
[in]yOffsetSpecifies an offset in the y direction within the atlas.
Returns
True if the image has compatible pixel format and fits within the atlas at the specified offset.

Definition at line 80 of file atlas-impl.cpp.

References AllocateAtlas(), Dali::Internal::Image::GetResourceId(), IsInside(), LoadBitmap(), mRecoverContext, mResourceClient, mTiles, and Dali::Internal::ResourceClient::UploadBitmap().

Here is the call graph for this function:

bool Dali::Internal::Atlas::Upload ( PixelDataPtr  pixelData,
SizeType  xOffset,
SizeType  yOffset 
)

Member Data Documentation

bool Dali::Internal::Atlas::mClear
private

Clear the backgound or not.

Definition at line 186 of file atlas-impl.h.

Referenced by ClearBackground(), and RecoverFromContextLoss().

Vector4 Dali::Internal::Atlas::mClearColor
private

The background clear color.

Definition at line 183 of file atlas-impl.h.

Referenced by ClearBackground(), and RecoverFromContextLoss().

ImageFactory& Dali::Internal::Atlas::mImageFactory
private

Definition at line 182 of file atlas-impl.h.

Referenced by AllocateAtlas(), and ReleaseAtlas().

Pixel::Format Dali::Internal::Atlas::mPixelFormat
private

The pixel format (rgba 32 bit by default)

Definition at line 185 of file atlas-impl.h.

Referenced by AllocateAtlas(), and ClearBackground().

bool Dali::Internal::Atlas::mRecoverContext
private

Re-upload the url resources or not when regaining context.

Definition at line 187 of file atlas-impl.h.

Referenced by RecoverFromContextLoss(), and Upload().

ResourceClient& Dali::Internal::Atlas::mResourceClient
private

Definition at line 181 of file atlas-impl.h.

Referenced by AllocateAtlas(), RecoverFromContextLoss(), and Upload().

Vector<Tile*> Dali::Internal::Atlas::mTiles
private

The url resources, which would recover automatically when regaining context.

Definition at line 184 of file atlas-impl.h.

Referenced by ClearCache(), RecoverFromContextLoss(), and Upload().


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