sw_engine: threading optimization
[platform/core/graphics/tizenvg.git] / test / testStroke.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
12 void tvgtest()
13 {
14     //Initialize TizenVG Engine
15     tvg::Initializer::init(tvg::CanvasEngine::Sw);
16
17     //Create a Canvas
18     auto canvas = tvg::SwCanvas::gen();
19     canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
20
21     //Shape 1
22     auto shape1 = tvg::Shape::gen();
23     shape1->appendRect(50, 50, 200, 200, 0);
24     shape1->fill(50, 50, 50, 255);
25     shape1->stroke(255, 255, 255, 255);       //color: r, g, b, a
26     shape1->stroke(tvg::StrokeJoin::Bevel);   //default is Bevel
27     shape1->stroke(10);                       //width: 10px
28
29     canvas->push(move(shape1));
30
31     //Shape 2
32     auto shape2 = tvg::Shape::gen();
33     shape2->appendRect(300, 50, 200, 200, 0);
34     shape2->fill(50, 50, 50, 255);
35     shape2->stroke(255, 255, 255, 255);
36     shape2->stroke(tvg::StrokeJoin::Round);
37     shape2->stroke(10);
38
39     canvas->push(move(shape2));
40
41     //Shape 3
42     auto shape3 = tvg::Shape::gen();
43     shape3->appendRect(550, 50, 200, 200, 0);
44     shape3->fill(50, 50, 50, 255);
45     shape3->stroke(255, 255, 255, 255);
46     shape3->stroke(tvg::StrokeJoin::Miter);
47     shape3->stroke(10);
48
49     canvas->push(move(shape3));
50
51     //Shape 4
52     auto shape4 = tvg::Shape::gen();
53     shape4->appendCircle(150, 450, 100, 100);
54     shape4->fill(50, 50, 50, 255);
55     shape4->stroke(255, 255, 255, 255);
56     shape4->stroke(1);
57
58     canvas->push(move(shape4));
59
60     //Shape 5
61     auto shape5 = tvg::Shape::gen();
62     shape5->appendCircle(400, 450, 100, 100);
63     shape5->fill(50, 50, 50, 255);
64     shape5->stroke(255, 255, 255, 255);
65     shape5->stroke(2);
66
67     canvas->push(move(shape5));
68
69     //Shape 6
70     auto shape6 = tvg::Shape::gen();
71     shape6->appendCircle(650, 450, 100, 100);
72     shape6->fill(50, 50, 50, 255);
73     shape6->stroke(255, 255, 255, 255);
74     shape6->stroke(4);
75
76     canvas->push(move(shape6));
77
78
79     canvas->draw();
80     canvas->sync();
81
82     //Terminate TizenVG Engine
83     tvg::Initializer::term(tvg::CanvasEngine::Sw);
84 }
85
86 void win_del(void *data, Evas_Object *o, void *ev)
87 {
88    elm_exit();
89 }
90
91 int main(int argc, char **argv)
92 {
93     tvgtest();
94
95     //Show the result using EFL...
96     elm_init(argc, argv);
97
98     Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
99     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
100
101     Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
102     evas_object_image_size_set(img, WIDTH, HEIGHT);
103     evas_object_image_data_set(img, buffer);
104     evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
105     evas_object_show(img);
106
107     elm_win_resize_object_add(win, img);
108     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
109     evas_object_show(win);
110
111     elm_run();
112     elm_shutdown();
113 }