1 /* Ask about compositing */
2 #include "e_wizard.h"
3 #include "e_wizard_api.h"
4 #include <Evas_GL.h>
5
6 static Eina_Bool do_gl = 0;
7 static Eina_Bool do_vsync = 0;
8
9
10 static void
check_add(Evas_Object * box,const char * txt,Eina_Bool * val)11 check_add(Evas_Object *box, const char *txt, Eina_Bool *val)
12 {
13 Evas_Object *ck;
14
15 ck = elm_check_add(box);
16 E_ALIGN(ck, 0, 0.5);
17 elm_object_text_set(ck, txt);
18 elm_check_state_pointer_set(ck, val);
19 elm_box_pack_end(box, ck);
20 evas_object_show(ck);
21 }
22
23 E_API int
wizard_page_show(E_Wizard_Page * pg EINA_UNUSED)24 wizard_page_show(E_Wizard_Page *pg EINA_UNUSED)
25 {
26 Evas_Object *o, *of;
27
28 api->wizard_title_set(_("Compositing"));
29
30 of = elm_frame_add(e_comp->elm);
31 elm_object_text_set(of, _("Settings"));
32
33 o = elm_box_add(of);
34 elm_box_homogeneous_set(o, 1);
35 elm_object_content_set(of, o);
36 if (e_comp->gl)
37 {
38 Evas_GL *gl;
39
40 gl = evas_gl_new(e_comp->evas);
41 if (gl)
42 {
43 const char *str;
44 Evas_GL_API *glapi = evas_gl_api_get(gl);
45 str = (char*)glapi->glGetString(GL_RENDERER);
46 if (str && (!strcasestr(str, "llvmpipe")))
47 do_gl = do_vsync = 1;
48 evas_gl_free(gl);
49 }
50 }
51 if (!do_gl)
52 {
53 #ifdef HAVE_WAYLAND
54 if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
55 {
56 if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_DRM))
57 {
58 void *egl = dlopen("libEGL.so.1", RTLD_NOW | RTLD_LOCAL);
59 if (!egl) egl = dlopen("libEGL.so", RTLD_NOW | RTLD_LOCAL);
60 if (egl)
61 {
62 do_gl = 1;
63 dlclose(egl);
64 }
65 }
66 do_vsync = 1;
67 }
68 #endif
69 #ifndef HAVE_WAYLAND_ONLY
70 if (e_comp->comp_type == E_PIXMAP_TYPE_X)
71 {
72 Ecore_X_Window_Attributes att;
73
74 memset((&att), 0, sizeof(Ecore_X_Window_Attributes));
75 ecore_x_window_attributes_get(ecore_x_window_root_first_get(), &att);
76 if ((att.depth > 8) &&
77 (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_X11)))
78 {
79 Ecore_Evas *ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 32, 32);
80 if (ee)
81 {
82 do_gl = do_vsync = 1;
83 ecore_evas_free(ee);
84 }
85 }
86 }
87 }
88 #endif
89 check_add(o, _("Hardware Accelerated (OpenGL)"), &do_gl);
90 check_add(o, _("Tear-free Rendering"), &do_vsync);
91
92 evas_object_show(of);
93 api->wizard_page_show(of);
94
95 return 1; /* 1 == show ui, and wait for user, 0 == just continue */
96 }
97
98 E_API int
wizard_page_hide(E_Wizard_Page * pg EINA_UNUSED)99 wizard_page_hide(E_Wizard_Page *pg EINA_UNUSED)
100 {
101 E_Comp_Config *conf = NULL;
102
103 conf = e_comp_config_get();
104 if (do_gl)
105 {
106 conf->engine = E_COMP_ENGINE_GL;
107 conf->smooth_windows = 1;
108 conf->vsync = do_vsync;
109 }
110 else
111 {
112 conf->engine = E_COMP_ENGINE_SW;
113 conf->smooth_windows = 0;
114 conf->vsync = 0;
115 }
116
117 e_comp_internal_save();
118
119 return 1;
120 }
121