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