projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Show the broken image in case of invalid svg files
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
visuals
/
svg
/
svg-rasterize-thread.h
diff --git
a/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h
b/dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h
index
e01020e
..
86e233f
100644
(file)
--- a/
dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h
+++ b/
dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h
@@
-27,10
+27,13
@@
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture-set.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/texture-set.h>
-#include <dali-toolkit/internal/visuals/visual-url.h>
+#include <dali/devel-api/adaptor-framework/vector-image-renderer.h>
+#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
+#include <dali/integration-api/processor-interface.h>
+#include <memory>
-struct NSVGimage;
-struct NSVGrasterizer;
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/visual-url.h>
namespace Dali
{
namespace Dali
{
@@
-60,26
+63,22
@@
class RasterizingTask : public RefObject
public:
/**
* Constructor
public:
/**
* Constructor
- *
* @param[in] svgRenderer The renderer which the rasterized image to be applied.
* @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.
*/
* @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
);
+ RasterizingTask(
SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height
);
/**
* Destructor.
*/
/**
* Destructor.
*/
- ~RasterizingTask();
+ ~RasterizingTask()
override
;
/**
* Do the rasterization with the mRasterizer.
*/
/**
* Do the rasterization with the mRasterizer.
*/
- void Rasterize(
);
+ void Rasterize();
/**
* Get the svg visual
/**
* Get the svg visual
@@
-93,10
+92,15
@@
public:
PixelData GetPixelData() const;
/**
PixelData GetPixelData() const;
/**
- * Get the parsed data.
- * @return parsed image data.
+ * Get the VectorRenderer.
+ * @return VectorRenderer.
+ */
+ VectorImageRenderer GetVectorRenderer() const;
+ /**
+ * Whether the resource is loaded.
+ * @return True if the resource is loaded.
*/
*/
-
NSVGimage* GetParsedImage
() const;
+
bool IsLoaded
() const;
/**
* Load svg file
/**
* Load svg file
@@
-112,19
+116,19
@@
private:
private:
SvgVisualPtr mSvgVisual;
private:
SvgVisualPtr mSvgVisual;
-
NSVGimage* mParsedSvg
;
+
VectorImageRenderer mVectorRenderer
;
VisualUrl mUrl;
PixelData mPixelData;
float mDpi;
unsigned int mWidth;
unsigned int mHeight;
VisualUrl mUrl;
PixelData mPixelData;
float mDpi;
unsigned int mWidth;
unsigned int mHeight;
-
NSVGrasterizer* mRasterizer
;
+
bool mLoadSuccess
;
};
/**
* The worker thread for SVG rasterization.
*/
};
/**
* The worker thread for SVG rasterization.
*/
-class SvgRasterizeThread : public Thread
+class SvgRasterizeThread : public Thread
, Integration::Processor
{
public:
{
public:
@@
-133,7
+137,7
@@
public:
*
* @param[in] trigger The trigger to wake up the main thread.
*/
*
* @param[in] trigger The trigger to wake up the main thread.
*/
- SvgRasterizeThread(
EventThreadCallback* trigger
);
+ SvgRasterizeThread();
/**
* Terminate the svg rasterize thread, join and delete.
/**
* Terminate the svg rasterize thread, join and delete.
@@
-166,11
+170,16
@@
public:
/**
* Delete the parsed SVG image, called by main thread.
*
/**
* Delete the parsed SVG image, called by main thread.
*
- * The parsed svg should be dele
l
ted in worker thread, as the main thread does not know whether a rasterization of this svg is ongoing.
+ * 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
+ * @param[in] VectorImage The image to be deleted
+ */
+ void DeleteImage( VectorImageRenderer vectorImage );
+
+ /**
+ * @copydoc Dali::Integration::Processor::Process()
*/
*/
- void
DeleteImage( NSVGimage* parsedSvg )
;
+ void
Process() override
;
private:
private:
@@
-188,12
+197,23
@@
private:
*/
void AddCompletedTask( RasterizingTaskPtr task );
*/
void AddCompletedTask( RasterizingTaskPtr task );
+ /**
+ * Applies the rasterized image to material
+ */
+ void ApplyRasterizedSVGToSampler();
+
+ /**
+ * @brief Unregister a previously registered processor
+ *
+ */
+ void UnregisterProcessor();
+
protected:
/**
* Destructor.
*/
protected:
/**
* Destructor.
*/
-
virtual ~SvgRasterizeThread()
;
+
~SvgRasterizeThread() override
;
/**
/**
@@
-214,13
+234,14
@@
private:
std::vector<RasterizingTaskPtr> mRasterizeTasks; //The queue of the tasks waiting to rasterize the SVG image
std::vector <RasterizingTaskPtr> mCompletedTasks; //The queue of the tasks with the SVG rasterization completed
std::vector<RasterizingTaskPtr> mRasterizeTasks; //The queue of the tasks waiting to rasterize the SVG image
std::vector <RasterizingTaskPtr> mCompletedTasks; //The queue of the tasks with the SVG rasterization completed
- Vector
<NSVGimage*>
mDeleteSvg; //The images that the event thread requested to delete
+ Vector
<VectorImageRenderer*>
mDeleteSvg; //The images that the event thread requested to delete
ConditionalWait mConditionalWait;
Dali::Mutex mMutex;
ConditionalWait mConditionalWait;
Dali::Mutex mMutex;
-
EventThreadCallback*
mTrigger;
-
+
std::unique_ptr< EventThreadCallback >
mTrigger;
+ const Dali::LogFactoryInterface& mLogFactory;
bool mIsThreadWaiting;
bool mIsThreadWaiting;
+ bool mProcessorRegistered;
};
} // namespace Internal
};
} // namespace Internal