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