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