1 #ifndef __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
2 #define __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
5 * Copyright (c) 2015 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.
21 #include <dali/public-api/common/dali-vector.h>
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/devel-api/threading/conditional-wait.h>
24 #include <dali/devel-api/threading/mutex.h>
25 #include <dali/devel-api/threading/thread.h>
26 #include <dali/devel-api/adaptor-framework/bitmap-loader.h>
27 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
39 * The task of loading and packing an image into the atlas.
46 LoadingTask( BitmapLoader loader, uint32_t packPositionX, uint32_t packPositionY, uint32_t width, uint32_t height );
51 LoadingTask( const LoadingTask& queue );
54 LoadingTask& operator=( const LoadingTask& queue );
58 BitmapLoader loader; ///< The loader used to load the bitmap from URL
59 Rect<uint32_t> packRect; ///< The x coordinate of the position to pack the image.
64 * The queue of the tasks waiting to load the bitmap from the URL in the worker thread/
66 class LoadQueue //: public TaskQueue
81 * Pop the next task out from the queue.
83 * @return The next task to be processed.
85 LoadingTask* NextTask();
88 * Add a task in to the queue
90 * @param[in] task The task added to the queue.
92 void AddTask( LoadingTask* task );
97 LoadQueue( const LoadQueue& queue );
100 LoadQueue& operator=( const LoadQueue& queue );
104 Vector< LoadingTask* > mTasks;
105 ConditionalWait mConditionalWait;
109 * The queue of the tasks, with the image loaded, waiting for the main thread to upload the bitmap.
111 class CompleteQueue //: public TaskQueue
118 * @param[in] mTrigger The trigger to wake up the main thread.
120 CompleteQueue( EventThreadCallback* mTrigger );
128 * Pop the next task out from the queue.
130 * @return The next task to be processed.
132 LoadingTask* NextTask();
135 * Add a task in to the queue
137 * @param[in] task The task added to the queue.
139 void AddTask( LoadingTask* task );
144 CompleteQueue( const CompleteQueue& queue );
147 CompleteQueue& operator=( const CompleteQueue& queue );
151 Vector< LoadingTask* > mTasks;
153 EventThreadCallback* mTrigger;
157 * The worker thread for image loading.
159 class ImageLoadThread : public Thread
166 * @param[in] loadQueue The task queue with images for loading.
167 * @param[in] completeQurue The task queue with images loaded.
169 ImageLoadThread( LoadQueue& loadQueue, CompleteQueue& completeQueue );
174 virtual ~ImageLoadThread();
179 * The entry function of the worker thread.
180 * It fetches loading task from the loadQueue, loads the image and adds to the completeQueue.
187 ImageLoadThread( const ImageLoadThread& thread );
190 ImageLoadThread& operator=( const ImageLoadThread& thread );
194 LoadQueue& mLoadQueue; ///<The task queue with images for loading.
195 CompleteQueue& mCompleteQueue; ///<The task queue with images loaded.
198 } // namespace Internal
200 } // namespace Toolkit
204 #endif /* __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__ */