diff --git a/inc/tizenvg.h b/inc/tizenvg.h index a8597ad9..cc334e0b 100644 --- a/inc/tizenvg.h +++ b/inc/tizenvg.h @@ -25,13 +25,146 @@ #define TIZENVG_EXPORT #endif +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZENVG" + + #ifdef __cplusplus extern "C" { #endif -namespace tizenvg +#define _TIZENVG_DECLARE_PRIVATE(A) \ +private: \ + struct Impl; \ + std::unique_ptr pImpl; \ + A(const A&) = delete; \ + const A& operator=(const A&) = delete; \ + A() + +#define _TIZENVG_DISABLE_CTOR(A) \ + A() = delete; \ + ~A() = delete + +namespace tvg { +class SceneNode; + + +/** + * @class PaintNode + * + * @ingroup TizenVG + * + * @brief description... + * + */ +class TIZENVG_EXPORT PaintNode +{ +public: + virtual ~PaintNode() {} + virtual int prepare() = 0; +}; + + +/** + * @class ShapeNode + * + * @ingroup TizenVG + * + * @brief description... + * + */ +class TIZENVG_EXPORT ShapeNode final : public PaintNode +{ +public: + ~ShapeNode(); + + int prepare() noexcept override; + + static std::unique_ptr gen(); + + _TIZENVG_DECLARE_PRIVATE(ShapeNode); +}; + + +/** + * @class SceneNode + * + * @ingroup TizenVG + * + * @brief description... + * + */ +class TIZENVG_EXPORT SceneNode final : public PaintNode +{ +public: + ~SceneNode(); + + int push(std::unique_ptr shape) noexcept; + int prepare() noexcept override; + + static std::unique_ptr gen() noexcept; + + _TIZENVG_DECLARE_PRIVATE(SceneNode); +}; + + +/** + * @class SwCanvas + * + * @ingroup TizenVG + * + @brief description... + * + */ +class TIZENVG_EXPORT SwCanvas final +{ +public: + ~SwCanvas(); + + int push(std::unique_ptr paint) noexcept; + int clear() noexcept; + + int draw(bool async = true) noexcept; + int drawSync() noexcept; + + int target(uint32_t* buffer, size_t stride, size_t height) noexcept; + + static std::unique_ptr gen(uint32_t* buffer = nullptr, size_t stride = 0, size_t height = 0) noexcept; + + _TIZENVG_DECLARE_PRIVATE(SwCanvas); +}; + + +/** + * @class GlCanvas + * + * @ingroup TizenVG + * + * @brief description... + * + */ +class TIZENVG_EXPORT GlCanvas final +{ +public: + ~GlCanvas(); + + int push(std::unique_ptr paint) noexcept; + int clear() noexcept; + + //TODO: Gl Specific methods. Need gl backend configuration methods as well. + int draw(bool async = true) noexcept { return 0; } + int drawSync() noexcept { return 0; } + + static std::unique_ptr gen() noexcept; + + _TIZENVG_DECLARE_PRIVATE(GlCanvas); +}; + + /** * @class Engine * @@ -56,6 +189,8 @@ public: */ static int init() noexcept; static int term() noexcept; + + _TIZENVG_DISABLE_CTOR(Engine); }; } //namespace diff --git a/src/lib/meson.build b/src/lib/meson.build index 1facacb6..fb856bf0 100644 --- a/src/lib/meson.build +++ b/src/lib/meson.build @@ -1,5 +1,11 @@ source_file = [ - 'TvgEngine.cpp' + 'tvgCommon.h', + 'tvgEngine.cpp', + 'tvgCanvasBase.h', + 'tvgSwCanvas.cpp', + 'tvgGlCanvas.cpp', + 'tvgSceneNode.cpp', + 'tvgShapeNode.cpp' ] src_dep = declare_dependency( diff --git a/src/lib/tvgCanvasBase.h b/src/lib/tvgCanvasBase.h new file mode 100644 index 00000000..83607bf4 --- /dev/null +++ b/src/lib/tvgCanvasBase.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_CANVAS_CPP_ +#define _TVG_CANVAS_CPP_ + +#include "tvgCommon.h" + +/************************************************************************/ +/* Internal Class Implementation */ +/************************************************************************/ + +struct CanvasBase +{ + + int push(unique_ptr paint) + { + return 0; + } + + int clear() + { + return 0; + } + +}; + + +/************************************************************************/ +/* External Class Implementation */ +/************************************************************************/ + +#endif /* _TVG_CANVAS_CPP_ */ diff --git a/src/lib/tvgCommon.h b/src/lib/tvgCommon.h new file mode 100644 index 00000000..f69af00f --- /dev/null +++ b/src/lib/tvgCommon.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_COMMON_H_ +#define _TVG_COMMON_H_ + +#include +#include +#include +#include "tizenvg.h" + +using namespace std; +using namespace tvg; +using var = float; + +#endif //_TVG_COMMON_H_ diff --git a/src/lib/TvgEngine.cpp b/src/lib/tvgEngine.cpp similarity index 79% rename from src/lib/TvgEngine.cpp rename to src/lib/tvgEngine.cpp index 08f6bc15..838f4ca8 100644 --- a/src/lib/TvgEngine.cpp +++ b/src/lib/tvgEngine.cpp @@ -17,32 +17,12 @@ #ifndef _TVG_ENGINE_CPP_ #define _TVG_ENGINE_CPP_ -#include -#include -#include "tizenvg.h" - -using namespace std; -using namespace tizenvg; +#include "tvgCommon.h" /************************************************************************/ /* Internal Class Implementation */ /************************************************************************/ -namespace tizenvg -{ -class EngineImpl -{ - public: - static int init() { - return 0; - } - - static int term() { - return 0; - } -}; - -} /************************************************************************/ /* External Class Implementation */ @@ -50,12 +30,13 @@ class EngineImpl int Engine::init() noexcept { - return EngineImpl::init(); + return 0; } + int Engine::term() noexcept { - return EngineImpl::term(); + return 0; } #endif /* _TVG_ENGINE_CPP_ */ diff --git a/src/lib/tvgGlCanvas.cpp b/src/lib/tvgGlCanvas.cpp new file mode 100644 index 00000000..573600eb --- /dev/null +++ b/src/lib/tvgGlCanvas.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_GLCANVAS_CPP_ +#define _TVG_GLCANVAS_CPP_ + +#include "tvgCommon.h" +#include "tvgCanvasBase.h" + +/************************************************************************/ +/* Internal Class Implementation */ +/************************************************************************/ + +struct GlCanvas::Impl : CanvasBase +{ + //... +}; + + +/************************************************************************/ +/* External Class Implementation */ +/************************************************************************/ + +GlCanvas::GlCanvas() : pImpl(make_unique()) +{ +} + + +GlCanvas::~GlCanvas() +{ + cout << "GlCanvas(" << this << ") destroyed!" << endl; +} + + +unique_ptr GlCanvas::gen() noexcept +{ + auto canvas = unique_ptr(new GlCanvas); + assert(canvas); + + return canvas; +} + + +int GlCanvas::push(unique_ptr paint) noexcept +{ + auto impl = pImpl.get(); + assert(impl); + return impl->push(move(paint)); +} + +int GlCanvas::clear() noexcept +{ + auto impl = pImpl.get(); + assert(impl); + return impl->clear(); +} + +#endif /* _TVG_GLCANVAS_CPP_ */ diff --git a/src/lib/tvgSceneNode.cpp b/src/lib/tvgSceneNode.cpp new file mode 100644 index 00000000..8da41fca --- /dev/null +++ b/src/lib/tvgSceneNode.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_SCENE_NODE_CPP_ +#define _TVG_SCENE_NODE_CPP_ + +#include "tvgCommon.h" + +/************************************************************************/ +/* Internal Class Implementation */ +/************************************************************************/ + +struct SceneNode::Impl +{ + +}; + + + +/************************************************************************/ +/* External Class Implementation */ +/************************************************************************/ + +SceneNode :: SceneNode() : pImpl(make_unique()) +{ + +} + + +SceneNode :: ~SceneNode() +{ + cout << "SceneNode(" << this << ") destroyed!" << endl; +} + + +unique_ptr SceneNode::gen() noexcept +{ + return unique_ptr(new SceneNode); +} + +int SceneNode :: push(unique_ptr shape) noexcept +{ + return 0; +} + + +int SceneNode :: prepare() noexcept +{ + + return 0; +} + +#endif /* _TVG_SCENE_NODE_CPP_ */ diff --git a/src/lib/tvgShapeNode.cpp b/src/lib/tvgShapeNode.cpp new file mode 100644 index 00000000..4fb4b107 --- /dev/null +++ b/src/lib/tvgShapeNode.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_SHAPE_NODE_CPP_ +#define _TVG_SHAPE_NODE_CPP_ + +#include "tvgCommon.h" + +/************************************************************************/ +/* Internal Class Implementation */ +/************************************************************************/ + +struct ShapeFill +{ +}; + + +struct ShapeStroke +{ +}; + + +struct ShapePath +{ +}; + + +struct ShapeTransform +{ + var e[4*4]; +}; + + +struct ShapeChildren +{ + vector> v; +}; + + +struct ShapeNode::Impl +{ + ShapeChildren *children = nullptr; + ShapeTransform *transform = nullptr; + ShapeFill *fill = nullptr; + ShapeStroke *stroke = nullptr; + ShapePath *path = nullptr; + uint32_t color = 0; + uint32_t id = 0; + + + ~Impl() + { + if (path) delete(path); + if (stroke) delete(stroke); + if (fill) delete(fill); + if (transform) delete(transform); + if (children) delete(children); + } + +}; + + +/************************************************************************/ +/* External Class Implementation */ +/************************************************************************/ + +ShapeNode :: ShapeNode() : pImpl(make_unique()) +{ + +} + + +ShapeNode :: ~ShapeNode() +{ + cout << "ShapeNode(" << this << ") destroyed!" << endl; +} + + +unique_ptr ShapeNode::gen() +{ + return unique_ptr(new ShapeNode); +} + + +int ShapeNode :: prepare() noexcept +{ + return 0; +} + + +#endif //_TVG_SHAPE_NODE_CPP_ diff --git a/src/lib/tvgSwCanvas.cpp b/src/lib/tvgSwCanvas.cpp new file mode 100644 index 00000000..05296cdb --- /dev/null +++ b/src/lib/tvgSwCanvas.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ +#ifndef _TVG_SWCANVAS_CPP_ +#define _TVG_SWCANVAS_CPP_ + +#include "tvgCommon.h" +#include "tvgCanvasBase.h" + +/************************************************************************/ +/* Internal Class Implementation */ +/************************************************************************/ + +struct SwCanvas::Impl : CanvasBase +{ + uint32_t* buffer = nullptr; + int stride = 0; + int height = 0; +}; + + +/************************************************************************/ +/* External Class Implementation */ +/************************************************************************/ + +int SwCanvas::target(uint32_t* buffer, size_t stride, size_t height) noexcept +{ + auto impl = pImpl.get(); + assert(impl); + + impl->buffer = buffer; + impl->stride = stride; + impl->height = height; + + return 0; +} + + +int SwCanvas::draw(bool async) noexcept +{ + return 0; +} + + +int SwCanvas::drawSync() noexcept +{ + return 0; +} + + +int SwCanvas::push(unique_ptr paint) noexcept +{ + auto impl = pImpl.get(); + assert(impl); + return impl->push(move(paint)); +} + + +int SwCanvas::clear() noexcept +{ + auto impl = pImpl.get(); + assert(impl); + return impl->clear(); +} + + +SwCanvas::SwCanvas() : pImpl(make_unique()) +{ +} + + +SwCanvas::~SwCanvas() +{ + cout << "SwCanvas(" << this << ") destroyed!" << endl; +} + + +unique_ptr SwCanvas::gen(uint32_t* buffer, size_t stride, size_t height) noexcept +{ + auto canvas = unique_ptr(new SwCanvas); + assert(canvas); + + int ret = canvas.get()->target(buffer, stride, height); + if (ret > 0) return nullptr; + + return canvas; +} + +#endif /* _TVG_SWCANVAS_CPP_ */ diff --git a/test/makefile b/test/makefile index 4dc91353..0f89da04 100644 --- a/test/makefile +++ b/test/makefile @@ -1,2 +1,2 @@ all: - gcc -o test test.cpp -g -lstdc++ `pkg-config --cflags --libs tizenvg` + gcc -o tvgDrawShape tvgDrawShape.cpp -g -lstdc++ `pkg-config --cflags --libs tizenvg` diff --git a/test/test.cpp b/test/test.cpp deleted file mode 100644 index 6c953586..00000000 --- a/test/test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -using namespace std; - -int main(int argc, char **argv) -{ - tizenvg::Engine::init(); - - //... - - tizenvg::Engine::term(); -} diff --git a/test/tvgDrawShape.cpp b/test/tvgDrawShape.cpp new file mode 100644 index 00000000..34f4dc9e --- /dev/null +++ b/test/tvgDrawShape.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Prepare a Shape + auto shape1 = tvg::ShapeNode::gen(); + shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius + shape1->fill(0, 255, 0, 255); + + //Draw the Shape onto the Canvas + canvas->push(move(shape1)); + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgGradient.cpp b/test/tvgGradient.cpp new file mode 100644 index 00000000..2bf2824a --- /dev/null +++ b/test/tvgGradient.cpp @@ -0,0 +1,55 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Prepare a Shape + auto shape1 = tvg::ShapeNode::gen(); + shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius + + //Linear Gradient Fill + auto fill1 = tvg::LinearFill::gen(); + fill1->range(fill1, 0, 0, 400, 400); //from(x, y), to(x, y) + fill1->color(0, 255, 0, 0, 255); //color Stop 0: Red + fill1->color(0.5, 0, 255, 0, 255); //color Stop 1: Green + fill1->color(1, 0, 0, 255, 255); //color Stop 2: Blue + shape1.fill(fill1); + + //Draw the Shape onto the Canvas + canvas->push(move(shape1)); + + //Prepare Circle + auto shape2 = tvg::ShapeNode::gen(); + shape2->circle(400, 400, 200); //cx, cy, radius + shape2->fill(255, 255, 0, 255); //r, g, b, a + canvas->push(move(shape2)); + + //Radial Gradient Fill + auto fill2 = tvg::RadialFill::gen(); + fill2->range(400, 400, 200); //center(x, y), radius + fill2->color(0, 255, 0, 0, 255); //color Stop 0: Red + fill2->color(0.5, 0, 255, 0, 255); //color Stop 1: Green + fill2->color(1, 0, 0, 255, 255); //color Stop 2: Blue + shape2.fill(fill2); + + //Draw the Shape onto the Canvas + canvas->push(move(shape2)); + + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgMultipleShapes.cpp b/test/tvgMultipleShapes.cpp new file mode 100644 index 00000000..fd7ea818 --- /dev/null +++ b/test/tvgMultipleShapes.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Prepare Rectangle + auto shape1 = tvg::ShapeNode::gen(); + shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius + shape1->fill(0, 255, 0, 255); //r, g, b, a + canvas->push(move(shape1)); + + //Prepare Circle + auto shape2 = tvg::ShapeNode::gen(); + shape2->circle(400, 400, 200); //cx, cy, radius + shape2->fill(255, 255, 0, 255); //r, g, b, a + canvas->push(move(shape2)); + + //Draw the Shapes onto the Canvas + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgPath.cpp b/test/tvgPath.cpp new file mode 100644 index 00000000..68f0998f --- /dev/null +++ b/test/tvgPath.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Prepare Path + auto path = tvg::Path::gen(); + path.reserve(cmdCnt, ptCnt); //command count, points count + path.moveTo(...); + path.lineTo(...); + path.cubicTo(...); + path.close(); + + //Prepare a Shape + auto shape1 = tvg::ShapeNode::gen(); + shape1->path(move(path)); //propagate owner + shape1->path(path.get()); //copy data directly + shape1->fill(0, 255, 0, 255); + + //Draw the Shape onto the Canvas + canvas->push(move(shape1)); + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgScene.cpp b/test/tvgScene.cpp new file mode 100644 index 00000000..56a9a6c1 --- /dev/null +++ b/test/tvgScene.cpp @@ -0,0 +1,49 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Create a Scene + auto scene = tvg::SceneNode::gen(3); //reserve 3 shape nodes (optional) + + //Shape1 + auto shape1 = tvg::ShapeNode::gen(); + shape1->rect(0, 0, 400, 400, 0.1); + shape1->fill(255, 0, 0, 255); + shape1->rotate(0, 0, 45); //axis x, y, z + scene->push(move(shape1)); + + //Shape2 + auto shape2 = tvg::ShapeNode::gen(); + shape2->rect(0, 0, 400, 400, 0.1); + shape2->fill(0, 255, 0, 255); + shape2->transform(matrix); //by matrix (var matrix[4 * 4];) + scene->push(move(shape2)); + + //Shape3 + auto shape3 = tvg::ShapeNode::gen(); + shape3->rect(0, 0, 400, 400, 0.1); + shape3->fill(0, 0, 255, 255); + shape3->origin(100, 100); //offset + scene->push(move(shape3)); + + //Draw the Scene onto the Canvas + canvas->push(move(scene)); + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgStroke.cpp b/test/tvgStroke.cpp new file mode 100644 index 00000000..6b90cda4 --- /dev/null +++ b/test/tvgStroke.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Prepare a Shape + auto shape1 = tvg::ShapeNode::gen(); + shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius + shape1->fill(0, 255, 0, 255); + + //Stroke Style + shape1->strokeColor(0, 0, 0, 255); //r, g, b, a + shape1->strokeWidth(1); //1px + shape1->strokeJoin(tvg::StrokeJoin::Miter); + shape1->strokeLineCap(tvg::StrokeLineCap::Butt); + + uint32_t dash[] = {3, 1, 5, 1}; + shape1->strokeDash(dash, 4); + + //Draw the Shape onto the Canvas + canvas->push(move(shape1)); + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +} diff --git a/test/tvgUpdate.cpp b/test/tvgUpdate.cpp new file mode 100644 index 00000000..5bef2b93 --- /dev/null +++ b/test/tvgUpdate.cpp @@ -0,0 +1,49 @@ +#include + +using namespace std; + +#define WIDTH 800 +#define HEIGHT 800 + +static uint32_t buffer[WIDTH * HEIGHT]; + +int main(int argc, char **argv) +{ + //Initialize TizenVG Engine + tvg::Engine::init(); + + //Create a Canvas + auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT); + + //Create a Scene + auto scene = tvg::SceneNode::gen(); + + //Shape1 + auto shape1 = tvg::ShapeNode::gen(); + auto pshape1 = shape1->get(); //acquire shape1 pointer to access directly + shape1->rect(0, 0, 400, 400, 0.1); + shape1->fill(255, 0, 0, 255); + shape1->rotate(0, 0, 45); //axis x, y, z + scene->push(move(shape1)); + + //Draw the Scene onto the Canvas + canvas->push(move(scene)); + + //Draw frame 1 + canvas->draw(); + canvas->sync(); + + //Clear previous shape path + pshape1->clear(); + pshape1->rect(0, 0, 300, 300, 0.1); + + //Prepapre for drawing + pshape1->update(); + + //Draw frame 2 + canvas->draw(); + canvas->sync(); + + //Terminate TizenVG Engine + tvg::Engine::term(); +}