build up base infra code for prototype. 15/228715/7
authorHermet Park <chuneon.park@samsung.com>
Wed, 25 Mar 2020 04:54:29 +0000 (13:54 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 30 Mar 2020 07:36:13 +0000 (16:36 +0900)
Change-Id: I117a798caf4d9fedfe5c467471dee2f0150c2630

18 files changed:
inc/tizenvg.h
src/lib/meson.build
src/lib/tvgCanvasBase.h [new file with mode: 0644]
src/lib/tvgCommon.h [new file with mode: 0644]
src/lib/tvgEngine.cpp [moved from src/lib/TvgEngine.cpp with 79% similarity]
src/lib/tvgGlCanvas.cpp [new file with mode: 0644]
src/lib/tvgSceneNode.cpp [new file with mode: 0644]
src/lib/tvgShapeNode.cpp [new file with mode: 0644]
src/lib/tvgSwCanvas.cpp [new file with mode: 0644]
test/makefile
test/test.cpp [deleted file]
test/tvgDrawShape.cpp [new file with mode: 0644]
test/tvgGradient.cpp [new file with mode: 0644]
test/tvgMultipleShapes.cpp [new file with mode: 0644]
test/tvgPath.cpp [new file with mode: 0644]
test/tvgScene.cpp [new file with mode: 0644]
test/tvgStroke.cpp [new file with mode: 0644]
test/tvgUpdate.cpp [new file with mode: 0644]

index a8597ad..cc334e0 100644 (file)
     #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<Impl> 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<ShapeNode> 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<ShapeNode> shape) noexcept;
+    int prepare() noexcept override;
+
+    static std::unique_ptr<SceneNode> gen() noexcept;
+
+    _TIZENVG_DECLARE_PRIVATE(SceneNode);
+};
+
+
+/**
+ * @class SwCanvas
+ *
+ * @ingroup TizenVG
+ *
+  @brief description...
+ *
+ */
+class TIZENVG_EXPORT SwCanvas final
 {
+public:
+    ~SwCanvas();
+
+    int push(std::unique_ptr<PaintNode> 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<SwCanvas> 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<PaintNode> 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<GlCanvas> 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
index 1facacb..fb856bf 100644 (file)
@@ -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 (file)
index 0000000..83607bf
--- /dev/null
@@ -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<PaintNode> 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 (file)
index 0000000..f69af00
--- /dev/null
@@ -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 <iostream>
+#include <cassert>
+#include <vector>
+#include "tizenvg.h"
+
+using namespace std;
+using namespace tvg;
+using var = float;
+
+#endif //_TVG_COMMON_H_
similarity index 79%
rename from src/lib/TvgEngine.cpp
rename to src/lib/tvgEngine.cpp
index 08f6bc1..838f4ca 100644 (file)
 #ifndef _TVG_ENGINE_CPP_
 #define _TVG_ENGINE_CPP_
 
-#include <iostream>
-#include <cassert>
-#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 (file)
index 0000000..573600e
--- /dev/null
@@ -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<Impl>())
+{
+}
+
+
+GlCanvas::~GlCanvas()
+{
+   cout << "GlCanvas(" << this << ") destroyed!" << endl;
+}
+
+
+unique_ptr<GlCanvas> GlCanvas::gen() noexcept
+{
+    auto canvas = unique_ptr<GlCanvas>(new GlCanvas);
+    assert(canvas);
+
+    return canvas;
+}
+
+
+int GlCanvas::push(unique_ptr<PaintNode> 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 (file)
index 0000000..8da41fc
--- /dev/null
@@ -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<Impl>())
+{
+
+}
+
+
+SceneNode :: ~SceneNode()
+{
+    cout << "SceneNode(" << this << ") destroyed!" << endl;
+}
+
+
+unique_ptr<SceneNode> SceneNode::gen() noexcept
+{
+    return unique_ptr<SceneNode>(new SceneNode);
+}
+
+int SceneNode :: push(unique_ptr<ShapeNode> 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 (file)
index 0000000..4fb4b10
--- /dev/null
@@ -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<unique_ptr<ShapeNode>> 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<Impl>())
+{
+
+}
+
+
+ShapeNode :: ~ShapeNode()
+{
+    cout << "ShapeNode(" << this << ") destroyed!" << endl;
+}
+
+
+unique_ptr<ShapeNode> ShapeNode::gen()
+{
+    return unique_ptr<ShapeNode>(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 (file)
index 0000000..05296cd
--- /dev/null
@@ -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<PaintNode> 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<Impl>())
+{
+}
+
+
+SwCanvas::~SwCanvas()
+{
+   cout << "SwCanvas(" << this << ") destroyed!" << endl;
+}
+
+
+unique_ptr<SwCanvas> SwCanvas::gen(uint32_t* buffer, size_t stride, size_t height) noexcept
+{
+    auto canvas = unique_ptr<SwCanvas>(new SwCanvas);
+    assert(canvas);
+
+    int ret = canvas.get()->target(buffer, stride, height);
+    if (ret > 0)  return nullptr;
+
+   return canvas;
+}
+
+#endif /* _TVG_SWCANVAS_CPP_ */
index 4dc9135..0f89da0 100644 (file)
@@ -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 (file)
index 6c95358..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <tizenvg.h>
-
-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 (file)
index 0000000..34f4dc9
--- /dev/null
@@ -0,0 +1,30 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..2bf2824
--- /dev/null
@@ -0,0 +1,55 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..fd7ea81
--- /dev/null
@@ -0,0 +1,36 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..68f0998
--- /dev/null
@@ -0,0 +1,39 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..56a9a6c
--- /dev/null
@@ -0,0 +1,49 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..6b90cda
--- /dev/null
@@ -0,0 +1,39 @@
+#include <tizenvg.h>
+
+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 (file)
index 0000000..5bef2b9
--- /dev/null
@@ -0,0 +1,49 @@
+#include <tizenvg.h>
+
+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();
+}