1 #include "testCommon.h"
3 /************************************************************************/
5 /************************************************************************/
7 void tvgDrawCmds(tvg::Canvas* canvas)
9 //Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
10 auto shape1 = tvg::Shape::gen();
11 shape1->appendRect(0, 0, 200, 200, 0, 0); //x, y, w, h, rx, ry
12 shape1->appendRect(100, 100, 300, 300, 100, 100); //x, y, w, h, rx, ry
13 shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH
14 shape1->appendCircle(400, 500, 170, 100); //cx, cy, radiusW, radiusH
15 shape1->fill(255, 255, 0, 255); //r, g, b, a
17 canvas->push(move(shape1));
21 /************************************************************************/
22 /* Sw Engine Test Code */
23 /************************************************************************/
25 static unique_ptr<tvg::SwCanvas> swCanvas;
27 void tvgSwTest(uint32_t* buffer)
30 swCanvas = tvg::SwCanvas::gen();
31 swCanvas->target(buffer, WIDTH, WIDTH, HEIGHT);
33 /* Push the shape into the Canvas drawing list
34 When this shape is into the canvas list, the shape could update & prepare
35 internal data asynchronously for coming rendering.
36 Canvas keeps this shape node unless user call canvas->clear() */
37 tvgDrawCmds(swCanvas.get());
40 void drawSwView(void* data, Eo* obj)
42 if (swCanvas->draw() == tvg::Result::Success) {
48 /************************************************************************/
49 /* GL Engine Test Code */
50 /************************************************************************/
52 static unique_ptr<tvg::GlCanvas> glCanvas;
54 void initGLview(Evas_Object *obj)
56 static constexpr auto BPP = 4;
59 glCanvas = tvg::GlCanvas::gen();
60 glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT);
62 /* Push the shape into the Canvas drawing list
63 When this shape is into the canvas list, the shape could update & prepare
64 internal data asynchronously for coming rendering.
65 Canvas keeps this shape node unless user call canvas->clear() */
66 tvgDrawCmds(glCanvas.get());
69 void drawGLview(Evas_Object *obj)
71 auto gl = elm_glview_gl_api_get(obj);
72 gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
73 gl->glClear(GL_COLOR_BUFFER_BIT);
75 if (glCanvas->draw() == tvg::Result::Success) {
81 /************************************************************************/
83 /************************************************************************/
85 int main(int argc, char **argv)
87 tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
90 if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl;
93 //Initialize ThorVG Engine
94 if (tvgEngine == tvg::CanvasEngine::Sw) {
95 cout << "tvg engine: software" << endl;
97 cout << "tvg engine: opengl" << endl;
100 //Initialize ThorVG Engine
101 if (tvg::Initializer::init(tvgEngine) == tvg::Result::Success) {
103 elm_init(argc, argv);
105 if (tvgEngine == tvg::CanvasEngine::Sw) {
114 //Terminate ThorVG Engine
115 tvg::Initializer::term(tvgEngine);
118 cout << "engine is not supported" << endl;