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

ResourceClient is an event side object that manages resource requests. More...

#include <resource-client.h>

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

Classes

struct  Impl
 

Public Types

typedef Rect< unsigned int > RectArea
 rectangular area (x,y,w,h) More...
 

Public Member Functions

 ResourceClient (ResourceManager &resourceManager, EventThreadServices &eventThreadServices)
 Create a resource client. More...
 
virtual ~ResourceClient ()
 Virtual destructor. More...
 
ResourceTicketPtr RequestResource (const Integration::ResourceType &type, const std::string &path, Integration::LoadResourcePriority priority=Integration::LoadPriorityNormal)
 Request a resource from the native filesystem. More...
 
ResourceTicketPtr DecodeResource (const Integration::ResourceType &type, RequestBufferPtr buffer, Integration::LoadResourcePriority priority=Integration::LoadPriorityNormal)
 Request that a resource be decoded in the background from the memory buffer that is passed-in. More...
 
bool ReloadResource (ResourceId id, bool resetFinishedStatus=false, Integration::LoadResourcePriority priority=Integration::LoadPriorityNormal)
 Request reloading a resource from the native filesystem. More...
 
ResourceTicketPtr RequestResourceTicket (ResourceId id)
 Get the ticket for the associated resource ID. More...
 
ImageTicketPtr AddBitmapImage (Integration::Bitmap *bitmap)
 Injects a bitmap resource (does not require loading). More...
 
ResourceTicketPtr AddNativeImage (NativeImageInterface &resourceData)
 Add an existing resource to the resource manager. More...
 
ImageTicketPtr AddFrameBufferImage (unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat)
 Add a framebuffer resource to the resource manager. More...
 
ImageTicketPtr AddFrameBufferImage (NativeImageInterface &nativeImage)
 Add a framebuffer resource to the resource manager. More...
 
ResourceTicketPtr AllocateTexture (unsigned int width, unsigned int height, Pixel::Format pixelformat)
 Request allocation of a texture. More...
 
void UpdateBitmapArea (ResourceTicketPtr ticket, RectArea &updateArea)
 Update bitmap area. More...
 
void UploadBitmap (ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset)
 Upload a bitmap to a texture. More...
 
void UploadBitmap (ResourceId destId, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset)
 Upload a bitmap to a texture. More...
 
void UploadBitmap (ResourceId destId, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset)
 Upload a pixel buffer to a texture. More...
 
void CreateGlTexture (ResourceId id)
 Trigger asynchronous creation of GL texture to back resource immediately. More...
 
virtual void ResourceTicketDiscarded (const ResourceTicket &ticket)
 This indicates that the previously requested resource is no longer needed. More...
 
void NotifyUploaded (ResourceId id)
 Notify associated ticket observers that the resource has been uploaded to GL. More...
 
void NotifyLoading (ResourceId id)
 Notify associated ticket observers that the resource is loading. More...
 
void NotifyLoadingSucceeded (ResourceId id)
 Notify associated ticket observers that the resource has loaded. More...
 
void NotifyLoadingFailed (ResourceId id)
 Notify associated ticket observers that the resource has failed to load. More...
 
void UpdateImageTicket (ResourceId id, const ImageAttributes &imageAttributes)
 Finds ImageTicket which belongs to resource identified by id and updates the cached attributes with a new set which contains the actual width and height of the loaded image but has undefined values for all other fields. More...
 

Private Attributes

ResourceManagermResourceManager
 !< Issue #AHC01 More...
 
EventThreadServicesmEventThreadServices
 Interface to send messages through. More...
 
ImplmImpl
 

Detailed Description

ResourceClient is an event side object that manages resource requests.

It uses ResourceTicket objects to keep track of the lifetime of each request. If the same resource is required by two client objects, they will share the same ResourceTicket i.e. only one load will occur using the native filesystem.

Resources themselves are handled by the Resource Manager in the update thread

Definition at line 66 of file resource-client.h.

Member Typedef Documentation

rectangular area (x,y,w,h)

Definition at line 69 of file resource-client.h.

Constructor & Destructor Documentation

Dali::Internal::ResourceClient::ResourceClient ( ResourceManager resourceManager,
EventThreadServices eventThreadServices 
)

Create a resource client.

There should exactly one of these objects per Dali Core.

Parameters
[in]resourceManagerThe resource manager
[in]eventThreadServicesUsed for messaging to and reading from scene-graph.

Definition at line 53 of file resource-client.cpp.

References mImpl, mResourceManager, and Dali::Internal::ResourceManager::SetClient().

Here is the call graph for this function:

Dali::Internal::ResourceClient::~ResourceClient ( )
virtual

