1 #ifndef __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
2 #define __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/images/native-image-interface.h>
26 #include <dali/public-api/images/buffer-image.h>
27 #include <dali/public-api/images/pixel.h>
28 #include <dali/public-api/images/frame-buffer-image.h>
29 #include <dali/internal/common/message.h>
30 #include <dali/internal/update/common/scene-graph-buffers.h>
31 #include <dali/integration-api/resource-declarations.h>
32 #include <dali/integration-api/bitmap.h>
39 typedef Integration::ResourceId ResourceId;
46 class TextureCacheDispatcher
52 * @param[in] renderQueue The queue to which to send messages
54 TextureCacheDispatcher( RenderQueue& renderQueue );
57 * Virtual destructor; TextureCacheDispatcher is a base class.
59 virtual ~TextureCacheDispatcher();
62 * mRenderQueue needs the update buffer index when any of the dispatch methods are
63 * called. Should really store a functor to get this index, but existing functors
64 * use references. Could heap allocate the functor, but that seems overly wasteful.
65 * Instead, store a pointer to the SceneGraphBuffers object, and call the relevant
66 * function when required. (increases coupling, requires object lifetime management :/ )
68 * @param[in] bufferIndices Pointer to SceneGraphBuffers object that can query
69 * the current RenderQueue buffer index.
71 void SetBufferIndices( const SceneGraphBuffers* bufferIndices );
74 * Dispatch a message to create an empty texture and add it to the texture cache.
75 * May be called from Update thread
76 * @param[in] id Resource Id of the texture
77 * @param[in] width Width of the texture
78 * @param[in] height Height of the texture
79 * @param[in] pixelFormat Pixel format of the texture
80 * @param[in] clearPixels True if the data should be cleared to 0 on creation
82 virtual void DispatchCreateTexture( ResourceId id,
85 Pixel::Format pixelFormat,
86 bool clearPixels ) = 0;
89 * Dispatch a message to add a texture for bitmap.
90 * May be called from Update thread
91 * @param[in] id Resource Id of the bitmap
92 * @param[in] bitmap The bitmap
94 virtual void DispatchCreateTextureForBitmap( ResourceId id, Integration::Bitmap* bitmap ) = 0;
97 * Dispatch a message to add a native image to the texture cache
98 * May be called from Update thread
99 * @param[in] id Resource Id of the native image
100 * @param[in] nativeImage The native image
102 virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
105 * Dispatch a message to create a framebuffer texture and add it to the texture cache
106 * May be called from Update thread
107 * @param[in] id Resource Id of the framebuffer
108 * @param[in] width Width of the framebuffer
109 * @param[in] height Height of the framebuffer
110 * @param[in] pixelFormat Pixel format of the framebuffer
112 virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat ) = 0;
115 * Dispatch a message to create a framebuffer texture and add it to the texture cache
116 * May be called from Update thread
117 * @param[in] id Resource Id of the framebuffer
118 * @param[in] nativeImage The NativeImage
120 virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
123 * @brief Create GL texture for native image resource.
124 * @param[in] id The resource id.
126 virtual void DispatchCreateGlTexture( ResourceId id ) = 0;
129 * Dispatch a message to update the texture.
130 * May be called from Update thread
131 * @param[in] id Resource Id of the texture
132 * @param[in] bitmap The updated bitmap
134 virtual void DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap ) = 0;
137 * Dispatch a message to update the part of a texture with the bitmap data.
138 * May be called from Update thread
139 * @param[in] destId The ID of the texture to update
140 * @param[in] bitmap The pointer pointing to the source bitmap data.
141 * @param [in] xOffset Specifies an offset in the x direction within the texture
142 * @param [in] yOffset Specifies an offset in the y direction within the texture
144 virtual void DispatchUpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset ) = 0;
147 * Dispatch a message to update the part of a texture with a newly loaded bitmap
148 * May be called from Update thread
149 * @param[in] destId The ID of the texture to update
150 * @param[in] srcId The resource ID of the source bitmap
151 * @param [in] xOffset Specifies an offset in the x direction within the texture
152 * @param [in] yOffset Specifies an offset in the y direction within the texture
154 virtual void DispatchUpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset ) = 0;
157 * Dispatch a message to update the texture area
158 * May be called from the Update thread
159 * @param[in] id Resource Id of the texture
160 * @param[in] area The area of the bitmap that has changed
162 virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area ) = 0;
165 * Dispatch a message to discard a texture
166 * May be called from Update thread
167 * @param[in] id Resource Id of the texture
169 virtual void DispatchDiscardTexture( ResourceId id ) = 0;
173 RenderQueue& mRenderQueue;
174 const SceneGraphBuffers* mSceneGraphBuffers;
183 #endif // __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__