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.h>
26 #include <dali/public-api/images/bitmap-image.h>
27 #include <dali/public-api/images/pixel.h>
28 #include <dali/internal/common/message.h>
29 #include <dali/internal/update/common/scene-graph-buffers.h>
30 #include <dali/internal/common/bitmap-upload.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, NativeImagePtr 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 ) = 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, NativeImagePtr nativeImage ) = 0;
123 * Dispatch a message to update the texture.
124 * May be called from Update thread
125 * @param[in] id Resource Id of the texture
126 * @param[in] bitmap The updated bitmap
128 virtual void DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap ) = 0;
131 * Update the part of a texture with a newly loaded bitmap
132 * May be called from Update thread
133 * @param[in] destId The ID of the texture to update
134 * @param[in] srcId The resource ID of the source bitmap
135 * @param [in] xOffset Specifies an offset in the x direction within the texture
136 * @param [in] yOffset Specifies an offset in the y direction within the texture
138 virtual void DispatchUpdateTexture( ResourceId destId, ResourceId srcId,std::size_t xOffset, std::size_t yOffset ) = 0;
141 * Dispatch a message to update the texture area
142 * May be called from the Update thread
143 * @param[in] id Resource Id of the texture
144 * @param[in] area The area of the bitmap that has changed
146 virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area ) = 0;
149 * Dispatch a message to insert an array of bitmaps into the texture.
150 * Used for uploading multiple images into an atlas.
151 * @param[in] id Resource id of the texture
152 * @param[in] uploadArray array of BitmapUpload structures
154 virtual void DispatchUploadBitmapArrayToTexture( ResourceId id, const BitmapUploadArray& uploadArray ) = 0;
157 * Dispatch a message to clear multiple areas of a texture to a specific color
158 * @param[in] id Resource id of the texture to clear
159 * @param[in] area Rectangles to clear
160 * @param[in] blockSize Size of block to clear
161 * @param[in] color Clear color (as a pixel value)
163 virtual void DispatchClearAreas( ResourceId id, const BitmapClearArray& area, std::size_t blockSize, uint32_t color ) = 0;
166 * Dispatch a message to discard a texture
167 * May be called from Update thread
168 * @param[in] id Resource Id of the texture
170 virtual void DispatchDiscardTexture( ResourceId id ) = 0;
174 RenderQueue& mRenderQueue;
175 const SceneGraphBuffers* mSceneGraphBuffers;
184 #endif // __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__