1 #include "testCommon.h"
3 /************************************************************************/
5 /************************************************************************/
7 void tvgDrawCmds(tvg::Canvas* canvas)
11 //Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
12 auto shape1 = tvg::Shape::gen();
13 shape1->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry
14 shape1->appendRect(100, 100, 300, 300, 100, 100); //x, y, w, h, rx, ry
15 shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH
16 shape1->appendCircle(400, 500, 170, 100); //cx, cy, radiusW, radiusH
17 shape1->fill(255, 255, 0, 255); //r, g, b, a
19 canvas->push(move(shape1));
23 /************************************************************************/
24 /* Sw Engine Test Code */
25 /************************************************************************/
27 static unique_ptr<tvg::SwCanvas> swCanvas;
29 void tvgSwTest(uint32_t* buffer)
32 swCanvas = tvg::SwCanvas::gen();
33 swCanvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888);
35 /* Push the shape into the Canvas drawing list
36 When this shape is into the canvas list, the shape could update & prepare
37 internal data asynchronously for coming rendering.
38 Canvas keeps this shape node unless user call canvas->clear() */
39 tvgDrawCmds(swCanvas.get());
42 void drawSwView(void* data, Eo* obj)
44 if (swCanvas->draw() == tvg::Result::Success) {
50 /************************************************************************/
51 /* GL Engine Test Code */
52 /************************************************************************/
54 static unique_ptr<tvg::GlCanvas> glCanvas;
56 void initGLview(Evas_Object *obj)
58 static constexpr auto BPP = 4;
61 glCanvas = tvg::GlCanvas::gen();
62 glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT);
64 /* Push the shape into the Canvas drawing list
65 When this shape is into the canvas list, the shape could update & prepare
66 internal data asynchronously for coming rendering.
67 Canvas keeps this shape node unless user call canvas->clear() */
68 tvgDrawCmds(glCanvas.get());
71 void drawGLview(Evas_Object *obj)
73 auto gl = elm_glview_gl_api_get(obj);
74 gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
75 gl->glClear(GL_COLOR_BUFFER_BIT);
77 if (glCanvas->draw() == tvg::Result::Success) {
83 /************************************************************************/
85 /************************************************************************/
87 int main(int argc, char **argv)
89 tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
92 if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl;
95 //Initialize ThorVG Engine
96 if (tvgEngine == tvg::CanvasEngine::Sw) {
97 cout << "tvg engine: software" << endl;
99 cout << "tvg engine: opengl" << endl;
102 //Initialize ThorVG Engine
103 if (tvg::Initializer::init(tvgEngine) == tvg::Result::Success) {
105 elm_init(argc, argv);
107 if (tvgEngine == tvg::CanvasEngine::Sw) {
116 //Terminate ThorVG Engine
117 tvg::Initializer::term(tvgEngine);
120 cout << "engine is not supported" << endl;