X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fsvg%2Fsvg-rasterize-thread.h;h=b915b133d60e182326b2b45314600e7248b54f12;hp=c0cf72650a9a9bad56444211e35dc3c8a4f1d1c1;hb=HEAD;hpb=4764ce1dc9edc7c08766e356c839278204369d73 diff --git a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h deleted file mode 100644 index c0cf726..0000000 --- a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef DALI_TOOLKIT_SVG_RASTERIZE_THREAD_H -#define DALI_TOOLKIT_SVG_RASTERIZE_THREAD_H - -/* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ -class SvgVisual; -typedef IntrusivePtr SvgVisualPtr; -class RasterizingTask; -typedef IntrusivePtr RasterizingTaskPtr; - -/** - * The svg rasterizing tasks to be processed in the worker thread. - * - * Life cycle of a rasterizing task is as follows: - * 1. Created by SvgVisual in the main thread - * 2. Queued in the worked thread waiting to be processed. - * 3. If this task gets its turn to do the rasterization, it triggers main thread to apply the rasterized image to material then been deleted in main thread call back - * Or if this task is been removed ( new image/size set to the visual or actor off stage) before its turn to be processed, it then been deleted in the worker thread. - */ -class RasterizingTask : public RefObject -{ -public: - /** - * Constructor - * @param[in] svgVisual The visual which the rasterized image to be applied. - * @param[in] vectorRenderer The vector rasterizer. - * @param[in] url The URL to svg resource to use. - * @param[in] dpi The DPI of the screen. - * @param[in] width The rasterization width. - * @param[in] height The rasterization height. - */ - RasterizingTask(SvgVisual* svgVisual, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height); - - /** - * Destructor. - */ - ~RasterizingTask() override; - - /** - * Load svg file - */ - void Load(); - - /** - * Do the rasterization with the mRasterizer. - */ - void Rasterize(); - - /** - * Get the svg visual - */ - SvgVisual* GetSvgVisual() const; - - /** - * Get the rasterization result. - * @return The pixel data with the rasterized pixels. - */ - PixelData GetPixelData() const; - - /** - * Whether the resource is loaded. - * @return True if the resource is loaded. - */ - bool IsLoaded() const; - -private: - // Undefined - RasterizingTask(const RasterizingTask& task); - - // Undefined - RasterizingTask& operator=(const RasterizingTask& task); - -private: - SvgVisualPtr mSvgVisual; - VectorImageRenderer mVectorRenderer; - VisualUrl mUrl; - PixelData mPixelData; - float mDpi; - uint32_t mWidth; - uint32_t mHeight; - bool mLoadSuccess; -}; - -/** - * The worker thread for SVG rasterization. - */ -class SvgRasterizeThread : public Thread, Integration::Processor -{ -public: - /** - * Constructor. - * - * @param[in] trigger The trigger to wake up the main thread. - */ - SvgRasterizeThread(); - - /** - * Terminate the svg rasterize thread, join and delete. - */ - static void TerminateThread(SvgRasterizeThread*& thread); - - /** - * Add a rasterization task into the waiting queue, called by main thread. - * - * @param[in] task The task added to the queue. - */ - void AddTask(RasterizingTaskPtr task); - - /** - * Pop the next task out from the completed queue, called by main thread. - * - * @return The next task in the completed queue. - */ - RasterizingTaskPtr NextCompletedTask(); - - /** - * Remove the task with the given visual from the waiting queue, called by main thread. - * - * Typically called when the actor is put off stage, so the renderer is not needed anymore. - * - * @param[in] visual The visual pointer. - */ - void RemoveTask(SvgVisual* visual); - - /** - * @copydoc Dali::Integration::Processor::Process() - */ - void Process(bool postProcessor) override; - -private: - /** - * Pop the next task out from the queue. - * - * @return The next task to be processed. - */ - RasterizingTaskPtr NextTaskToProcess(); - - /** - * Add a task in to the queue - * - * @param[in] task The task added to the queue. - */ - void AddCompletedTask(RasterizingTaskPtr task); - - /** - * Applies the rasterized image to material - */ - void ApplyRasterizedSVGToSampler(); - - /** - * @brief Unregister a previously registered processor - * - */ - void UnregisterProcessor(); - -protected: - /** - * Destructor. - */ - ~SvgRasterizeThread() override; - - /** - * The entry function of the worker thread. - * It fetches task from the Queue, rasterizes the image and apply to the renderer. - */ - void Run() override; - -private: - // Undefined - SvgRasterizeThread(const SvgRasterizeThread& thread); - - // Undefined - SvgRasterizeThread& operator=(const SvgRasterizeThread& thread); - -private: - std::vector mRasterizeTasks; //The queue of the tasks waiting to rasterize the SVG image - std::vector mCompletedTasks; //The queue of the tasks with the SVG rasterization completed - - ConditionalWait mConditionalWait; - Dali::Mutex mMutex; - std::unique_ptr mTrigger; - const Dali::LogFactoryInterface& mLogFactory; - bool mIsThreadWaiting; - bool mProcessorRegistered; -}; - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_SVG_RASTERIZE_THREAD_H