Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-core.git] / dali / internal / update / resources / resource-manager.h
index 612f13a..d35473d 100644 (file)
@@ -32,8 +32,8 @@
 #include <dali/integration-api/resource-cache.h>
 #include <dali/integration-api/shader-data.h>
 
-#include <dali/internal/common/event-to-update.h>
 #include <dali/internal/common/message.h>
+#include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/internal/event/resources/resource-client-declarations.h>
 #include <dali/internal/event/effects/shader-factory.h>
@@ -260,6 +260,15 @@ public: // Used by ResourceClient
   /**
    * Upload a bitmap to a position within a specified texture
    * @param[in] destId The destination texture ID
+   * @param[in] bitmap The pointer pointing to the bitmap data to upload
+   * @param [in] xOffset Specifies an offset in the x direction within the texture
+   * @param [in] yOffset Specifies an offset in the y direction within the texture
+   */
+  void HandleUploadBitmapRequest( ResourceId destId, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset );
+
+  /**
+   * Upload a bitmap to a position within a specified texture
+   * @param[in] destId The destination texture ID
    * @param[in] srcId The resource ID of the bitmap to upload
    * @param [in] xOffset Specifies an offset in the x direction within the texture
    * @param [in] yOffset Specifies an offset in the y direction within the texture
@@ -362,7 +371,6 @@ public:
   /********************************************************************************
    ********************************* Private Methods  *****************************
    ********************************************************************************/
