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( uint32_t id, BitmapLoader loader );
51 LoadingTask( const LoadingTask& queue );
54 LoadingTask& operator=( const LoadingTask& queue );
58 BitmapLoader loader; ///< The loader used to load the bitmap from URL
59 uint32_t id; ///< The id associated with this task.
64 * The worker thread for image loading.
66 class ImageLoadThread : public Thread
73 * @param[in] mTrigger The trigger to wake up the main thread.
75 ImageLoadThread( EventThreadCallback* mTrigger );
80 virtual ~ImageLoadThread();
83 * Add a task in to the loading queue
85 * @param[in] task The task added to the queue.
87 void AddTask( LoadingTask* task );
90 * Pop the next task out from the completed queue.
92 * @return The next task to be processed.
94 LoadingTask* NextCompletedTask();
97 * Remove the loading task from the waiting queue.
99 bool CancelTask( uint32_t loadingTaskId );
102 * Remove all the loading tasks in the waiting queue.
109 * Pop the next loading task out from the queue to process.
111 * @return The next task to be processed.
113 LoadingTask* NextTaskToProcess();
116 * Add a task in to the loading queue
118 * @param[in] task The task added to the queue.
120 void AddCompletedTask( LoadingTask* task );
125 * The entry function of the worker thread.
126 * It fetches loading task from the loadQueue, loads the image and adds to the completeQueue.
133 ImageLoadThread( const ImageLoadThread& thread );
136 ImageLoadThread& operator=( const ImageLoadThread& thread );
140 Vector< LoadingTask* > mLoadQueue; ///<The task queue with images for loading.
141 Vector< LoadingTask* > mCompleteQueue; ///<The task queue with images loaded.
143 ConditionalWait mConditionalWait;
145 EventThreadCallback* mTrigger;
148 } // namespace Internal
150 } // namespace Toolkit
154 #endif /* __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__ */