Virtual destructor.

Definition at line 62 of file resource-client.cpp.

References Dali::Internal::Stage::IsInstalled(), mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Here is the call graph for this function:

Member Function Documentation

ImageTicketPtr Dali::Internal::ResourceClient::AddBitmapImage ( Integration::Bitmap bitmap)

Injects a bitmap resource (does not require loading).

Precondition
bitmap has to be initialized
Parameters
[in]bitmapan initialized bitmap
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 212 of file resource-client.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_INFO, Dali::Uint16Pair::FromFloatVec2(), Dali::IntrusivePtr< T >::Get(), Dali::Integration::Bitmap::GetImageHeight(), Dali::Integration::Bitmap::GetImageWidth(), Dali::Internal::ImageAttributes::GetSize(), mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::ImageAttributes::New(), and Dali::Internal::RequestAddBitmapImageMessage().

Referenced by Dali::Internal::NinePatchImage::Connect(), Dali::Internal::BufferImage::CreateHostBitmap(), and Dali::Internal::EncodedBufferImage::New().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageTicketPtr Dali::Internal::ResourceClient::AddFrameBufferImage ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelFormat,
RenderBuffer::Format  bufferFormat 
)

Add a framebuffer resource to the resource manager.

Parameters
[in]widthwidth in pixels
[in]heightheight in pixels
[in]pixelFormatPixel format
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 256 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::ImageAttributes::New(), and Dali::Internal::RequestAddFrameBufferImageMessage().

Referenced by Dali::Internal::FrameBufferImage::Connect().

Here is the call graph for this function:

Here is the caller graph for this function:

ImageTicketPtr Dali::Internal::ResourceClient::AddFrameBufferImage ( NativeImageInterface nativeImage)

Add a framebuffer resource to the resource manager.

Parameters
[in]nativeImagethe NativeImage object
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 277 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), Dali::NativeImageInterface::GetHeight(), Dali::NativeImageInterface::GetWidth(), mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::ImageAttributes::New(), and Dali::Internal::RequestAddFrameBufferImageMessage().

Here is the call graph for this function:

ResourceTicketPtr Dali::Internal::ResourceClient::AddNativeImage ( NativeImageInterface resourceData)

Add an existing resource to the resource manager.

Parameters
[in]resourceDatathe NativeImage object
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 235 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), Dali::NativeImageInterface::GetHeight(), Dali::NativeImageInterface::GetWidth(), mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::ImageAttributes::New(), and Dali::Internal::RequestAddNativeImageMessage().

Referenced by Dali::Internal::NativeImage::New().

Here is the call graph for this function:

Here is the caller graph for this function:

ResourceTicketPtr Dali::Internal::ResourceClient::AllocateTexture ( unsigned int  width,
unsigned int  height,
Pixel::Format  pixelformat 
)

Request allocation of a texture.

The texture is initially empty.

Note
Older hardware may require image width and image height to be a power of two
Parameters
[in]widthImage width in pixels
[in]heightImage height in pixels
[in]pixelformatPixel format
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 299 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::ImageAttributes::New(), and Dali::Internal::RequestAllocateTextureMessage().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::CreateGlTexture ( ResourceId  id)

Trigger asynchronous creation of GL texture to back resource immediately.

Parameters
[in]idThe resource ID to allocate a GL texture for.

Definition at line 360 of file resource-client.cpp.

References mEventThreadServices, mResourceManager, and Dali::Internal::RequestCreateGlTextureMessage().

Referenced by Dali::Internal::NativeImage::CreateGlTexture().

Here is the call graph for this function:

Here is the caller graph for this function:

ResourceTicketPtr Dali::Internal::ResourceClient::DecodeResource ( const Integration::ResourceType type,
RequestBufferPtr  buffer,
Integration::LoadResourcePriority  priority = Integration::LoadPriorityNormal 
)

Request that a resource be decoded in the background from the memory buffer that is passed-in.

The data in the memory buffer should be formatted exactly as it would be in a file of a supported resource type.

Adding an observer to the ticket will enable the application to determine when the resource has finished decoding.

Note
Only images are currently supported by this function.
Parameters
[in]typeThe type of resource. Must be BitmapResourceType.
[in]bufferThe raw data of the resource.
[in]priorityThe priority of the request. This is ignored if the resource is already being loaded.
Returns
A ref-counted request object on success or a null pointer on failure. Keep a copy until the resource is no longer required.

