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

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

#include <nine-patch-image-impl.h>

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

Public Types

typedef Dali::Vector< Uint16PairStretchRanges
 

Public Member Functions

 NinePatchImage (const std::string &filename, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Create a new NinePatchImage For better performance and portability use power of two dimensions. More...
 
const StretchRangesGetStretchPixelsX ()
 Retrieves the horizontal stretch pixel ranges in the cropped image space. More...
 
const StretchRangesGetStretchPixelsY ()
 Retrieves the vertical stretch pixel ranges in the cropped image space. More...
 
Rect< int > GetChildRectangle ()
 Get the child rectangle. More...
 
BufferImagePtr CreateCroppedBufferImage ()
 Create a cropped image from the bitmap with the 1 pixel border cropped off. More...
 
- Public Member Functions inherited from Dali::Internal::ResourceImage
Dali::LoadingState GetLoadingState () const
 Query whether the image data has loaded. More...
 
LoadPolicy GetLoadPolicy () const
 .3 More...
 
Dali::ResourceImage::ResourceImageSignalLoadingFinishedSignal ()
 Emitted when the image data loads successfully, or when the loading fails. More...
 
const ImageAttributesGetAttributes () const
 Get the attributes of the image. More...
 
const std::string & GetUrl () const
 Returns the URL of the image. More...
 
void Reload ()
 Reload image from filesystem. More...
 
virtual unsigned int GetWidth () const
 Returns the width of the image. More...
 
virtual unsigned int GetHeight () const
 Returns the width 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...
 
- 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 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 NinePatchImagePtr New (const std::string &filename, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Create a new NinePatchImage. More...
 
static NinePatchImageDownCast (Image *image)
 Convert Image object to a 9 patch image object if possible. More...
 
static bool IsNinePatchUrl (const std::string &url)
  More...
 
- Static Public Member Functions inherited from Dali::Internal::ResourceImage
static ResourceImagePtr New ()
 Creates a pointer to an uninitialized Image object. More...
 
static ResourceImagePtr New (const std::string &url, const ImageAttributes &attributes, LoadPolicy loadPol=IMAGE_LOAD_POLICY_DEFAULT, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Creates object and loads image from filesystem the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE. More...
 
static bool DoConnectSignal (BaseObject *object, ConnectionTrackerInterface *tracker, const std::string &signalName, FunctorDelegate *functor)
 Connects a callback function with the object's signals. 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 ~NinePatchImage ()
 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::ResourceImage
virtual ~ResourceImage ()
 A reference counted object may only be deleted by calling Unreference() More...
 
 ResourceImage (LoadPolicy loadPol=IMAGE_LOAD_POLICY_DEFAULT, ReleasePolicy releasePol=IMAGE_RELEASE_POLICY_DEFAULT)
 Constructor, with default parameters. 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 ParseBorders ()
 Read the borders of the bitmap and determine the child area and stretch borders. More...
 
Uint16Pair ParseRange (unsigned int &index, unsigned int width, const PixelBuffer *&pixel, unsigned int pixelStride, int testByte, int testBits, int testValue)
 

Private Attributes

ResourceClientmResourceClient
 
Integration::BitmapPtr mBitmap
 
StretchRanges mStretchPixelsX
 
StretchRanges mStretchPixelsY
 
Rect< int > mChildRectangle
 
bool mParsedBorder
 

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

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

It's image data has a border which determines stretch and fill areas Its pixel buffer data is loaded synchronously from file.

Definition at line 48 of file nine-patch-image-impl.h.

Member Typedef Documentation

Definition at line 51 of file nine-patch-image-impl.h.

Constructor & Destructor Documentation

Dali::Internal::NinePatchImage::NinePatchImage ( const std::string &  filename,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)

Create a new NinePatchImage 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]filenameFile to load synchronously into buffer
[in]releasePoloptionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 176 of file nine-patch-image-impl.cpp.

References Dali::Internal::ThreadLocalStorage::Get(), Dali::IntrusivePtr< T >::Get(), Dali::Internal::ThreadLocalStorage::GetPlatformAbstraction(), Dali::Internal::ThreadLocalStorage::GetResourceClient(), Dali::Integration::PlatformAbstraction::LoadResourceSynchronously(), mBitmap, Dali::Internal::Image::mHeight, mResourceClient, Dali::Internal::Image::mWidth, and Dali::IntrusivePtr< T >::Reset().

Referenced by New().

Here is the call graph for this function:

Here is the caller graph for this function:

Dali::Internal::NinePatchImage::~NinePatchImage ( )
protectedvirtual

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

Definition at line 207 of file nine-patch-image-impl.cpp.

Member Function Documentation

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

Indicates that the image is used.

Reimplemented from Dali::Internal::ResourceImage.

Definition at line 278 of file nine-patch-image-impl.cpp.

References Dali::Internal::ResourceClient::AddBitmapImage(), Dali::IntrusivePtr< T >::Get(), mBitmap, Dali::Internal::Image::mConnectionCount, mResourceClient, and Dali::Internal::Image::mTicket.

Here is the call graph for this function:

Internal::BufferImagePtr Dali::Internal::NinePatchImage::CreateCroppedBufferImage ( )

Create a cropped image from the bitmap with the 1 pixel border cropped off.

This does not change the internal bitmap.

Returns
the cropped bitmap.

Definition at line 238 of file nine-patch-image-impl.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_ERROR, Dali::Integration::Bitmap::PackedPixelsProfile::GetBufferStride(), Dali::Pixel::GetBytesPerPixel(), mBitmap, Dali::Internal::Image::mHeight, Dali::Internal::Image::mWidth, Dali::Image::NEVER, Dali::Internal::BufferImage::New(), and pixelWidth.

Here is the call graph for this function:

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

Indicates that the image is not used anymore.

Reimplemented from Dali::Internal::ResourceImage.

Definition at line 293 of file nine-patch-image-impl.cpp.

References Dali::Internal::Image::mConnectionCount.

NinePatchImage * Dali::Internal::NinePatchImage::DownCast ( Image image)
static

Convert Image object to a 9 patch image object if possible.

Parameters
[in]imageThe image to convert
Returns
A pointer to the 9 patch image object, or NULL if the conversion is not possible.

Definition at line 202 of file nine-patch-image-impl.cpp.

Rect< int > Dali::Internal::NinePatchImage::GetChildRectangle ( )

Get the child rectangle.

Returns
the position and size of the child rectangle

Definition at line 229 of file nine-patch-image-impl.cpp.

References mChildRectangle, mParsedBorder, and ParseBorders().

Here is the call graph for this function:

const NinePatchImage::StretchRanges & Dali::Internal::NinePatchImage::GetStretchPixelsX ( )

Retrieves the horizontal stretch pixel ranges in the cropped image space.

.4

Returns
the horizontal stretch pixel ranges in the cropped image space

Definition at line 211 of file nine-patch-image-impl.cpp.

References mParsedBorder, mStretchPixelsX, and ParseBorders().

Here is the call graph for this function:

const NinePatchImage::StretchRanges & Dali::Internal::NinePatchImage::GetStretchPixelsY ( )

Retrieves the vertical stretch pixel ranges in the cropped image space.

.4

Returns
the vertical stretch pixel ranges in the cropped image space

Definition at line 220 of file nine-patch-image-impl.cpp.

References mParsedBorder, mStretchPixelsY, and ParseBorders().

Here is the call graph for this function:

bool Dali::Internal::NinePatchImage::IsNinePatchUrl ( const std::string &  url)
static

Definition at line 431 of file nine-patch-image-impl.cpp.

Referenced by Dali::NinePatchImage::IsNinePatchUrl(), and Dali::Internal::ResourceImage::New().

Here is the caller graph for this function:

NinePatchImagePtr Dali::Internal::NinePatchImage::New ( const std::string &  filename,
ReleasePolicy  releasePol = IMAGE_RELEASE_POLICY_DEFAULT 
)
static

Create a new NinePatchImage.

Also a pixel buffer for image data is allocated. Dali has ownership of the buffer.

Parameters
[in]filenameFile to load synchronously into buffer
[in]releasePoloptionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).

Definition at line 169 of file nine-patch-image-impl.cpp.

References NinePatchImage().

Here is the call graph for this function:

void Dali::Internal::NinePatchImage::ParseBorders ( )
private
Uint16Pair Dali::Internal::NinePatchImage::ParseRange ( unsigned int &  index,
unsigned int  width,
const PixelBuffer *&  pixel,
unsigned int  pixelStride,
int  testByte,
int  testBits,
int  testValue 
)
private

Definition at line 402 of file nine-patch-image-impl.cpp.

References width.

Referenced by ParseBorders().

Here is the caller graph for this function:

Member Data Documentation

Integration::BitmapPtr Dali::Internal::NinePatchImage::mBitmap
private
Rect<int> Dali::Internal::NinePatchImage::mChildRectangle
private

Definition at line 147 of file nine-patch-image-impl.h.

Referenced by GetChildRectangle(), and ParseBorders().

bool Dali::Internal::NinePatchImage::mParsedBorder
private
ResourceClient* Dali::Internal::NinePatchImage::mResourceClient
private

Definition at line 143 of file nine-patch-image-impl.h.

Referenced by Connect(), and NinePatchImage().

StretchRanges Dali::Internal::NinePatchImage::mStretchPixelsX
private

Definition at line 145 of file nine-patch-image-impl.h.

Referenced by GetStretchPixelsX(), and ParseBorders().

StretchRanges Dali::Internal::NinePatchImage::mStretchPixelsY
private

Definition at line 146 of file nine-patch-image-impl.h.

Referenced by GetStretchPixelsY(), and ParseBorders().


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