Blending enum clean-up
[platform/core/uifw/dali-core.git] / dali / internal / render / common / texture-cache-dispatcher.h
1 #ifndef __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
2 #define __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_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 <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/buffer-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/pixel.h>
29 #include <dali/devel-api/images/pixel-data.h>
30 #include <dali/internal/common/message.h>
31 #include <dali/internal/update/common/scene-graph-buffers.h>
32 #include <dali/integration-api/resource-declarations.h>
33 #include <dali/integration-api/bitmap.h>
34
35 namespace Dali
36 {
37
38 namespace Internal
39 {
40 typedef Integration::ResourceId ResourceId;
41
42 namespace SceneGraph
43 {
44
45 class RenderQueue;
46
47 class TextureCacheDispatcher
48 {
49 public:
50
51   /**
52    * Constructor
53    * @param[in] renderQueue The queue to which to send messages
54    */
55   TextureCacheDispatcher( RenderQueue& renderQueue );
56
57   /**
58    * Virtual destructor; TextureCacheDispatcher is a base class.
59    */
60   virtual ~TextureCacheDispatcher();
61
62   /**
63    * mRenderQueue needs the update buffer index when any of the dispatch methods are
64    * called. Should really store a functor to get this index, but existing functors
65    * use references. Could heap allocate the functor, but that seems overly wasteful.
66    * Instead, store a pointer to the SceneGraphBuffers object, and call the relevant
67    * function when required. (increases coupling, requires object lifetime management :/ )
68    *
69    * @param[in] bufferIndices Pointer to SceneGraphBuffers object that can query
70    * the current RenderQueue buffer index.
71    */
72   void SetBufferIndices( const SceneGraphBuffers* bufferIndices );
73
74   /**
75    * Dispatch a message to create an empty texture and add it to the texture cache.
76    * May be called from Update thread
77    * @param[in] id Resource Id of the texture
78    * @param[in] width Width of the texture
79    * @param[in] height Height of the texture
80    * @param[in] pixelFormat Pixel format of the texture
81    * @param[in] clearPixels True if the data should be cleared to 0 on creation
82    */
83   virtual void DispatchCreateTexture( ResourceId        id,
84                                       unsigned int      width,
85                                       unsigned int      height,
86                                       Pixel::Format     pixelFormat,
87                                       bool              clearPixels ) = 0;
88
89   /**
90    * Dispatch a message to add a texture for bitmap.
91    * May be called from Update thread
92    * @param[in] id Resource Id of the bitmap
93    * @param[in] bitmap The bitmap
94    */
95   virtual void DispatchCreateTextureForBitmap( ResourceId id, Integration::Bitmap* bitmap ) = 0;
96
97   /**
98    * Dispatch a message to add a native image to the texture cache
99    * May be called from Update thread
100    * @param[in] id Resource Id of the native image
101    * @param[in] nativeImage The native image
102    */
103   virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
104
105   /**
106    * Dispatch a message to create a framebuffer texture and add it to the texture cache
107    * May be called from Update thread
108    * @param[in] id Resource Id of the framebuffer
109    * @param[in] width Width of the framebuffer
110    * @param[in] height Height of the framebuffer
111    * @param[in] pixelFormat Pixel format of the framebuffer
112    */
113   virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat ) = 0;
114
115   /**
116    * Dispatch a message to create a framebuffer texture and add it to the texture cache
117    * May be called from Update thread
118    * @param[in] id Resource Id of the framebuffer
119    * @param[in] nativeImage The NativeImage
120    */
121   virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
122
123   /**
124    * @brief Create GL texture for native image resource.
125    * @param[in] id The resource id.
126    */
127   virtual void DispatchCreateGlTexture( ResourceId id ) = 0;
128
129   /**
130    * Dispatch a message to update the texture.
131    * May be called from Update thread
132    * @param[in] id Resource Id of the texture
133    * @param[in] bitmap The updated bitmap
134    */
135   virtual void DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap ) = 0;
136
137   /**
138    * Dispatch a message to update the part of a texture with the bitmap data.
139    * May be called from Update thread
140    * @param[in] destId The ID of the texture to update
141    * @param[in] bitmap The pointer pointing to the source bitmap data.
142    * @param [in] xOffset Specifies an offset in the x direction within the texture
143    * @param [in] yOffset Specifies an offset in the y direction within the texture
144    */
145   virtual void DispatchUpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset ) = 0;
146
147   /**
148    * Dispatch a message to update the part of a texture with a newly loaded bitmap
149    * May be called from Update thread
150    * @param[in] destId The ID of the texture to update
151    * @param[in] srcId The resource ID of the source bitmap
152    * @param [in] xOffset Specifies an offset in the x direction within the texture
153    * @param [in] yOffset Specifies an offset in the y direction within the texture
154    */
155   virtual void DispatchUpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset ) = 0;
156
157   /**
158    * Dispatch a message to update the part of a texture with the pixel data.
159    * May be called from Update thread
160    * @param[in] destId The ID of the texture to update
161    * @param[in] pixelData The pointer pointing to the pixel data to upload.
162    * @param [in] xOffset Specifies an offset in the x direction within the texture
163    * @param [in] yOffset Specifies an offset in the y direction within the texture
164    */
165   virtual void DispatchUpdateTexture( ResourceId id, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset ) = 0;
166
167   /**
168    * Dispatch a message to update the texture area
169    * May be called from the Update thread
170    * @param[in] id Resource Id of the texture
171    * @param[in] area The area of the bitmap that has changed
172    */
173   virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area ) = 0;
174
175   /**
176    * Dispatch a message to discard a texture
177    * May be called from Update thread
178    * @param[in] id Resource Id of the texture
179    */
180   virtual void DispatchDiscardTexture( ResourceId id ) = 0;
181
182 protected:
183
184   RenderQueue&             mRenderQueue;
185   const SceneGraphBuffers* mSceneGraphBuffers;
186 };
187
188 } // SceneGraph
189
190 } // Internal
191
192 } // Dali
193
194 #endif // __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__