Definition at line 124 of file resource-client.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_ERROR, DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), Dali::Integration::ResourceType::id, mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Integration::BitmapResourceType::orientationCorrection, Dali::Internal::RequestDecodeResourceMessage(), Dali::Integration::ResourceBitmap, Dali::Integration::ResourceNativeImage, Dali::Integration::ResourceTargetImage, Dali::Integration::BitmapResourceType::samplingMode, Dali::Integration::BitmapResourceType::scalingMode, and Dali::Integration::BitmapResourceType::size.

Here is the call graph for this function:

void Dali::Internal::ResourceClient::NotifyLoading ( ResourceId  id)

Notify associated ticket observers that the resource is loading.

Parameters
[in]idThe resource id of the loading resource

Definition at line 400 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::Internal::ResourceTicket::Loading(), mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Referenced by Dali::Internal::LoadingMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::NotifyLoadingFailed ( ResourceId  id)

Notify associated ticket observers that the resource has failed to load.

Parameters
[in]idThe resource id of the resource

Definition at line 424 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::Internal::ResourceTicket::LoadingFailed(), mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Referenced by Dali::Internal::LoadingFailedMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::NotifyLoadingSucceeded ( ResourceId  id)

Notify associated ticket observers that the resource has loaded.

Parameters
[in]idThe resource id of the loaded resource

Definition at line 412 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::Internal::ResourceTicket::LoadingSucceeded(), mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Referenced by Dali::Internal::LoadingSucceededMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::NotifyUploaded ( ResourceId  id)

Notify associated ticket observers that the resource has been uploaded to GL.

Parameters
[in]idThe resource id of the uploaded resource

Definition at line 388 of file resource-client.cpp.

References DALI_LOG_INFO, mImpl, Dali::Internal::ResourceClient::Impl::mTickets, and Dali::Internal::ResourceTicket::Uploaded().

Referenced by Dali::Internal::UploadedMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::ResourceClient::ReloadResource ( ResourceId  id,
bool  resetFinishedStatus = false,
Integration::LoadResourcePriority  priority = Integration::LoadPriorityNormal 
)

Request reloading a resource from the native filesystem.

If the resource is still loading, this request is ignored. The ticket observer will be notified of completion with ResourceLoadingSucceeded() or ResourceLoadingFailed()

Parameters
[in]idresource id
[in]resetFinishedStatusTrue if the finished status of the current image should be reset.
[in]priorityThe priority of the request. This is ignored if the resource is already being refreshed.
Returns
true if successful, false if resource doesn't exist

Definition at line 171 of file resource-client.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_ERROR, DALI_LOG_INFO, Dali::Internal::ResourceTicket::GetTypePath(), mEventThreadServices, mImpl, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, and Dali::Internal::RequestReloadResourceMessage().

Referenced by Dali::Internal::ImageFactory::RecoverFromContextLoss(), and Dali::Internal::ImageFactory::Reload().

Here is the call graph for this function:

Here is the caller graph for this function:

ResourceTicketPtr Dali::Internal::ResourceClient::RequestResource ( const Integration::ResourceType type,
const std::string &  path,
Integration::LoadResourcePriority  priority = Integration::LoadPriorityNormal 
)

Request a resource from the native filesystem.

Adding an observer to the ticket will enable the application to determine when the resource has finished loading.

Parameters
[in]typeThe type of requested resource.
[in]pathThe path to the requested resource.
[in]priorityThe priority of the request. This is ignored if the resource is already being loaded.
Returns
A ref-counted request object. Keep a copy until the resource is no longer required.

Definition at line 75 of file resource-client.cpp.

References DALI_LOG_INFO, Dali::IntrusivePtr< T >::Get(), Dali::Uint16Pair::GetHeight(), Dali::Uint16Pair::GetWidth(), Dali::Integration::ResourceType::id, Dali::Integration::NativeImageResourceType::imageDimensions, mEventThreadServices, mImpl, Dali::Internal::ResourceClient::Impl::mNextId, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Integration::BitmapResourceType::orientationCorrection, Dali::Internal::RequestLoadResourceMessage(), Dali::Integration::ResourceBitmap, Dali::Integration::ResourceNativeImage, Dali::Integration::ResourceTargetImage, Dali::Integration::BitmapResourceType::samplingMode, Dali::Integration::BitmapResourceType::scalingMode, and Dali::Integration::BitmapResourceType::size.

Referenced by Dali::Internal::ImageFactory::IssueLoadRequest().

Here is the call graph for this function:

Here is the caller graph for this function:

ResourceTicketPtr Dali::Internal::ResourceClient::RequestResourceTicket ( ResourceId  id)

Get the ticket for the associated resource ID.

If no ticket can be found for this resource, then this returns NULL to indicate the resource doesn't exist.

Parameters
[in]idThe resource ID.
Returns
A resource ticket, or NULL if no resource existed with the given ID.

