bindings/capi: fix c compatibility warnings.
[platform/core/graphics/tizenvg.git] / test / testCommon.h
1 #include <iostream>
2 #include <thread>
3 #include <Elementary.h>
4 #include <thorvg.h>
5
6 using namespace std;
7
8 #define WIDTH 800
9 #define HEIGHT 800
10
11 /************************************************************************/
12 /* Common Infrastructure Code                                           */
13 /************************************************************************/
14
15 void tvgSwTest(uint32_t* buffer);
16 void drawSwView(void* data, Eo* obj);
17
18 void win_del(void *data, Evas_Object *o, void *ev)
19 {
20    elm_exit();
21 }
22
23 static Eo* createSwView()
24 {
25     static uint32_t buffer[WIDTH * HEIGHT];
26
27     Eo* win = elm_win_util_standard_add(NULL, "ThorVG Test");
28     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
29
30     Eo* view = evas_object_image_filled_add(evas_object_evas_get(win));
31     evas_object_image_size_set(view, WIDTH, HEIGHT);
32     evas_object_image_data_set(view, buffer);
33     evas_object_image_pixels_get_callback_set(view, drawSwView, nullptr);
34     evas_object_image_pixels_dirty_set(view, EINA_TRUE);
35     evas_object_image_data_update_add(view, 0, 0, WIDTH, HEIGHT);
36     evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37     evas_object_show(view);
38
39     elm_win_resize_object_add(win, view);
40     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
41     evas_object_show(win);
42
43     tvgSwTest(buffer);
44
45     return view;
46 }
47
48 void initGLview(Evas_Object *obj);
49 void drawGLview(Evas_Object *obj);
50
51 static Eo* createGlView()
52 {
53     elm_config_accel_preference_set("gl");
54
55     Eo* win = elm_win_util_standard_add(NULL, "ThorVG Test");
56     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
57
58     Eo* view = elm_glview_add(win);
59     evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60     elm_glview_mode_set(view, ELM_GLVIEW_ALPHA);
61     elm_glview_resize_policy_set(view, ELM_GLVIEW_RESIZE_POLICY_RECREATE);
62     elm_glview_render_policy_set(view, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
63     elm_glview_init_func_set(view, initGLview);
64     elm_glview_render_func_set(view, drawGLview);
65     evas_object_show(view);
66
67     elm_win_resize_object_add(win, view);
68     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
69     evas_object_show(win);
70
71     return view;
72 }