Merge "Added C# control / property registration to devel API" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / resources / resource-client.cpp
index 5961cde..2a0e2cd 100644 (file)
@@ -39,30 +39,23 @@ typedef TicketContainer::iterator                    TicketContainerIter;
 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);
 }
 
@@ -79,11 +72,6 @@ ResourceClient::~ResourceClient()
   delete mImpl;
 }
 
-ResourcePolicy::DataRetention ResourceClient::GetResourceDataRetentionPolicy()
-{
-  return mImpl->mDataRetentionPolicy;
-}
-
 ResourceTicketPtr ResourceClient::RequestResource(
   const ResourceType& type,
   const std::string& path,
@@ -119,7 +107,6 @@ ResourceTicketPtr ResourceClient::RequestResource(
       break;
     }
     case ResourceTargetImage:
-    case ResourceShader:
     {
       newTicket = new ResourceTicket(*this, newId, typePath);
       break;
@@ -157,7 +144,7 @@ ResourceTicketPtr ResourceClient::DecodeResource(
         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;
       }
@@ -165,9 +152,8 @@ ResourceTicketPtr ResourceClient::DecodeResource(
       // 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" );
       }
     }
 
@@ -182,24 +168,6 @@ ResourceTicketPtr ResourceClient::DecodeResource(
   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);
@@ -225,28 +193,6 @@ bool ResourceClient::ReloadResource( ResourceId id, bool resetFinishedStatus, Lo
   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);
@@ -263,28 +209,6 @@ ResourceTicketPtr ResourceClient::RequestResourceTicket( ResourceId 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 );
@@ -302,9 +226,6 @@ ImageTicketPtr ResourceClient::AddBitmapImage(Bitmap* bitmap)
 
   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 );
 
@@ -332,7 +253,7 @@ ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImageInterface& resourc
   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;
 
@@ -348,7 +269,7 @@ ImageTicketPtr ResourceClient::AddFrameBufferImage ( unsigned int width, unsigne
   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;
 }
@@ -426,18 +347,14 @@ void ResourceClient::UploadBitmap( ResourceId destId,Integration::BitmapPtr bitm
                               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 )
@@ -455,9 +372,6 @@ void ResourceClient::ResourceTicketDiscarded(const ResourceTicket& ticket)
   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);
@@ -483,19 +397,6 @@ void ResourceClient::NotifyUploaded( ResourceId id )
   }
 }
 
-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);
@@ -532,30 +433,6 @@ void ResourceClient::NotifyLoadingFailed( ResourceId 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);