X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fsvg%2Fsvg-rasterize-thread.h;h=705d41140ff48e695845e68c6a1ccbe9ae2b6180;hb=a4fa71ebecb9ed103fa3e64004e99b728f9190c2;hp=5c8b323e37af613c86bc429694fa1ecfd847f083;hpb=8bb92d7d1170f2ddf59da60bd3588be601ef8cd2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h index 5c8b323..705d411 100644 --- a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h +++ b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h @@ -27,15 +27,13 @@ #include #include #include -#include - -#ifdef NO_THORVG -struct NSVGimage; -struct NSVGrasterizer; -#else /* NO_THORVG */ -#include #include -#endif /* NO_THORVG */ +#include +#include +#include + +// INTERNAL INCLUDES +#include namespace Dali { @@ -63,20 +61,6 @@ typedef IntrusivePtr< RasterizingTask > RasterizingTaskPtr; class RasterizingTask : public RefObject { public: -#ifdef NO_THORVG - /** - * Constructor - * - * @param[in] svgRenderer The renderer which the rasterized image to be applied. - * @param[in] parsedSvg The parsed svg for rasterizing. - * Note, after the task is added to the worker thread, the worker thread takes over the ownership. - * When the image is to be deleted, delete it in the worker thread by calling SvgRasterizeThread::DeleteImage( parsedSvg ). - * @param[in] url The URL to svg resource to use. - * @param[in] width The rasterization width. - * @param[in] height The rasterization height. - */ - RasterizingTask( SvgVisual* svgRenderer, NSVGimage* parsedSvg, const VisualUrl& url, float dpi, unsigned int width, unsigned int height ); -#else /* NO_THORVG */ /** * Constructor * @param[in] svgRenderer The renderer which the rasterized image to be applied. @@ -86,7 +70,6 @@ public: * @param[in] loaded The svg resource is loaded or not. */ RasterizingTask( SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height, bool loaded ); -#endif /* NO_THORVG */ /** * Destructor. @@ -96,7 +79,7 @@ public: /** * Do the rasterization with the mRasterizer. */ - void Rasterize( ); + void Rasterize(); /** * Get the svg visual @@ -109,20 +92,6 @@ public: */ PixelData GetPixelData() const; -#ifdef NO_THORVG - /** - * Get the parsed data. - * @return parsed image data. - */ - NSVGimage* GetParsedImage() const; - /** - * Get default size of svg - * - * @param[out] width The default width of svg - * @param[out] height The default height of svg - */ - void GetDefaultSize( uint32_t& width, uint32_t& height ) const; -#else /* NO_THORVG */ /** * Get the VectorRenderer. * @return VectorRenderer. @@ -133,7 +102,6 @@ public: * @return True if the resource is loaded. */ bool IsLoaded() const; -#endif /* NO_THORVG */ /** * Load svg file @@ -149,27 +117,19 @@ private: private: SvgVisualPtr mSvgVisual; -#ifdef NO_THORVG - NSVGimage* mParsedSvg; -#else /* NO_THORVG */ VectorImageRenderer mVectorRenderer; -#endif /* NO_THORVG */ VisualUrl mUrl; PixelData mPixelData; float mDpi; unsigned int mWidth; unsigned int mHeight; -#ifdef NO_THORVG - NSVGrasterizer* mRasterizer; -#else /* NO_THORVG */ bool mLoaded; -#endif /* NO_THORVG */ }; /** * The worker thread for SVG rasterization. */ -class SvgRasterizeThread : public Thread +class SvgRasterizeThread : public Thread, Integration::Processor { public: @@ -178,7 +138,7 @@ public: * * @param[in] trigger The trigger to wake up the main thread. */ - SvgRasterizeThread( EventThreadCallback* trigger ); + SvgRasterizeThread(); /** * Terminate the svg rasterize thread, join and delete. @@ -208,16 +168,6 @@ public: */ void RemoveTask( SvgVisual* visual ); -#ifdef NO_THORVG - /** - * Delete the parsed SVG image, called by main thread. - * - * The parsed svg should be deleted in worker thread, as the main thread does not know whether a rasterization of this svg is ongoing. - * - * @param[in] parsedImage The image to be deleted - */ - void DeleteImage( NSVGimage* parsedSvg ); -#else /* NO_THORVG */ /** * Delete the parsed SVG image, called by main thread. * @@ -226,7 +176,11 @@ public: * @param[in] VectorImage The image to be deleted */ void DeleteImage( VectorImageRenderer vectorImage ); -#endif /* NO_THORVG */ + + /** + * @copydoc Dali::Integration::Processor::Process() + */ + void Process() override; private: @@ -244,6 +198,17 @@ private: */ void AddCompletedTask( RasterizingTaskPtr task ); + /** + * Applies the rasterized image to material + */ + void ApplyRasterizedSVGToSampler(); + + /** + * @brief Unregister a previously registered processor + * + */ + void UnregisterProcessor(); + protected: /** @@ -270,17 +235,14 @@ 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 -#ifdef NO_THORVG - Vector mDeleteSvg; //The images that the event thread requested to delete -#else /* NO_THORVG */ - Vector mDeleteSvg; //The images that the event thread requested to delete -#endif /* NO_THORVG */ + Vector mDeleteSvg; //The images that the event thread requested to delete ConditionalWait mConditionalWait; Dali::Mutex mMutex; - EventThreadCallback* mTrigger; - + std::unique_ptr< EventThreadCallback > mTrigger; + const Dali::LogFactoryInterface& mLogFactory; bool mIsThreadWaiting; + bool mProcessorRegistered; }; } // namespace Internal