-private:
 
   /**
    * Sends notification messages for load sucess & failure,
@@ -400,7 +408,7 @@ private:
 // picked-up by the update thread in its main loop and executed on that in
 // submission order.
 
-inline void RequestLoadResourceMessage( EventToUpdate& eventToUpdate,
+inline void RequestLoadResourceMessage( EventThreadServices& eventThreadServices,
                                         ResourceManager& manager,
                                         ResourceId id,
                                         const ResourceTypePath& typePath,
@@ -409,13 +417,13 @@ inline void RequestLoadResourceMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue3< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleLoadResourceRequest, id, typePath, priority );
 }
 
-inline void RequestDecodeResourceMessage( EventToUpdate& eventToUpdate,
+inline void RequestDecodeResourceMessage( EventThreadServices& eventThreadServices,
                                           ResourceManager& manager,
                                           const ResourceId id,
                                           /// We use typePath instead of the raw type for ownership and to enable copying of a concrete type.
@@ -426,13 +434,13 @@ inline void RequestDecodeResourceMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, RequestBufferPtr, Integration::LoadResourcePriority > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleDecodeResourceRequest, id, typePath, buffer, priority );
 }
 
-inline void RequestAddBitmapImageMessage( EventToUpdate& eventToUpdate,
+inline void RequestAddBitmapImageMessage( EventThreadServices& eventThreadServices,
                                           ResourceManager& manager,
                                           ResourceId id,
                                           Integration::Bitmap* resourceData )
@@ -440,13 +448,13 @@ inline void RequestAddBitmapImageMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, Integration::BitmapPtr > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAddBitmapImageRequest, id, resourceData );
 }
 
-inline void RequestAddNativeImageMessage( EventToUpdate& eventToUpdate,
+inline void RequestAddNativeImageMessage( EventThreadServices& eventThreadServices,
                                           ResourceManager& manager,
                                           ResourceId id,
                                           NativeImageInterfacePtr resourceData )
@@ -454,13 +462,13 @@ inline void RequestAddNativeImageMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAddNativeImageRequest, id, resourceData );
 }
 
-inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
+inline void RequestAddFrameBufferImageMessage( EventThreadServices& eventThreadServices,
                                                ResourceManager& manager,
                                                ResourceId id,
                                                unsigned int width,
@@ -470,13 +478,13 @@ inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, width, height, pixelFormat );
 }
 
-inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
+inline void RequestAddFrameBufferImageMessage( EventThreadServices& eventThreadServices,
                                                ResourceManager& manager,
                                                ResourceId id,
                                                NativeImageInterfacePtr resourceData )
@@ -484,29 +492,29 @@ inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, resourceData );
 }
 
-inline void RequestAllocateTextureMessage(EventToUpdate& eventToUpdate,
-                                               ResourceManager& manager,
-                                               ResourceId id,
-                                               unsigned int width,
-                                               unsigned int height,
-                                               Pixel::Format pixelFormat)
+inline void RequestAllocateTextureMessage( EventThreadServices& eventThreadServices,
+                                           ResourceManager& manager,
+                                           ResourceId id,
+                                           unsigned int width,
+                                           unsigned int height,
+                                           Pixel::Format pixelFormat)
 {
   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateTextureRequest, id, width, height, pixelFormat );
 }
 
-inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate,
+inline void RequestAllocateMeshMessage( EventThreadServices& eventThreadServices,
                                         ResourceManager& manager,
                                         ResourceId id,
                                         OwnerPointer<MeshData>& meshData )
@@ -514,13 +522,13 @@ inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, OwnerPointer<MeshData> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateMeshRequest, id, meshData.Release() );
 }
 
-inline void RequestLoadShaderMessage( EventToUpdate& eventToUpdate,
+inline void RequestLoadShaderMessage( EventThreadServices& eventThreadServices,
                                       ResourceManager& manager,
                                       ResourceId id,
                                       const ResourceTypePath& typePath )
@@ -528,13 +536,13 @@ inline void RequestLoadShaderMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleLoadShaderRequest, id, typePath );
 }
 
-inline void RequestUpdateBitmapAreaMessage( EventToUpdate& eventToUpdate,
+inline void RequestUpdateBitmapAreaMessage( EventThreadServices& eventThreadServices,
                                             ResourceManager& manager,
                                             ResourceId id,
                                             const Dali::RectArea& area )
@@ -542,13 +550,29 @@ inline void RequestUpdateBitmapAreaMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, Dali::RectArea > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateBitmapAreaRequest, id, area );
 }
 
-inline void RequestUploadBitmapMessage( EventToUpdate& eventToUpdate,
+inline void RequestUploadBitmapMessage( EventThreadServices& eventThreadServices,
+                                        ResourceManager& manager,
+                                        ResourceId destId,
+                                        Integration::BitmapPtr bitmap,
+                                        std::size_t xOffset,
+                                        std::size_t yOffset )
+{
+  typedef MessageValue4< ResourceManager, ResourceId, Integration::BitmapPtr , std::size_t, std::size_t > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, bitmap, xOffset, yOffset );
+}
+
+inline void RequestUploadBitmapMessage( EventThreadServices& eventThreadServices,
                                         ResourceManager& manager,
                                         ResourceId destId,
                                         ResourceId srcId,
@@ -558,13 +582,13 @@ inline void RequestUploadBitmapMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue4< ResourceManager, ResourceId, ResourceId, std::size_t, std::size_t > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, srcId, xOffset, yOffset );
 }
 
-inline void RequestUpdateMeshMessage( EventToUpdate& eventToUpdate,
+inline void RequestUpdateMeshMessage( EventThreadServices& eventThreadServices,
                                       ResourceManager& manager,
                                       ResourceId id,
                                       const Dali::MeshData& meshData,
@@ -572,7 +596,7 @@ inline void RequestUpdateMeshMessage( EventToUpdate& eventToUpdate,
 {
   typedef MessageDoubleBuffered2< ResourceManager, ResourceId, OwnerPointer< MeshData > > LocalType;
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   MeshData* internalMeshData = new MeshData( meshData, discardable, false );
 
@@ -580,7 +604,7 @@ inline void RequestUpdateMeshMessage( EventToUpdate& eventToUpdate,
   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateMeshRequest, id, internalMeshData );
 }
 
-inline void RequestReloadResourceMessage( EventToUpdate& eventToUpdate,
+inline void RequestReloadResourceMessage( EventThreadServices& eventThreadServices,
                                           ResourceManager& manager,
                                           ResourceId id,
                                           const ResourceTypePath& typePath,
@@ -590,13 +614,13 @@ inline void RequestReloadResourceMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority, bool > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleReloadResourceRequest, id, typePath, priority, resetFinishedStatus );
 }
 
-inline void RequestSaveResourceMessage( EventToUpdate& eventToUpdate,
+inline void RequestSaveResourceMessage( EventThreadServices& eventThreadServices,
                                         ResourceManager& manager,
                                         ResourceId id,
                                         const ResourceTypePath& typePath )
@@ -604,13 +628,13 @@ inline void RequestSaveResourceMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleSaveResourceRequest, id, typePath );
 }
 
-inline void RequestDiscardResourceMessage( EventToUpdate& eventToUpdate,
+inline void RequestDiscardResourceMessage( EventThreadServices& eventThreadServices,
                                            ResourceManager& manager,
                                            ResourceId id,
                                            Integration::ResourceTypeId typeId )
@@ -618,7 +642,7 @@ inline void RequestDiscardResourceMessage( EventToUpdate& eventToUpdate,
   typedef MessageValue2< ResourceManager, ResourceId, Integration::ResourceTypeId > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &manager, &ResourceManager::HandleDiscardResourceRequest, id, typeId );