CanvasRendererTizen::CanvasRendererTizen(const Vector2& viewBox)
: mPixelBuffer(nullptr),
+#ifdef THORVG_SUPPORT
mTvgCanvas(nullptr),
mTvgRoot(nullptr),
+#endif
mSize(0, 0),
mViewBox(0, 0),
mChanged(false)
CanvasRendererTizen::~CanvasRendererTizen()
{
+#ifdef THORVG_SUPPORT
for(DrawableVectorIterator it = mDrawables.begin(),
endIt = mDrawables.end();
it != endIt;
}
//Terminate ThorVG Engine
tvg::Initializer::term(tvg::CanvasEngine::Sw);
+#endif
}
void CanvasRendererTizen::Initialize(const Vector2& viewBox)
{
+#ifdef THORVG_SUPPORT
if(tvg::Initializer::init(tvg::CanvasEngine::Sw, 0 /*threads*/) != tvg::Result::Success)
{
DALI_LOG_ERROR("ThorVG engine initialize failed\n");
auto scene = tvg::Scene::gen();
mTvgRoot = scene.get();
mTvgCanvas->push(move(scene));
+#endif
}
bool CanvasRendererTizen::Commit()
{
+#ifdef THORVG_SUPPORT
bool changed = false;
for(DrawableVectorIterator it = mDrawables.begin(),
return false;
}
return true;
+#else
+ return false;
+#endif
}
Devel::PixelBuffer CanvasRendererTizen::GetPixelBuffer()
bool CanvasRendererTizen::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
{
+#ifdef THORVG_SUPPORT
bool exist = false;
for(DrawableVectorIterator it = mDrawables.begin(),
endIt = mDrawables.end();
mChanged = true;
return true;
+#else
+ return false;
+#endif
}
bool CanvasRendererTizen::SetSize(const Vector2& size)
void CanvasRendererTizen::MakeTargetBuffer(const Vector2& size)
{
+#ifdef THORVG_SUPPORT
mPixelBuffer = Devel::PixelBuffer::New(size.width, size.height, Dali::Pixel::RGBA8888);
unsigned char* pBuffer;
mTvgCanvas->sync();
mTvgCanvas->target(reinterpret_cast<uint32_t*>(pBuffer), size.width, size.width, size.height, tvg::SwCanvas::ABGR8888);
+#endif
}
} // namespace Adaptor
DrawableTizen::DrawableTizen()
: mAdded(false),
- mChanged(false),
+ mChanged(false)
+#ifdef THORVG_SUPPORT
+ ,
mTvgPaint(nullptr)
+#endif
{
}
DrawableTizen::~DrawableTizen()
{
+#ifdef THORVG_SUPPORT
if(mTvgPaint && !mAdded)
{
delete mTvgPaint;
}
+#endif
}
bool DrawableTizen::SetOpacity(float opacity)
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null [%p]\n", this);
}
SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
float DrawableTizen::GetOpacity() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null [%p]\n", this);
return 0;
}
return (float)mTvgPaint->opacity() / 255.f;
+#else
+ return 0;
+#endif
}
bool DrawableTizen::Rotate(Degree degree)
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null\n");
}
SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool DrawableTizen::Scale(float factor)
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null\n");
}
SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool DrawableTizen::Translate(Vector2 translate)
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null\n");
}
SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool DrawableTizen::Transform(const Dali::Matrix3& matrix)
{
+#ifdef THORVG_SUPPORT
if(!mTvgPaint)
{
DALI_LOG_ERROR("Drawable is null\n");
}
SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
void DrawableTizen::SetDrawableAdded(bool added)
void* DrawableTizen::GetObject() const
{
+#ifdef THORVG_SUPPORT
return static_cast<void*>(mTvgPaint);
+#else
+ return nullptr;
+#endif
}
void DrawableTizen::SetObject(const void* object)
{
+#ifdef THORVG_SUPPORT
if(object)
{
mTvgPaint = static_cast<tvg::Paint*>((void*)object);
delete mTvgPaint;
}
}
+#endif
}
void DrawableTizen::SetChanged(bool changed)
}
ShapeTizen::ShapeTizen()
+#ifdef THORVG_SUPPORT
: mTvgShape(nullptr)
+#endif
{
Initialize();
}
void ShapeTizen::Initialize()
{
+#ifdef THORVG_SUPPORT
mTvgShape = tvg::Shape::gen().release();
if(!mTvgShape)
{
Drawable::Create();
Drawable::SetObject(static_cast<void*>(mTvgShape));
+#endif
}
bool ShapeTizen::AddRect(Rect<float> rect, Vector2 roundedCorner)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null [%p]\n", this);
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::AddCircle(Vector2 center, Vector2 radius)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null [%p]\n", this);
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::AddMoveTo(Vector2 point)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::AddLineTo(Vector2 line)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::Close()
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
bool ShapeTizen::SetFillColor(Vector4 color)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null [%p]\n", this);
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Vector4 ShapeTizen::GetFillColor() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null [%p]\n", this);
return Vector4(0, 0, 0, 0);
}
return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+#else
+ return Vector4::ZERO;
+#endif
}
bool ShapeTizen::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Dali::CanvasRenderer::Shape::FillRule ShapeTizen::GetFillRule() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
tvg::FillRule rule = static_cast<tvg::Shape*>(mTvgShape)->fillRule();
return static_cast<Dali::CanvasRenderer::Shape::FillRule>(rule);
+#endif
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
}
bool ShapeTizen::SetStrokeWidth(float width)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
float ShapeTizen::GetStrokeWidth() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
return false;
}
return static_cast<tvg::Shape*>(mTvgShape)->strokeWidth();
+#else
+ return false;
+#endif
}
bool ShapeTizen::SetStrokeColor(Vector4 color)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Vector4 ShapeTizen::GetStrokeColor() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
return Vector4(0, 0, 0, 0);
}
return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+#else
+ return Vector4(0, 0, 0, 0);
+#endif
}
bool ShapeTizen::SetStrokeDash(const Dali::Vector<float> dashPattern)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Dali::Vector<float> ShapeTizen::GetStrokeDash() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
dashPattern.PushBack(tvgDashPattern[i]);
}
return dashPattern;
+#else
+ return Vector<float>();
+#endif
}
bool ShapeTizen::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Dali::CanvasRenderer::Shape::StrokeCap ShapeTizen::GetStrokeCap() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
tvg::StrokeCap cap = static_cast<tvg::Shape*>(mTvgShape)->strokeCap();
return static_cast<Dali::CanvasRenderer::Shape::StrokeCap>(cap);
+#endif
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
}
bool ShapeTizen::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
}
Drawable::SetChanged(true);
return true;
+#else
+ return false;
+#endif
}
Dali::CanvasRenderer::Shape::StrokeJoin ShapeTizen::GetStrokeJoin() const
{
+#ifdef THORVG_SUPPORT
if(!mTvgShape)
{
DALI_LOG_ERROR("Shape is null\n");
tvg::StrokeJoin join = static_cast<tvg::Shape*>(mTvgShape)->strokeJoin();
return static_cast<Dali::CanvasRenderer::Shape::StrokeJoin>(join);
+#endif
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
}
} // namespace Adaptor