Definition at line 196 of file resource-client.cpp.

References DALI_LOG_INFO, mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Referenced by Dali::Internal::ImageFactory::FindCompatibleResource(), Dali::Internal::ImageFactory::Load(), Dali::Internal::ImageFactory::RecoverFromContextLoss(), and Dali::Internal::ImageFactory::Reload().

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::ResourceTicketDiscarded ( const ResourceTicket ticket)
virtual

This indicates that the previously requested resource is no longer needed.

Parameters
[in]ticketThe ticket to remove from resource manager.

Implements Dali::Internal::ResourceTicketLifetimeObserver.

Definition at line 370 of file resource-client.cpp.

References DALI_ASSERT_DEBUG, DALI_LOG_INFO, Dali::Internal::ResourceTicket::GetId(), Dali::Internal::ResourceTicket::GetTypePath(), Dali::Integration::ResourceType::id, mEventThreadServices, mImpl, mResourceManager, Dali::Internal::ResourceClient::Impl::mTickets, Dali::Internal::RequestDiscardResourceMessage(), and Dali::Internal::ResourceTypePath::type.

Here is the call graph for this function:

void Dali::Internal::ResourceClient::UpdateBitmapArea ( ResourceTicketPtr  ticket,
RectArea updateArea 
)

Update bitmap area.

Parameters
[in]ticketThe ticket representing the bitmap
[in]updateAreathe area updated.

Definition at line 322 of file resource-client.cpp.

References DALI_ASSERT_DEBUG, mEventThreadServices, mResourceManager, and Dali::Internal::RequestUpdateBitmapAreaMessage().

Here is the call graph for this function:

void Dali::Internal::ResourceClient::UpdateImageTicket ( ResourceId  id,
const ImageAttributes imageAttributes 
)

Finds ImageTicket which belongs to resource identified by id and updates the cached attributes with a new set which contains the actual width and height of the loaded image but has undefined values for all other fields.

!< Issue #AHC01

Parameters
idThe resource id to find the ticket of
imageAttributesThe image attributes to assign to the ticket

Definition at line 436 of file resource-client.cpp.

References DALI_LOG_INFO, mImpl, and Dali::Internal::ResourceClient::Impl::mTickets.

Referenced by Dali::Internal::UpdateImageTicketMessage().

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::UploadBitmap ( ResourceId  destId,
ResourceId  srcId,
std::size_t  xOffset,
std::size_t  yOffset 
)

Upload a bitmap to a texture.

Parameters
[in]destIdThe destination texture ID
[in]srcIdThe resource ID of the bitmap to upload
[in]xOffsetSpecifies an offset in the x direction within the texture
[in]yOffsetSpecifies an offset in the y direction within the texture

Definition at line 329 of file resource-client.cpp.

References mEventThreadServices, mResourceManager, and Dali::Internal::RequestUploadBitmapMessage().

Referenced by Dali::Internal::Atlas::RecoverFromContextLoss(), Dali::Internal::Atlas::Upload(), and Dali::Internal::BufferImage::UploadArea().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::ResourceClient::UploadBitmap ( ResourceId  destId,
Integration::BitmapPtr  bitmap,
std::size_t  xOffset,
std::size_t  yOffset 
)

Upload a bitmap to a texture.

Parameters
[in]destIdThe destination texture ID
[in]bitmapThe pointer pointing to the bitmap to upload
[in]xOffsetSpecifies an offset in the x direction within the texture
[in]yOffsetSpecifies an offset in the y direction within the texture

Definition at line 340 of file resource-client.cpp.

References mEventThreadServices, mResourceManager, and Dali::Internal::RequestUploadBitmapMessage().

Here is the call graph for this function:

void Dali::Internal::ResourceClient::UploadBitmap ( ResourceId  destId,
PixelDataPtr  pixelData,
std::size_t  xOffset,
std::size_t  yOffset 
)

Upload a pixel buffer to a texture.

Parameters
[in]destIdThe destination texture ID
[in]bitmapThe pointer pointing to the pixel data
[in]xOffsetSpecifies an offset in the x direction within the texture
[in]yOffsetSpecifies an offset in the y direction within the texture

Definition at line 350 of file resource-client.cpp.

References mEventThreadServices, mResourceManager, and Dali::Internal::RequestUploadBitmapMessage().

Here is the call graph for this function:

Member Data Documentation

EventThreadServices& Dali::Internal::ResourceClient::mEventThreadServices
private
Impl* Dali::Internal::ResourceClient::mImpl
private
ResourceManager& Dali::Internal::ResourceClient::mResourceManager
private

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