Merge remote-tracking branch 'origin/tizen' into new_text
[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/event/resources/resource-client-declarations.h>
39 #include <dali/internal/event/effects/shader-factory.h>
40 #include <dali/internal/update/modeling/internal-mesh-data.h>
41 #include <dali/internal/update/modeling/scene-graph-mesh-declarations.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    * Requests allocation of a mesh resource
241    * @param[in] id The resource id
242    * @param[in] meshData The mesh data
243    */
244   void HandleAllocateMeshRequest (ResourceId id, MeshData* meshData);
245
246   /**
247    * Load a shader program from a file
248    * @param[in] id The resource id
249    * @param[in] typePath The type & path of the resource
250    */
251   void HandleLoadShaderRequest(ResourceId id, const ResourceTypePath& typePath );
252
253   /**
254    * Update bitmap area request
255    * @param[in] textureId The resource ID of a bitmap-texture to remove.
256    * @param[in] area The updated area. Zero width/height indicates the whole bitmap has been updated
257    */
258   void HandleUpdateBitmapAreaRequest( ResourceId textureId, const Dali::RectArea& area );
259
260   /**
261    * Upload a bitmap to a position within a specified texture
262    * @param[in] destId The destination texture ID
263    * @param[in] srcId The resource ID of the bitmap to upload
264    * @param [in] xOffset Specifies an offset in the x direction within the texture
265    * @param [in] yOffset Specifies an offset in the y direction within the texture
266    */
267   void HandleUploadBitmapRequest( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
268
269   /**
270    * Upload mesh buffer changes.
271    * @param[in] updateBufferIndex The current update buffer index.
272    * @param[in] id The ID of a Mesh resource.
273    * @param[in] meshData Newly allocated mesh data; ownership is taken.
274    */
275   void HandleUpdateMeshRequest( BufferIndex updateBufferIndex, ResourceId id, MeshData* meshData );
276
277   /**
278    * Request reloading a resource from the native filesystem.
279    * @param[in] id The resource id
280    * @param[in] typePath The type & path of the resource
281    * @param[in] priority The priority of the request. This is ignored if the resource is already being refreshed.
282    * @param[in] resetFinishedStatus True if the finished status of the resource id should be reset
283    */
284   void HandleReloadResourceRequest( ResourceId id, const ResourceTypePath& typePath, Integration::LoadResourcePriority priority, bool resetFinishedStatus );
285
286   /**
287    * Save a resource to the given url
288    * @param[in] id       The resource id
289    * @param[in] typePath The type & path of the resource
290    */
291   void HandleSaveResourceRequest( ResourceId id, const ResourceTypePath& typePath );
292
293   /**
294    * Resource ticket has been discarded, throw away the actual resource
295    */
296   void HandleDiscardResourceRequest( ResourceId id, Integration::ResourceTypeId typeId );
297
298   /********************************************************************************
299    ******************** Update thread object direct interface  ********************
300    ********************************************************************************/
301
302   /**
303    * Check if a resource has completed loading.
304    * @param[in] id The ID of a bitmap/texture resource.
305    * @return true if the bitmap or texture has finished loading
306    */
307   bool IsResourceLoaded(ResourceId id);
308
309   /**
310    * Check if a resource has failed to load, e.g. file not found, etc.
311    * @param[in] id The ID of a bitmap/texture resource.
312    * @return true if the bitmap or texture has failed to load
313    */
314   bool IsResourceLoadFailed(ResourceId id);
315
316   /**
317    * Get bitmap metadata. This stores meta data about the resource, but
318    * doesn't keep track of the resource
319    */
320   BitmapMetadata GetBitmapMetadata(ResourceId id);
321
322   /**
323    * Get the mesh data.
324    * @note Used by update thread objects (SceneGraph::Mesh) only
325    * @param[in] id - the id of a MeshData resource.
326    * @return the mesh data or NULL if this resource isn't valid
327    */
328   Internal::SceneGraph::Mesh* GetMesh(ResourceId id);
329
330   /**
331    * Returns the shader resource corresponding to the Id
332    * @param[in] id - the id of a shader binary resource.
333    * @return the shader binary resource data or NULL if it has not been loaded.
334    */
335   Integration::ShaderDataPtr GetShaderData(ResourceId id);
336
337   /********************************************************************************
338    ************************* ResourceCache Implementation  ************************
339    ********************************************************************************/
340 public:
341
342   /**
343    * @copydoc Integration::ResourceCache::LoadResponse
344    */
345   virtual void LoadResponse(ResourceId id, Integration::ResourceTypeId type, Integration::ResourcePointer resource, Integration::LoadStatus loadStatus);
346
347   /**
348    * @copydoc Integration::ResourceCache::SaveComplete
349    */
350   virtual void SaveComplete(ResourceId id, Integration::ResourceTypeId type);
351
352   /**
353    * @copydoc Integration::ResourceCache::LoadFailed
354    */
355   virtual void LoadFailed(ResourceId id, Integration::ResourceFailure failure);
356
357   /**
358    * @copydoc Integration::ResourceCache::SaveFailed
359    */
360   virtual void SaveFailed(ResourceId id, Integration::ResourceFailure failure);
361
362   /********************************************************************************
363    ********************************* Private Methods  *****************************
364    ********************************************************************************/
365 private:
366
367   /**
368    * Sends notification messages for load sucess & failure,
369    * pushes from newComplete / newFailed into oldComplete / oldFailed respectively
370    */
371   void NotifyTickets();
372
373   /**
374    * Triggers message to Event thread to update the ticket's image attributes
375    * @pre An Image resource with the given id should exist in the cache.
376    * @param id ID of the image resource
377    * @param attributes Resource image attributes
378    */
379   void UpdateImageTicket( ResourceId id, ImageAttributes& attributes );
380
381   /**
382    * Send message to ResourceClient in event thread
383    * @param[in] message The message to send
384    */
385   void SendToClient( MessageBase* message );
386
387   /**
388    * Discard all dead resources.
389    * @param[in] updateBufferIndex The current update buffer index.
390    */
391   void DiscardDeadResources( BufferIndex updateBufferIndex );
392
393 private:
394   struct ResourceManagerImpl;
395   ResourceManagerImpl* mImpl;
396 };
397
398 // Messages sent to resource manager from other threads:
399 // These functions are run on other threads and insert messages to be
400 // picked-up by the update thread in its main loop and executed on that in
401 // submission order.
402
403 inline void RequestLoadResourceMessage( EventToUpdate& eventToUpdate,
404                                         ResourceManager& manager,
405                                         ResourceId id,
406                                         const ResourceTypePath& typePath,
407                                         Integration::LoadResourcePriority priority )
408 {
409   typedef MessageValue3< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority > LocalType;
410
411   // Reserve some memory inside the message queue
412   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
413
414   // Construct message in the message queue memory; note that delete should not be called on the return value
415   new (slot) LocalType( &manager, &ResourceManager::HandleLoadResourceRequest, id, typePath, priority );
416 }
417
418 inline void RequestDecodeResourceMessage( EventToUpdate& eventToUpdate,
419                                           ResourceManager& manager,
420                                           const ResourceId id,
421                                           /// We use typePath instead of the raw type for ownership and to enable copying of a concrete type.
422                                           const ResourceTypePath& typePath,
423                                           RequestBufferPtr buffer,
424                                           Integration::LoadResourcePriority priority )
425 {
426   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, RequestBufferPtr, Integration::LoadResourcePriority > LocalType;
427
428   // Reserve some memory inside the message queue
429   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
430
431   // Construct message in the message queue memory; note that delete should not be called on the return value
432   new (slot) LocalType( &manager, &ResourceManager::HandleDecodeResourceRequest, id, typePath, buffer, priority );
433 }
434
435 inline void RequestAddBitmapImageMessage( EventToUpdate& eventToUpdate,
436                                           ResourceManager& manager,
437                                           ResourceId id,
438                                           Integration::Bitmap* resourceData )
439 {
440   typedef MessageValue2< ResourceManager, ResourceId, Integration::BitmapPtr > LocalType;
441
442   // Reserve some memory inside the message queue
443   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
444
445   // Construct message in the message queue memory; note that delete should not be called on the return value
446   new (slot) LocalType( &manager, &ResourceManager::HandleAddBitmapImageRequest, id, resourceData );
447 }
448
449 inline void RequestAddNativeImageMessage( EventToUpdate& eventToUpdate,
450                                           ResourceManager& manager,
451                                           ResourceId id,
452                                           NativeImageInterfacePtr resourceData )
453 {
454   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
455
456   // Reserve some memory inside the message queue
457   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
458
459   // Construct message in the message queue memory; note that delete should not be called on the return value
460   new (slot) LocalType( &manager, &ResourceManager::HandleAddNativeImageRequest, id, resourceData );
461 }
462
463 inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
464                                                ResourceManager& manager,
465                                                ResourceId id,
466                                                unsigned int width,
467                                                unsigned int height,
468                                                Pixel::Format pixelFormat )
469 {
470   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
471
472   // Reserve some memory inside the message queue
473   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
474
475   // Construct message in the message queue memory; note that delete should not be called on the return value
476   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, width, height, pixelFormat );
477 }
478
479 inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
480                                                ResourceManager& manager,
481                                                ResourceId id,
482                                                NativeImageInterfacePtr resourceData )
483 {
484   typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
485
486   // Reserve some memory inside the message queue
487   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
488
489   // Construct message in the message queue memory; note that delete should not be called on the return value
490   new (slot) LocalType( &manager, &ResourceManager::HandleAddFrameBufferImageRequest, id, resourceData );
491 }
492
493 inline void RequestAllocateTextureMessage(EventToUpdate& eventToUpdate,
494                                                ResourceManager& manager,
495                                                ResourceId id,
496                                                unsigned int width,
497                                                unsigned int height,
498                                                Pixel::Format pixelFormat)
499 {
500   typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
501
502   // Reserve some memory inside the message queue
503   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
504
505   // Construct message in the message queue memory; note that delete should not be called on the return value
506   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateTextureRequest, id, width, height, pixelFormat );
507 }
508
509 inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate,
510                                         ResourceManager& manager,
511                                         ResourceId id,
512                                         OwnerPointer<MeshData>& meshData )
513 {
514   typedef MessageValue2< ResourceManager, ResourceId, OwnerPointer<MeshData> > LocalType;
515
516   // Reserve some memory inside the message queue
517   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
518
519   // Construct message in the message queue memory; note that delete should not be called on the return value
520   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateMeshRequest, id, meshData.Release() );
521 }
522
523 inline void RequestLoadShaderMessage( EventToUpdate& eventToUpdate,
524                                       ResourceManager& manager,
525                                       ResourceId id,
526                                       const ResourceTypePath& typePath )
527 {
528   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
529
530   // Reserve some memory inside the message queue
531   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
532
533   // Construct message in the message queue memory; note that delete should not be called on the return value
534   new (slot) LocalType( &manager, &ResourceManager::HandleLoadShaderRequest, id, typePath );
535 }
536
537 inline void RequestUpdateBitmapAreaMessage( EventToUpdate& eventToUpdate,
538                                             ResourceManager& manager,
539                                             ResourceId id,
540                                             const Dali::RectArea& area )
541 {
542   typedef MessageValue2< ResourceManager, ResourceId, Dali::RectArea > LocalType;
543
544   // Reserve some memory inside the message queue
545   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
546
547   // Construct message in the message queue memory; note that delete should not be called on the return value
548   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateBitmapAreaRequest, id, area );
549 }
550
551 inline void RequestUploadBitmapMessage( EventToUpdate& eventToUpdate,
552                                         ResourceManager& manager,
553                                         ResourceId destId,
554                                         ResourceId srcId,
555                                         std::size_t xOffset,
556                                         std::size_t yOffset )
557 {
558   typedef MessageValue4< ResourceManager, ResourceId, ResourceId, std::size_t, std::size_t > LocalType;
559
560   // Reserve some memory inside the message queue
561   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
562
563   // Construct message in the message queue memory; note that delete should not be called on the return value
564   new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, srcId, xOffset, yOffset );
565 }
566
567 inline void RequestUpdateMeshMessage( EventToUpdate& eventToUpdate,
568                                       ResourceManager& manager,
569                                       ResourceId id,
570                                       const Dali::MeshData& meshData,
571                                       ResourcePolicy::Discardable discardable )
572 {
573   typedef MessageDoubleBuffered2< ResourceManager, ResourceId, OwnerPointer< MeshData > > LocalType;
574   // Reserve some memory inside the message queue
575   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
576
577   MeshData* internalMeshData = new MeshData( meshData, discardable, false );
578
579   // Construct message in the message queue memory; note that delete should not be called on the return value
580   new (slot) LocalType( &manager, &ResourceManager::HandleUpdateMeshRequest, id, internalMeshData );
581 }
582
583 inline void RequestReloadResourceMessage( EventToUpdate& eventToUpdate,
584                                           ResourceManager& manager,
585                                           ResourceId id,
586                                           const ResourceTypePath& typePath,
587                                           Integration::LoadResourcePriority priority,
588                                           bool resetFinishedStatus )
589 {
590   typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority, bool > LocalType;
591
592   // Reserve some memory inside the message queue
593   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ), false );
594
595   // Construct message in the message queue memory; note that delete should not be called on the return value
596   new (slot) LocalType( &manager, &ResourceManager::HandleReloadResourceRequest, id, typePath, priority, resetFinishedStatus );
597 }
598
599 inline void RequestSaveResourceMessage( EventToUpdate& eventToUpdate,
600                                         ResourceManager& manager,
601                                         ResourceId id,
602                                         const ResourceTypePath& typePath )
603 {
604   typedef MessageValue2< ResourceManager, ResourceId, ResourceTypePath > LocalType;
605
606   // Reserve some memory inside the message queue
607   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
608
609   // Construct message in the message queue memory; note that delete should not be called on the return value
610   new (slot) LocalType( &manager, &ResourceManager::HandleSaveResourceRequest, id, typePath );
611 }
612
613 inline void RequestDiscardResourceMessage( EventToUpdate& eventToUpdate,
614                                            ResourceManager& manager,
615                                            ResourceId id,
616                                            Integration::ResourceTypeId typeId )
617 {
618   typedef MessageValue2< ResourceManager, ResourceId, Integration::ResourceTypeId > LocalType;
619
620   // Reserve some memory inside the message queue
621   unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
622
623   // Construct message in the message queue memory; note that delete should not be called on the return value
624   new (slot) LocalType( &manager, &ResourceManager::HandleDiscardResourceRequest, id, typeId );
625 }
626
627 } // namespace Internal
628
629 } // namespace Dali
630
631 #endif // __DALI_INTERNAL_RESOURCE_MANAGER_H__