3 /************************************************************************/
5 /************************************************************************/
7 static const char* svg = "<svg height=\"1000\" viewBox=\"0 0 1000 1000\" width=\"1000\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M1.171875.25H1004.687475V1005.6094H1.171875Z\" fill=\"#09bbf1\" stroke-width=\"3.910218\"/><g fill=\"#252f35\"><g stroke-width=\"3.864492\"><path d=\"M256.61221 100.51736H752.8963V386.99554H256.61221Z\"/><path d=\"M201.875 100.51736H238.366478V386.99554H201.875Z\"/><path d=\"M771.14203 100.51736H807.633508V386.99554H771.14203Z\"/></g><path d=\"M420.82388 380H588.68467V422.805317H420.82388Z\" stroke-width=\"3.227\"/><path d=\"m420.82403 440.7101v63.94623l167.86079 25.5782V440.7101Z\"/><path d=\"M420.82403 523.07258V673.47362L588.68482 612.59701V548.13942Z\"/></g><g fill=\"#222f35\"><path d=\"M420.82403 691.37851 588.68482 630.5019 589 834H421Z\"/><path d=\"m420.82403 852.52249h167.86079v28.64782H420.82403v-28.64782 0 0\"/><path d=\"m439.06977 879.17031c0 0-14.90282 8.49429-18.24574 15.8161-4.3792 9.59153 0 31.63185 0 31.63185h167.86079c0 0 4.3792-22.04032 0-31.63185-3.34292-7.32181-18.24574-15.8161-18.24574-15.8161z\"/></g><path d=\"m280 140h15v55l8 10 8-10v-55h15v60l-23 25-23-25z\" fill=\"#09bbf1\"/><path d=\"m335 140v80h45v-50h-25v10h10v30h-15v-57h18v-13z\" fill=\"#09bbf1\"/></svg>";
10 void tvgDrawCmds(tvg::Canvas* canvas)
15 auto shape = tvg::Shape::gen();
16 shape->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry
17 shape->fill(255, 255, 255, 255); //r, g, b, a
19 if (canvas->push(move(shape)) != tvg::Result::Success) return;
21 auto picture = tvg::Picture::gen();
22 if (picture->load(svg, strlen(svg)) != tvg::Result::Success) return;
25 picture->viewbox(&x, &y, &w, &h);
27 float rate = (WIDTH/(w > h ? w : h));
37 y -= (WIDTH - h) * 0.5f;
39 x -= (WIDTH - w) * 0.5f;
42 picture->translate(-x, -y);
44 canvas->push(move(picture));
48 /************************************************************************/
49 /* Sw Engine Test Code */
50 /************************************************************************/
52 static unique_ptr<tvg::SwCanvas> swCanvas;
54 void tvgSwTest(uint32_t* buffer)
57 swCanvas = tvg::SwCanvas::gen();
58 swCanvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888);
60 /* Push the shape into the Canvas drawing list
61 When this shape is into the canvas list, the shape could update & prepare
62 internal data asynchronously for coming rendering.
63 Canvas keeps this shape node unless user call canvas->clear() */
64 tvgDrawCmds(swCanvas.get());
67 void drawSwView(void* data, Eo* obj)
69 if (swCanvas->draw() == tvg::Result::Success) {
75 /************************************************************************/
76 /* GL Engine Test Code */
77 /************************************************************************/
79 static unique_ptr<tvg::GlCanvas> glCanvas;
81 void initGLview(Evas_Object *obj)
83 static constexpr auto BPP = 4;
86 glCanvas = tvg::GlCanvas::gen();
87 glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT);
89 /* Push the shape into the Canvas drawing list
90 When this shape is into the canvas list, the shape could update & prepare
91 internal data asynchronously for coming rendering.
92 Canvas keeps this shape node unless user call canvas->clear() */
93 tvgDrawCmds(glCanvas.get());
96 void drawGLview(Evas_Object *obj)
98 auto gl = elm_glview_gl_api_get(obj);
99 gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
100 gl->glClear(GL_COLOR_BUFFER_BIT);
102 if (glCanvas->draw() == tvg::Result::Success) {
108 /************************************************************************/
110 /************************************************************************/
112 int main(int argc, char **argv)
114 tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
117 if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl;
120 //Initialize ThorVG Engine
121 if (tvgEngine == tvg::CanvasEngine::Sw) {
122 cout << "tvg engine: software" << endl;
124 cout << "tvg engine: opengl" << endl;
128 auto threads = std::thread::hardware_concurrency();
130 //Initialize ThorVG Engine
131 if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) {
133 elm_init(argc, argv);
135 if (tvgEngine == tvg::CanvasEngine::Sw) {
144 //Terminate ThorVG Engine
145 tvg::Initializer::term(tvg::CanvasEngine::Sw);
148 cout << "engine is not supported" << endl;