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/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>
40 typedef Integration::ResourceId ResourceId;
47 class TextureCacheDispatcher
53 * @param[in] renderQueue The queue to which to send messages
55 TextureCacheDispatcher( RenderQueue& renderQueue );
58 * Virtual destructor; TextureCacheDispatcher is a base class.
60 virtual ~TextureCacheDispatcher();
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 :/ )
69 * @param[in] bufferIndices Pointer to SceneGraphBuffers object that can query
70 * the current RenderQueue buffer index.
72 void SetBufferIndices( const SceneGraphBuffers* bufferIndices );
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
83 virtual void DispatchCreateTexture( ResourceId id,
86 Pixel::Format pixelFormat,
87 bool clearPixels ) = 0;
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
95 virtual void DispatchCreateTextureForBitmap( ResourceId id, Integration::Bitmap* bitmap ) = 0;
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
103 virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
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
113 virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat ) = 0;
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
121 virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
124 * @brief Create GL texture for native image resource.
125 * @param[in] id The resource id.
127 virtual void DispatchCreateGlTexture( ResourceId id ) = 0;
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
135 virtual void DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap ) = 0;
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
145 virtual void DispatchUpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset ) = 0;
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
155 virtual void DispatchUpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset ) = 0;
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
165 virtual void DispatchUpdateTexture( ResourceId id, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset ) = 0;
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
173 virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area ) = 0;
176 * Dispatch a message to discard a texture
177 * May be called from Update thread
178 * @param[in] id Resource Id of the texture
180 virtual void DispatchDiscardTexture( ResourceId id ) = 0;
184 RenderQueue& mRenderQueue;
185 const SceneGraphBuffers* mSceneGraphBuffers;
194 #endif // __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__