sw_engine: threading optimization
[platform/core/graphics/tizenvg.git] / test / testShape.cpp
1 #include <tizenvg.h>
2 #include <Elementary.h>
3
4 using namespace std;
5
6 #define WIDTH 800
7 #define HEIGHT 800
8
9 static uint32_t buffer[WIDTH * HEIGHT];
10
11 void tvgtest()
12 {
13     //Initialize TizenVG Engine
14     tvg::Initializer::init(tvg::CanvasEngine::Sw);
15
16     //Create a Canvas
17     auto canvas = tvg::SwCanvas::gen();
18     canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
19
20     //Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
21     auto shape1 = tvg::Shape::gen();
22     shape1->appendRect(0, 0, 200, 200, 0);          //x, y, w, h, cornerRadius
23     shape1->appendRect(100, 100, 300, 300, 100);    //x, y, w, h, cornerRadius
24     shape1->appendCircle(400, 400, 100, 100);       //cx, cy, radiusW, radiusH
25     shape1->appendCircle(400, 500, 170, 100);       //cx, cy, radiusW, radiusH
26     shape1->fill(255, 255, 0, 255);                 //r, g, b, a
27
28     /* Push the shape into the Canvas drawing list
29        When this shape is into the canvas list, the shape could update & prepare
30        internal data asynchronously for coming rendering.
31        Canvas keeps this shape node unless user call canvas->clear() */
32     canvas->push(move(shape1));
33
34     canvas->draw();
35     canvas->sync();
36
37     //Terminate TizenVG Engine
38     tvg::Initializer::term(tvg::CanvasEngine::Sw);
39 }
40
41 void win_del(void *data, Evas_Object *o, void *ev)
42 {
43    elm_exit();
44 }
45
46
47 int main(int argc, char **argv)
48 {
49     tvgtest();
50
51     //Show the result using EFL...
52     elm_init(argc, argv);
53
54     Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
55     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
56
57     Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
58     evas_object_image_size_set(img, WIDTH, HEIGHT);
59     evas_object_image_data_set(img, buffer);
60     evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61     evas_object_show(img);
62
63     elm_win_resize_object_add(win, img);
64     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
65     evas_object_show(win);
66
67     elm_run();
68     elm_shutdown();
69 }