typedef TicketContainer::size_type TicketContainerSize;
typedef std::pair<ResourceId, ResourceTicket*> TicketPair;
-typedef std::map<ResourceId, Bitmap*> BitmapCache;
-typedef BitmapCache::iterator BitmapCacheIter;
-
struct ResourceClient::Impl
{
- Impl(ResourcePolicy::DataRetention dataRetentionPolicy)
- : mNextId(0),
- mDataRetentionPolicy( dataRetentionPolicy )
+ Impl()
+ : mNextId(0)
{
}
ResourceId mNextId;
TicketContainer mTickets;
- BitmapCache mBitmaps;
- ResourcePolicy::DataRetention mDataRetentionPolicy;
};
ResourceClient::ResourceClient( ResourceManager& resourceManager,
- EventThreadServices& eventThreadServices,
- ResourcePolicy::DataRetention dataRetentionPolicy)
+ EventThreadServices& eventThreadServices)
: mResourceManager(resourceManager),
mEventThreadServices(eventThreadServices)
{
- mImpl = new ResourceClient::Impl(dataRetentionPolicy);
+ mImpl = new ResourceClient::Impl();
mResourceManager.SetClient(*this);
}
delete mImpl;
}
-ResourcePolicy::DataRetention ResourceClient::GetResourceDataRetentionPolicy()
-{
- return mImpl->mDataRetentionPolicy;
-}
-
ResourceTicketPtr ResourceClient::RequestResource(
const ResourceType& type,
const std::string& path,
break;
}
case ResourceTargetImage:
- case ResourceShader:
{
newTicket = new ResourceTicket(*this, newId, typePath);
break;
const BitmapResourceType& bitmapResource = static_cast <const BitmapResourceType&> ( type );
// Image tickets will cache the requested parameters, which are updated on successful loading
ImageTicket* imageTicket = new ImageTicket( *this, newId, typePath );
- imageTicket->mAttributes.Reset( bitmapResource.size, bitmapResource.scalingMode, bitmapResource.samplingMode, bitmapResource.orientationCorrection );;
+ imageTicket->mAttributes.Reset( bitmapResource.size, bitmapResource.scalingMode, bitmapResource.samplingMode, bitmapResource.orientationCorrection );
newTicket = imageTicket;
break;
}
// FALLTHROUGH:
case ResourceNativeImage:
case ResourceTargetImage:
- case ResourceShader:
{
- DALI_LOG_ERROR( "Unsupported resource type passed for decoding from a memory buffer." );
+ DALI_LOG_ERROR( "Unsupported resource type passed for decoding from a memory buffer.\n" );
}
}
return newTicket;
}
-ResourceTicketPtr ResourceClient::LoadShader( ShaderResourceType& type,
- const std::string& path )
-{
- ResourceTicketPtr newTicket;
-
- const ResourceId newId = ++(mImpl->mNextId);
-
- ResourceTypePath typePath(type, path);
- newTicket = new ResourceTicket(*this, newId, typePath);
-
- mImpl->mTickets.insert(TicketPair(newId, newTicket.Get()));
-
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: LoadShader(path:%s) newId:%u\n", path.c_str(), newId);
-
- RequestLoadShaderMessage( mEventThreadServices, mResourceManager, newId, typePath );
- return newTicket;
-}
-
bool ResourceClient::ReloadResource( ResourceId id, bool resetFinishedStatus, LoadResourcePriority priority )
{
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: ReloadResource(Id: %u)\n", id);
return resourceExists;
}
-void ResourceClient::SaveResource( ResourceTicketPtr ticket, const std::string& url )
-{
- DALI_ASSERT_DEBUG( ticket );
-
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: SaveResource(Id: %u, path:%s)\n", ticket->GetId(), url.c_str());
-
- const ResourceTypePath * const typePathPtr = &ticket->GetTypePath();
- if( typePathPtr )
- {
- if( 0 != url.length() )
- {
- ResourceTypePath typePath( *(typePathPtr->type), url );
- RequestSaveResourceMessage( mEventThreadServices, mResourceManager, ticket->GetId(), typePath );
- }
- else
- {
- ResourceTypePath typePath( *typePathPtr );
- RequestSaveResourceMessage( mEventThreadServices, mResourceManager, ticket->GetId(), typePath );
- }
- }
-}
-
ResourceTicketPtr ResourceClient::RequestResourceTicket( ResourceId id )
{
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: RequestResourceTicket(Id: %u)\n", id);
return ticket;
}
-ImageTicketPtr ResourceClient::AllocateBitmapImage( unsigned int width,
- unsigned int height,
- unsigned int bufferWidth,
- unsigned int bufferHeight,
- Pixel::Format pixelformat )
-{
- /* buffer is available via public-api, therefore not discardable */
- Bitmap* const bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
- Bitmap::PackedPixelsProfile* const packedBitmap = bitmap->GetPackedPixelsProfile();
- DALI_ASSERT_DEBUG(packedBitmap);
-
- packedBitmap->ReserveBuffer(pixelformat, width, height, bufferWidth, bufferHeight);
- DALI_ASSERT_DEBUG(bitmap->GetBuffer() != 0);
- DALI_ASSERT_DEBUG(bitmap->GetBufferSize() >= width * height);
-
- ImageTicketPtr ticket = AddBitmapImage(bitmap);
-
- DALI_ASSERT_DEBUG(bitmap->GetBuffer() != 0);
- DALI_ASSERT_DEBUG(bitmap->GetBufferSize() >= width * height);
- return ticket;
-}
-
ImageTicketPtr ResourceClient::AddBitmapImage(Bitmap* bitmap)
{
DALI_ASSERT_DEBUG( bitmap != NULL );
mImpl->mTickets.insert(TicketPair(newId, newTicket.Get()));
- // Store bitmap for immediate access.
- mImpl->mBitmaps[newId] = bitmap;
-
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: AddBitmapImage() New id = %u\n", newId);
RequestAddBitmapImageMessage( mEventThreadServices, mResourceManager, newId, bitmap );
return newTicket;
}
-ImageTicketPtr ResourceClient::AddFrameBufferImage ( unsigned int width, unsigned int height, Pixel::Format pixelFormat )
+ImageTicketPtr ResourceClient::AddFrameBufferImage ( unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat )
{
ImageTicketPtr newTicket;
mImpl->mTickets.insert(TicketPair(newId, newTicket.Get()));
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: AddFrameBufferImage() New id = %u\n", newId);
- RequestAddFrameBufferImageMessage( mEventThreadServices, mResourceManager, newId, width, height, pixelFormat );
+ RequestAddFrameBufferImageMessage( mEventThreadServices, mResourceManager, newId, width, height, pixelFormat, bufferFormat );
return newTicket;
}
yOffset );
}
-Bitmap* ResourceClient::GetBitmap(ResourceTicketPtr ticket)
+void ResourceClient::UploadBitmap( ResourceId destId, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset)
{
- DALI_ASSERT_DEBUG( ticket );
-
- Bitmap* bitmap = NULL;
- BitmapCacheIter iter = mImpl->mBitmaps.find(ticket->GetId());
-
- if( iter != mImpl->mBitmaps.end() )
- {
- bitmap = iter->second;
- }
- return bitmap;
+ RequestUploadBitmapMessage( mEventThreadServices,
+ mResourceManager,
+ destId,
+ pixelData,
+ xOffset,
+ yOffset );
}
void ResourceClient::CreateGlTexture( ResourceId id )
const ResourceId deadId = ticket.GetId();
const ResourceTypePath& typePath = ticket.GetTypePath();
- // Ensure associated event owned resources are also removed
- mImpl->mBitmaps.erase(ticket.GetId());
-
// The ticket object is dead, remove from tickets container
TicketContainerSize erased = mImpl->mTickets.erase(deadId);
DALI_ASSERT_DEBUG(erased != 0);
}
}
-void ResourceClient::NotifySaveRequested( ResourceId id )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: NotifySaveRequested(id:%u)\n", id);
-
- TicketContainerIter ticketIter = mImpl->mTickets.find(id);
- if(ticketIter != mImpl->mTickets.end())
- {
- ResourceTicket* ticket = ticketIter->second;
- SaveResource( ticket, "" );
- }
-}
-
-
void ResourceClient::NotifyLoading( ResourceId id )
{
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: NotifyLoading(id:%u)\n", id);
}
}
-void ResourceClient::NotifySavingSucceeded( ResourceId id )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: NotifySavingSucceeded(id:%u)\n", id);
-
- TicketContainerIter ticketIter = mImpl->mTickets.find(id);
- if(ticketIter != mImpl->mTickets.end())
- {
- ResourceTicket* ticket = ticketIter->second;
- ticket->SavingSucceeded();
- }
-}
-
-void ResourceClient::NotifySavingFailed( ResourceId id )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: NotifySavingFailed(id:%u)\n", id);
-
- TicketContainerIter ticketIter = mImpl->mTickets.find(id);
- if(ticketIter != mImpl->mTickets.end())
- {
- ResourceTicket* ticket = ticketIter->second;
- ticket->SavingFailed();
- }
-}
-
void ResourceClient::UpdateImageTicket( ResourceId id, const ImageAttributes& imageAttributes ) ///!< Issue #AHC01
{
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: UpdateImageTicket(id:%u)\n", id);