1 #include "testCommon.h"
3 /************************************************************************/
5 /************************************************************************/
7 void tvgDrawCmds(tvg::Canvas* canvas)
12 auto shape1 = tvg::Shape::gen();
13 shape1->appendArc(150, 150, 80, 10, 180, false);
14 shape1->stroke(255, 255, 255, 255);
16 if (canvas->push(move(shape1)) != tvg::Result::Success) return;
18 auto shape2 = tvg::Shape::gen();
19 shape2->appendArc(400, 150, 80, 0, 300, false);
20 shape2->stroke(255, 255, 255, 255);
22 if (canvas->push(move(shape2)) != tvg::Result::Success) return;
24 auto shape3 = tvg::Shape::gen();
25 shape3->appendArc(600, 150, 80, 300, 60, false);
26 shape3->stroke(255, 255, 255, 255);
28 if (canvas->push(move(shape3)) != tvg::Result::Success) return;
31 auto shape4 = tvg::Shape::gen();
32 shape4->appendArc(150, 400, 80, 10, 180, true);
33 shape4->stroke(255, 255, 255, 255);
35 if (canvas->push(move(shape4)) != tvg::Result::Success) return;
37 auto shape5 = tvg::Shape::gen();
38 shape5->appendArc(400, 400, 80, 0, 300, true);
39 shape5->stroke(255, 255, 255, 255);
41 if (canvas->push(move(shape5)) != tvg::Result::Success) return;
43 auto shape6 = tvg::Shape::gen();
44 shape6->appendArc(600, 400, 80, 300, 60, true);
45 shape6->stroke(255, 255, 255, 255);
47 if (canvas->push(move(shape6)) != tvg::Result::Success) return;
50 auto shape7 = tvg::Shape::gen();
51 shape7->appendArc(150, 650, 80, 10, 180, true);
52 shape7->fill(255, 255, 255, 255);
53 shape7->stroke(255, 0, 0, 255);
55 if (canvas->push(move(shape7)) != tvg::Result::Success) return;
57 auto shape8 = tvg::Shape::gen();
58 shape8->appendArc(400, 650, 80, 0, 300, true);
59 shape8->fill(255, 255, 255, 255);
60 shape8->stroke(255, 0, 0, 255);
62 if (canvas->push(move(shape8)) != tvg::Result::Success) return;
64 auto shape9 = tvg::Shape::gen();
65 shape9->appendArc(600, 650, 80, 300, 60, true);
66 shape9->fill(255, 255, 255, 255);
67 shape9->stroke(255, 0, 0, 255);
69 if (canvas->push(move(shape9)) != tvg::Result::Success) return;
72 /************************************************************************/
73 /* Sw Engine Test Code */
74 /************************************************************************/
76 static unique_ptr<tvg::SwCanvas> swCanvas;
78 void tvgSwTest(uint32_t* buffer)
81 swCanvas = tvg::SwCanvas::gen();
82 swCanvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888);
84 /* Push the shape into the Canvas drawing list
85 When this shape is into the canvas list, the shape could update & prepare
86 internal data asynchronously for coming rendering.
87 Canvas keeps this shape node unless user call canvas->clear() */
88 tvgDrawCmds(swCanvas.get());
91 void drawSwView(void* data, Eo* obj)
93 if (swCanvas->draw() == tvg::Result::Success) {
99 /************************************************************************/
100 /* GL Engine Test Code */
101 /************************************************************************/
103 static unique_ptr<tvg::GlCanvas> glCanvas;
105 void initGLview(Evas_Object *obj)
107 static constexpr auto BPP = 4;
110 glCanvas = tvg::GlCanvas::gen();
111 glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT);
113 /* Push the shape into the Canvas drawing list
114 When this shape is into the canvas list, the shape could update & prepare
115 internal data asynchronously for coming rendering.
116 Canvas keeps this shape node unless user call canvas->clear() */
117 tvgDrawCmds(glCanvas.get());
120 void drawGLview(Evas_Object *obj)
122 auto gl = elm_glview_gl_api_get(obj);
123 gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
124 gl->glClear(GL_COLOR_BUFFER_BIT);
126 if (glCanvas->draw() == tvg::Result::Success) {
132 /************************************************************************/
134 /************************************************************************/
136 int main(int argc, char **argv)
138 tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
141 if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl;
144 //Initialize ThorVG Engine
145 if (tvgEngine == tvg::CanvasEngine::Sw) {
146 cout << "tvg engine: software" << endl;
148 cout << "tvg engine: opengl" << endl;
151 //Initialize ThorVG Engine
152 if (tvg::Initializer::init(tvgEngine) == tvg::Result::Success) {
154 elm_init(argc, argv);
156 if (tvgEngine == tvg::CanvasEngine::Sw) {
165 //Terminate ThorVG Engine
166 tvg::Initializer::term(tvgEngine);
169 cout << "engine is not supported" << endl;