Removed Meshes and Model loading
[platform/core/uifw/dali-core.git] / dali / internal / update / resources / resource-manager.h
1 #ifndef __DALI_INTERNAL_RESOURCE_MANAGER_H__
2 #define __DALI_INTERNAL_RESOURCE_MANAGER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/image.h>
26 #include <dali/public-api/images/native-image-interface.h>
27 #include <dali/public-api/images/buffer-image.h>
28 #include <dali/public-api/common/ref-counted-dali-vector.h>
29
30 #include <dali/integration-api/bitmap.h>
31 #include <dali/integration-api/platform-abstraction.h>
32 #include <dali/integration-api/resource-cache.h>
33 #include <dali/integration-api/shader-data.h>
34
35 #include <dali/internal/common/event-to-update.h>
36 #include <dali/internal/common/message.h>
37 #include <dali/internal/event/common/thread-local-storage.h>
38 #include <dali/internal/common/bitmap-upload.h>
39 #include <dali/internal/event/text/font-impl.h>
40 #include <dali/internal/event/resources/resource-client-declarations.h>
41 #include <dali/internal/event/effects/shader-factory.h>
42 #include <dali/internal/update/resources/resource-manager-declarations.h>
43 #include <dali/internal/update/resources/bitmap-metadata.h>
44
45 namespace Dali
46 {
47
48 class NativeImageInterface;
49
50 namespace Integration
51 {
52 struct ResourceType;
53 }
54
55 namespace Internal
56 {
57
58 // value types used by messages
59 template <> struct ParameterType< Integration::LoadResourcePriority >
60 : public BasicType< Integration::LoadResourcePriority > {};
61 template <> struct ParameterType< Pixel::Format >
62 : public BasicType< Pixel::Format > {};
63 template <> struct ParameterType< Integration::ResourceTypeId >
64 : public BasicType< Integration::ResourceTypeId > {};
65
66 namespace SceneGraph
67 {
68 class DiscardQueue;
69 class RenderQueue;
70 class TextureCacheDispatcher;
71 class PostProcessResourceDispatcher;
72 }
73
74 class NotificationManager;
75
76 /** Raw bytes of a resource laid out exactly as it wouldbe in a file, but in memory. */
77 typedef Dali::RefCountedVector<uint8_t> RequestBuffer;
78 /** Counting smart pointer for managing a buffer of raw bytes. */
79 typedef IntrusivePtr<RequestBuffer> RequestBufferPtr;
80
81 /**
82  * ResourceManager keeps track of resource loading requests, and caches resources that are loaded.
83  * It uses ResourceTicket objects, to keep track of the lifetime of each request.
84  * If the same resource is required by two client objects, they will share the same ResourceTicket
85  * i.e. only one load will occur using the native filesystem.
86  *
87  * Multi-threading notes:
88  * Resources are received from the PlatformAbstraction API during the Core::Render() method, which
89  * may be called from a dedicated rendering thread.
90  * Loading requests must be made from the application's main thread e.g. when Dali::Image is created.
91  */
92 class ResourceManager : public Integration::ResourceCache
93 {
94 public:
95
96   /**
97    * Create a resource manager.
98    * There should exactly one of these objects per Dali Core.
99    * @param[in] platformAbstraction Used to request resources from the native filesystem.
100    * @param[in] notificationManager Used to send NotifyTickets message.
101    * @param[in] postProcessResourcesQueue Used for performing post processing on resources
102    * @param[in] discardQueue Used to cleanup nodes & resources when no longer in use.
103    * @param[in] renderQueue Used to queue resource updates until the next Render.
104    */
105   ResourceManager( Integration::PlatformAbstraction& platformAbstraction,
106                    NotificationManager& notificationManager,
107                    SceneGraph::TextureCacheDispatcher& textureCacheDispatcher,
108                    ResourcePostProcessList& postProcessResourcesQueue,
109                    SceneGraph::PostProcessResourceDispatcher& postProcessResourceDispatcher,
110                    SceneGraph::DiscardQueue& discardQueue,
111                    SceneGraph::RenderQueue& renderQueue );
112
113   /**
114    * Virtual destructor.
115    */
116   virtual ~ResourceManager();
117
118 public: // Used by ResourceClient
119
120   /********************************************************************************
121    ************************ ResourceClient direct interface  **********************
122    ********************************************************************************/
123
124   /**
125    * Resource client passes itself for secondary intialisation.
126    * (The resource client requires the ResourceManager to be instantiated first).
127    * @param[in] resourceClient The ResourceClient.
128    */
129   void SetClient( ResourceClient& resourceClient );
130
131   /********************************************************************************
132    ************************ UpdateManager direct interface  ***********************
133    ********************************************************************************/
134
135   /**
136    * Called to update the resource cache before rendering.
137    * New resources will be added to the cache using PlatformAbstraction::FillResourceCache().
138    * Unwanted resources will be added to the DiscardQueue.
139    * @param[in] updateBufferIndex The current update buffer index.
140    * @return true, if a resource load was completed or failed
141    */
142   bool UpdateCache( BufferIndex updateBufferIndex );
143
144   /**
145    * Iterate through the post process queue, performing requested updates.
146    * @param[in] updateBufferIndex The current update buffer index.
147    */
148   void PostProcessResources( BufferIndex updateBufferIndex );
149
150   /********************************************************************************
151    *************************** CoreImpl direct interface  *************************
152    ********************************************************************************/
153
154   /**
155    * Returns whether the Resource Manager is still processing any resource requests.
156    * @return true if still processing, false otherwise.
157    */
158   bool ResourcesToProcess();
159
160   /********************************************************************************
161    ********************************* Message handlers *****************************
162    ********************************************************************************/
163
164   /**
165    * Request a resource from the native filesystem.
166    * @param[in] id The Id of the requested resource
167    * @param[in] typePath The type & path of requested resource.
168    * @param[in] priority The priority of the request. This is ignored if the resource is already being loaded.
169    */
170   void HandleLoadResourceRequest( ResourceId id,
171                                   const ResourceTypePath& typePath,
172                                   Integration::LoadResourcePriority priority );
173
174   /**
175    * Decode a resource from a memory buffer with the semantics of loading.
176    * Notifications of partial completion, success, and failure will happen via
177    * the same loading notification path used for loading from files: Update()
178    * will retrieve loading events in its main loop and notify listeners to its
179    * own loading events, and forward them, still as loading events, to the event
180    * thread via its update queue.
181    * Resource manager and lower levels make no attempt to detect resource
182    * aliases as is done for multiple requests to load the same resource
183    * file, so the caller is responsible for ensuring that it only requests
184    * the decoding of an in-memory resource once and for doing the sharing of the
185    * resulting object itself. Ultimately this responsibility resides with the
186    * application.
187    * @note ! Only Bitmap resources are supported for decoding from memory !
188    * @param[in] id The Id of the requested resource.
189    * @param[in] typePath The type of the requested resource and a path that is ignored.
190    * @param[in] buffer The raw encoded bytes of the resource as they would appear in a file.
191    * @param[in] priority The priority of the request. This is ignored if the resource is already being loaded.
192    */
193   void HandleDecodeResourceRequest( ResourceId id,
194                                     const ResourceTypePath& typePath,
195                                     RequestBufferPtr buffer,
196                                     Integration::LoadResourcePriority priority );
197
198   /**
199    * Injects a bitmap resource (does not require loading).
200    * @pre bitmap has to be initialized
201    * @param[in] id The resource id
202    * @param[in] bitmap an initialized bitmap
203    */
204   void HandleAddBitmapImageRequest(ResourceId id, Integration::BitmapPtr bitmap);
205
206   /**
207    * Add an existing resource to the resource manager.
208    * @param[in] id The resource id
209    * @param [in] resourceData the NativeImageInterface object
210    * @return A ref-counted request object. Keep a copy until the resource is no longer required.
211    */
212   void HandleAddNativeImageRequest( ResourceId id, NativeImageInterfacePtr resourceData );
213
214   /**
215    * Add an existing resource to the resource manager.
216    * @param[in] id The resource id
217    * @param[in] width       width in pixels
218    * @param[in] height      height in pixels
219    * @param[in] pixelFormat Pixel format
220    */
221   void HandleAddFrameBufferImageRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
222
223   /**
224    * Add an existing resource to the resource manager.
225    * @param[in] id            The resource id
226    * @param[in] nativeImage   The NativeImage
227    */
228   void HandleAddFrameBufferImageRequest( ResourceId id, NativeImageInterfacePtr nativeImage );
229
230   /**
231    * Allocate a new empty texture.
232    * @param[in] id The resource id
233    * @param[in] width       width in pixels
234    * @param[in] height      height in pixels
235    * @param[in] pixelFormat Pixel format
236    */
237   void HandleAllocateTextureRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
238
239   /**
240    * Upload an array of bitmaps to a texture.
241    * @param[in] id The resource id
242    * @param[in] uploadArray  bitmap upload array.
243    */
244   void HandleUpdateTextureRequest( ResourceId id,  const BitmapUploadArray& uploadArray );
245
246   /**
247    * Requests allocation of a font resource
248    */
249   void HandleAllocateFontRequest(ResourceId id, const std::string& familyNameAndStyle);
250
251   /**
252    * Load a shader program from a file
253    * @param[in] id The resource id
254    * @param[in] typePath The type & path of the resource
255    */
256   void HandleLoadShaderRequest(ResourceId id, const ResourceTypePath& typePath );
257
258   /**
259    * Update bitmap area request
260    * @param[in] textureId The resource ID of a bitmap-texture to remove.
261    * @param[in] area The updated area. Zero width/height indicates the whole bitmap has been updated
262    */
263   void HandleUpdateBitmapAreaRequest( ResourceId textureId, const Dali::RectArea& area );
264
265   /**
266    * Upload a bitmap to a position within a specified texture
267    * @param[in] destId The destination texture ID
268    * @param[in] srcId The resource ID of the bitmap to upload
269    * @param [in] xOffset Specifies an offset in the x direction within the texture
270    * @param [in] yOffset Specifies an offset in the y direction within the texture
271    */
272   void HandleUploadBitmapRequest( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
273
274   /**
275    * Request reloading a resource from the native filesystem.
276    * @param[in] id The resource id
277    * @param[in] typePath The type & path of the resource
278    * @param[in] priority The priority of the request. This is ignored if the resource is already being refreshed.
279    * @param[in] resetFinishedStatus True if the finished status of the resource id should be reset
280    */
281   void HandleReloadResourceRequest( ResourceId id, const ResourceTypePath& typePath, Integration::LoadResourcePriority priority, bool resetFinishedStatus );
282
283   /**
284    * Save a resource to the given url
285    * @param[in] id       The resource id
286    * @param[in] typePath The type & path of the resource
287    */
288   void HandleSaveResourceRequest( ResourceId id, const ResourceTypePath& typePath );
289
290   /**
291    * Resource ticket has been discarded, throw away the actual resource
292    */
293   void HandleDiscardResourceRequest( ResourceId id, Integration::ResourceTypeId typeId );
294
295   /**
296    * Update font texture atlas status
297    * @param[in] id         The resource id
298    * @param[in] atlasId    texture ID of the atlas
299    * @param[in] loadStatus The status update.
300    */
301   void HandleAtlasUpdateRequest( ResourceId id, ResourceId atlasId, Integration::LoadStatus loadStatus );
302
303   /********************************************************************************
304    ******************** Update thread object direct interface  ********************
305    ********************************************************************************/
306
307   /**
308    * Check if a resource has completed loading.
309    * @param[in] id The ID of a bitmap/texture resource.
310    * @return true if the bitmap or texture has finished loading
311    */
312   bool IsResourceLoaded(ResourceId id);
313
314   /**
315    * Check if a resource has failed to load, e.g. file not found, etc.
316    * @param[in] id The ID of a bitmap/texture resource.
317    * @return true if the bitmap or texture has failed to load
318    */
319   bool IsResourceLoadFailed(ResourceId id);
320
321   /**
322    * Get bitmap metadata. This stores meta data about the resource, but
323    * doesn't keep track of the resource
324    */
325   BitmapMetadata GetBitmapMetadata(ResourceId id);
326
327   /**
328    * Returns the shader resource corresponding to the Id
329    * @param[in] id - the id of a shader binary resource.
330    * @return the shader binary resource data or NULL if it has not been loaded.
331    */
332   Integration::ShaderDataPtr GetShaderData(ResourceId id);
333
334   /**
335    * Check if current set of glyph requests on given atlas have finished loading
336    * @param[in] id Request Id of the text atlas texture
337    * @return true if the current set of glyph requests have all completed, false
338    * if there are outstanding glyph requests that haven't finished.
339    */
340   bool IsAtlasLoaded(ResourceId id);
341
342   /**
343    * Check the load status of a given atlas.
344    * @param[in] id Request Id of the text atlas texture
345    * @return LoadStatus
346    */
347   Integration::LoadStatus GetAtlasLoadStatus( ResourceId atlasId );
348
349   /********************************************************************************
350    ************************* ResourceCache Implementation  ************************
351    ********************************************************************************/
352 public:
353
354   /**
355    * @copydoc Integration::ResourceCache::LoadResponse
356    */
357   virtual void LoadResponse(ResourceId id, Integration::ResourceTypeId type, Integration::ResourcePointer resource, Integration::LoadStatus loadStatus);
358
359   /**
360    * @copydoc Integration::ResourceCache::SaveComplete
361    */
362   virtual void SaveComplete(ResourceId id, Integration::ResourceTypeId type);
363
364   /**
365    * @copydoc Integration::ResourceCache::LoadFailed
366    */
367   virtual void LoadFailed(ResourceId id, Integration::ResourceFailure failure);
368
369   /**
370    * @copydoc Integration::ResourceCache::SaveFailed
371    */
372   virtual void SaveFailed(ResourceId id, Integration::ResourceFailure failure);
373
374   /********************************************************************************
375    ********************************* Private Methods  *****************************
376    ********************************************************************************/
377 private:
378   /**
379    * @param[in] id Resource id to clear
380    * @param[in] typePath Glyphs to be loaded, and cleared beforehand
381    */
382   void ClearRequestedGlyphArea( ResourceId id, const ResourceTypePath& typePath );
383
384   /**
385    * Sends loaded glyphs to texture atlas for uploading
386    * @param[in] glyphSet Loaded glyphs
387    */
388   void UploadGlyphsToTexture( const Integration::GlyphSet& glyphSet );
389
390   /**
391    * Sends notification messages for load sucess & failure,
392    * pushes from newComplete / newFailed into oldComplete / oldFailed respectively
393    */
394   void NotifyTickets();
395
396   /**
397    * Triggers message to Event thread to update the ticket's image attributes
398    * @pre An Image resource with the given id should exist in the cache.
399    * @param id ID of the image resource
400    * @param attributes Resource image attributes
401    */
402   void UpdateImageTicket( ResourceId id, ImageAttributes& attributes );
403
404   /**
405    * Send message to ResourceClient in event thread
406    * @param[in] message The message to send
407    */
408   void SendToClient( MessageBase* message );
409
410   /**
411    * Discard all dead resources.
412    * @param[in] updateBufferIndex The current update buffer index.
413    */
414   void DiscardDeadResources( BufferIndex updateBufferIndex );
415
416 private:
417   struct ResourceManagerImpl;
418   ResourceManagerImpl* mImpl;
419 };
420
421 // Messages sent to resource manager from other threads:
422 // These functions are run on other threads and insert messages to be
423 // picked-up by the update thread in its main loop and executed on that in
424 // submission order.
425
426 inline void RequestLoadResourceMessage( EventToUpdate& eventToUpdate,
427                                         ResourceManager& manager,
428                                         ResourceId id,
429                                         const ResourceTypePath& typePath,
430                                         Integration::LoadResourcePriority priority )
431 {
432   typedef MessageValue3< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority > LocalType;
433
434   // Reserve some memory inside the message queue
435   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
436
437   // Construct message in the message queue memory; note that delete should not be called on the return value
438   new (slot) LocalType( &manager, &ResourceManager::HandleLoadResourceRequest, id, typePath, priority );
439 }
440
441 inline void RequestDecodeResourceMessage( EventToUpdate& eventToUpdate,
442                                           ResourceManager& manager,
443                                           const ResourceId id,
444                                           /// We use typePath instead of the raw type for ownership and to enable copying of a concrete type.
445                                           const ResourceTypePath& typePath,
446                                           RequestBufferPtr buffer,
447                                           Integration::LoadResourcePriority priority )
448 {
449   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, RequestBufferPtr, Integration::LoadResourcePriority > LocalType;
450
451   // Reserve some memory inside the message queue
452   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
453
454   // Construct message in the message queue memory; note that delete should not be called on the return value
455   new (slot) LocalType( &manager, &ResourceManager::HandleDecodeResourceRequest, id, typePath, buffer, priority );
456 }
457
458 inline void RequestAddBitmapImageMessage( EventToUpdate& eventToUpdate,
459                                           ResourceManager& manager,
460                                           ResourceId id,
461                                           Integration::Bitmap* resourceData )
462 {
463   typedef MessageValue2< ResourceManager, ResourceId, Integration::BitmapPtr > LocalType;
464
465   // Reserve some memory inside the message queue
466   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
467
468   // Construct message in the message queue memory; note that delete should not be called on the return value
469   new (slot) LocalType( &manager, &ResourceManager::HandleAddBitmapImageRequest, id, resourceData );
470 }
471
472 inline void RequestAddNativeImageMessage( EventToUpdate& eventToUpdate,
473                                           ResourceManager& manager,
474                                           ResourceId id,
475                                           NativeImageInterfacePtr resourceData )
476 {
477   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
478
479   // Reserve some memory inside the message queue
480   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
481
482   // Construct message in the message queue memory; note that delete should not be called on the return value
483   new (slot) LocalType( &manager, &ResourceManager::HandleAddNativeImageRequest, id, resourceData );
484 }
485
486 inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
487                                                ResourceManager& manager,
488                                                ResourceId id,
489                                                unsigned int width,
490                                                unsigned int height,
491                                                Pixel::Format pixelFormat )
492 {
493   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
494
495   // Reserve some memory inside the message queue
496   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
497
498   // Construct message in the message queue memory; note that delete should not be called on the return value
499   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, width, height, pixelFormat );
500 }
501
502 inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
503                                                ResourceManager& manager,
504                                                ResourceId id,
505                                                NativeImageInterfacePtr resourceData )
506 {
507   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
508
509   // Reserve some memory inside the message queue
510   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
511
512   // Construct message in the message queue memory; note that delete should not be called on the return value
513   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, resourceData );
514 }
515
516 inline void RequestAllocateTextureMessage(EventToUpdate& eventToUpdate,
517                                                ResourceManager& manager,
518                                                ResourceId id,
519                                                unsigned int width,
520                                                unsigned int height,
521                                                Pixel::Format pixelFormat)
522 {
523   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
524
525   // Reserve some memory inside the message queue
526   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
527
528   // Construct message in the message queue memory; note that delete should not be called on the return value
529   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateTextureRequest, id, width, height, pixelFormat );
530 }
531
532 inline void RequestUpdateTextureMessage(EventToUpdate& eventToUpdate,
533                                                ResourceManager& manager,
534                                                ResourceId id,
535                                                BitmapUploadArray uploadArray )
536 {
537   typedef MessageValue2< ResourceManager, ResourceId, BitmapUploadArray > LocalType;
538
539   // Reserve some memory inside the message queue
540   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
541
542   // Construct message in the message queue memory; note that delete should not be called on the return value
543   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateTextureRequest, id, uploadArray );
544 }
545
546 inline void RequestAllocateFontMessage( EventToUpdate& eventToUpdate,
547                                         ResourceManager& manager,
548                                         ResourceId id,
549                                         const std::string& familyNameAndStyle)
550 {
551   typedef MessageValue2< ResourceManager, ResourceId, std::string > LocalType;
552
553   // Reserve some memory inside the message queue
554   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
555
556   // Construct message in the message queue memory; note that delete should not be called on the return value
557   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateFontRequest, id, familyNameAndStyle );
558 }
559
560 inline void RequestLoadShaderMessage( EventToUpdate& eventToUpdate,
561                                       ResourceManager& manager,
562                                       ResourceId id,
563                                       const ResourceTypePath& typePath )
564 {
565   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
566
567   // Reserve some memory inside the message queue
568   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
569
570   // Construct message in the message queue memory; note that delete should not be called on the return value
571   new (slot) LocalType( &manager, &ResourceManager::HandleLoadShaderRequest, id, typePath );
572 }
573
574 inline void RequestUpdateBitmapAreaMessage( EventToUpdate& eventToUpdate,
575                                             ResourceManager& manager,
576                                             ResourceId id,
577                                             const Dali::RectArea& area )
578 {
579   typedef MessageValue2< ResourceManager, ResourceId, Dali::RectArea > LocalType;
580
581   // Reserve some memory inside the message queue
582   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
583
584   // Construct message in the message queue memory; note that delete should not be called on the return value
585   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateBitmapAreaRequest, id, area );
586 }
587
588 inline void RequestUploadBitmapMessage( EventToUpdate& eventToUpdate,
589                                         ResourceManager& manager,
590                                         ResourceId destId,
591                                         ResourceId srcId,
592                                         std::size_t xOffset,
593                                         std::size_t yOffset )
594 {
595   typedef MessageValue4< ResourceManager, ResourceId, ResourceId, std::size_t, std::size_t > LocalType;
596
597   // Reserve some memory inside the message queue
598   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
599
600   // Construct message in the message queue memory; note that delete should not be called on the return value
601   new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, srcId, xOffset, yOffset );
602 }
603
604 inline void RequestReloadResourceMessage( EventToUpdate& eventToUpdate,
605                                           ResourceManager& manager,
606                                           ResourceId id,
607                                           const ResourceTypePath& typePath,
608                                           Integration::LoadResourcePriority priority,
609                                           bool resetFinishedStatus )
610 {
611   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority, bool > LocalType;
612
613   // Reserve some memory inside the message queue
614   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
615
616   // Construct message in the message queue memory; note that delete should not be called on the return value
617   new (slot) LocalType( &manager, &ResourceManager::HandleReloadResourceRequest, id, typePath, priority, resetFinishedStatus );
618 }
619
620 inline void RequestSaveResourceMessage( EventToUpdate& eventToUpdate,
621                                         ResourceManager& manager,
622                                         ResourceId id,
623                                         const ResourceTypePath& typePath )
624 {
625   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
626
627   // Reserve some memory inside the message queue
628   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
629
630   // Construct message in the message queue memory; note that delete should not be called on the return value
631   new (slot) LocalType( &manager, &ResourceManager::HandleSaveResourceRequest, id, typePath );
632 }
633
634 inline void RequestDiscardResourceMessage( EventToUpdate& eventToUpdate,
635                                            ResourceManager& manager,
636                                            ResourceId id,
637                                            Integration::ResourceTypeId typeId )
638 {
639   typedef MessageValue2< ResourceManager, ResourceId, Integration::ResourceTypeId > LocalType;
640
641   // Reserve some memory inside the message queue
642   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
643
644   // Construct message in the message queue memory; note that delete should not be called on the return value
645   new (slot) LocalType( &manager, &ResourceManager::HandleDiscardResourceRequest, id, typeId );
646 }
647
648 inline void RequestAtlasUpdateMessage( EventToUpdate& eventToUpdate,
649                                        ResourceManager& manager,
650                                        ResourceId id,
651                                        ResourceId atlasId,
652                                        Integration::LoadStatus loadStatus )
653 {
654   typedef MessageValue3< ResourceManager, ResourceId, ResourceId, Integration::LoadStatus > LocalType;
655
656   // Reserve some memory inside the message queue
657   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
658
659   // Construct message in the message queue memory; note that delete should not be called on the return value
660   new (slot) LocalType( &manager, &ResourceManager::HandleAtlasUpdateRequest, id, atlasId, loadStatus );
661 }
662
663 } // namespace Internal
664
665 } // namespace Dali
666
667 #endif // __DALI_INTERNAL_RESOURCE_MANAGER_H__