summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-10-04 00:10:29 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-10-04 10:04:39 +0900
commit177e6e148629f581c9729c75657831f4ccee6376 (patch)
treeda867c2f5f6df3a632f2791295672f6ecc55cced /src/lib/ecore_x
parent173edf60203678a032dd87e321dec0f5aa3d1814 (diff)
ecore_x - remove ecore_x_vsync tool as it isnt enabled or used runtime
so ecore_x_vsync as a tool uses glx for nvidia drivers plut "wait for vblank" extensions to try vsync "sync". the problem is this is flakey because the drivers may or may not continue vsyncing after screen off or syspend/resume or vt changes and all the workarounds dont seem to be reliable, so since this causes this to be disabled, no point keeping all the code and build stuff around, so remove this "unused junk" we have in the tree.
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/ecore_x_vsync_tool.c275
-rw-r--r--src/lib/ecore_x/ecore_x_vsync_tool_glx.c330
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_vsync.c170
3 files changed, 0 insertions, 775 deletions
diff --git a/src/lib/ecore_x/ecore_x_vsync_tool.c b/src/lib/ecore_x/ecore_x_vsync_tool.c
deleted file mode 100644
index b1a29cbca3..0000000000
--- a/src/lib/ecore_x/ecore_x_vsync_tool.c
+++ /dev/null
@@ -1,275 +0,0 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include <Eina.h>
6#include <Ecore.h>
7#include <Ecore_Con.h>
8
9#include <unistd.h>
10
11enum
12{
13 MODE_NONE,
14 MODE_GLX
15};
16
17int _vsync_init_glx(void);
18double _vsync_wait_glx(void);
19
20static void _svr_broadcast_time(double t);
21
22static int _vsync_mode = MODE_NONE;
23
24static int
25_vsync_init(void)
26{
27 if (_vsync_init_glx()) _vsync_mode = MODE_GLX;
28 else return 0;
29 return 1;
30}
31
32static double
33_vsync_wait(void)
34{
35 if (_vsync_mode == MODE_GLX) return _vsync_wait_glx();
36 return 0.0;
37}
38
39typedef struct
40{
41 Eina_Thread_Queue_Msg head;
42 char val;
43} Msg;
44
45static Eina_Thread_Queue *thq = NULL;
46static volatile int ticking = 0;
47
48static void
49_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
50{
51 Msg *msg;
52 void *ref;
53 int tick = 0;
54
55 for (;;)
56 {
57 if (!tick)
58 {
59 msg = eina_thread_queue_wait(thq, &ref);
60 if (msg)
61 {
62 tick = msg->val;
63 eina_thread_queue_wait_done(thq, ref);
64 }
65 }
66 else
67 {
68 do
69 {
70 msg = eina_thread_queue_poll(thq, &ref);
71 if (msg)
72 {
73 tick = msg->val;
74 eina_thread_queue_wait_done(thq, ref);
75 }
76 }
77 while (msg);
78 }
79 if (tick == -1) exit(0);
80 if (tick)
81 {
82 double *t;
83
84 t = malloc(sizeof(*t));
85 if (t)
86 {
87 *t = _vsync_wait();
88 do
89 {
90 msg = eina_thread_queue_poll(thq, &ref);
91 if (msg)
92 {
93 tick = msg->val;
94 eina_thread_queue_wait_done(thq, ref);
95 }
96 }
97 while (msg);
98 if (tick) ecore_thread_feedback(thread, t);
99 }
100 }
101 }
102}
103
104static void
105_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg)
106{
107 double *t = msg;
108
109 if (t)
110 {
111 _svr_broadcast_time(*t);
112 free(t);
113 }
114}
115
116static void
117_tick_init(void)
118{
119 thq = eina_thread_queue_new();
120 ecore_thread_feedback_run(_tick_core, _tick_notify,
121 NULL, NULL, NULL, EINA_TRUE);
122}
123
124static void
125_tick_send(char val)
126{
127 Msg *msg;
128 void *ref;
129 msg = eina_thread_queue_send(thq, sizeof(Msg), &ref);
130 msg->val = val;
131 eina_thread_queue_send_done(thq, ref);
132}
133
134static void
135_tick_start(void)
136{
137 ticking++;
138 if (ticking == 1) _tick_send(1);
139}
140
141static void
142_tick_end(void)
143{
144 if (ticking <= 0) return;
145 ticking--;
146 if (ticking == 0) _tick_send(0);
147}
148
149/*--------------------------------------------------------------------*/
150
151typedef struct
152{
153 Ecore_Con_Client *client;
154 int enabled;
155} Clientdata;
156
157static Ecore_Con_Server *svr = NULL;
158static Eina_List *clients = NULL;
159
160static void
161_svr_broadcast_time(double t)
162{
163 Eina_List *l;
164 Clientdata *cdat;
165
166 EINA_LIST_FOREACH(clients, l, cdat)
167 {
168 if (cdat->enabled > 0)
169 ecore_con_client_send(cdat->client, &t, sizeof(t));
170 }
171}
172
173static Eina_Bool
174_svr_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
175{
176 Ecore_Con_Event_Client_Add *ev = event;
177 if (svr != ecore_con_client_server_get(ev->client)) return EINA_TRUE;
178 Clientdata *cdat = calloc(1, sizeof(Clientdata));
179 if (cdat)
180 {
181 cdat->client = ev->client;
182 clients = eina_list_append(clients, cdat);
183 ecore_con_client_data_set(ev->client, cdat);
184 }
185 return EINA_FALSE;
186}
187
188static Eina_Bool
189_svr_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
190{
191 Ecore_Con_Event_Client_Del *ev = event;
192 if (svr != ecore_con_client_server_get(ev->client)) return EINA_TRUE;
193 Clientdata *cdat = ecore_con_client_data_get(ev->client);
194 if (cdat)
195 {
196 while (cdat->enabled > 0)
197 {
198 cdat->enabled--;
199 if (cdat->enabled == 0) _tick_end();
200 }
201 clients = eina_list_remove(clients, cdat);
202 free(cdat);
203 }
204 return EINA_FALSE;
205}
206
207static Eina_Bool
208_svr_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
209{
210 Ecore_Con_Event_Client_Data *ev = event;
211 if (svr != ecore_con_client_server_get(ev->client)) return EINA_TRUE;
212 Clientdata *cdat = ecore_con_client_data_get(ev->client);
213 if (cdat)
214 {
215 char *dat = ev->data;
216 int i;
217 int penabled = cdat->enabled;
218
219 for (i = 0; i < ev->size; i++)
220 {
221 if (dat[i]) cdat->enabled++;
222 else if (cdat->enabled > 0) cdat->enabled--;
223 }
224 if (ev->size > 0)
225 {
226 if (penabled != cdat->enabled)
227 {
228 if (cdat->enabled == 1) _tick_start();
229 else if (cdat->enabled == 0) _tick_end();
230 }
231 }
232 }
233 return EINA_FALSE;
234}
235
236static void
237_svr_init(void)
238{
239 char buf[4096], *disp, *s;
240
241 disp = getenv("DISPLAY");
242 if (!disp) disp = ":0";
243 snprintf(buf, sizeof(buf), "ecore-x-vsync-%s", disp);
244 for (s = buf; *s; s++)
245 {
246 if (!(((*s >= 'a') && (*s <= 'z')) ||
247 ((*s >= 'A') && (*s <= 'Z')) ||
248 ((*s >= '0') && (*s <= '9')))) *s = '-';
249 }
250 svr = ecore_con_server_add(ECORE_CON_LOCAL_USER, buf, 1, NULL);
251 if (!svr) exit(0);
252 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _svr_add, NULL);
253 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _svr_del, NULL);
254 ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _svr_data, NULL);
255}
256
257/*--------------------------------------------------------------------*/
258
259int
260main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
261{
262 eina_init();
263 ecore_app_no_system_modules();
264 ecore_init();
265 ecore_con_init();
266
267 if (!_vsync_init()) return 7;
268 _svr_init();
269 _tick_init();
270
271 ecore_main_loop_begin();
272 _tick_send(-1);
273 pause();
274 return 0;
275}
diff --git a/src/lib/ecore_x/ecore_x_vsync_tool_glx.c b/src/lib/ecore_x/ecore_x_vsync_tool_glx.c
deleted file mode 100644
index a6f6a0cc41..0000000000
--- a/src/lib/ecore_x/ecore_x_vsync_tool_glx.c
+++ /dev/null
@@ -1,330 +0,0 @@
1#include <Eina.h>
2#include <Ecore.h>
3#include <string.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7#include <dlfcn.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <fcntl.h>
11
12/*-------------------------------------------------------------------------*/
13
14#define SYM(lib, xx) \
15 do { \
16 sym_ ## xx = dlsym(lib, #xx); \
17 if (!(sym_ ## xx)) { \
18 fail = 1; \
19 } \
20 } while (0)
21
22#define GLX_DRAWABLE_TYPE 0x8010
23#define GLX_WINDOW_BIT 0x00000001
24#define GLX_RENDER_TYPE 0x8011
25#define GLX_RGBA_BIT 0x00000001
26#define GLX_DOUBLEBUFFER 5
27#define GLX_RED_SIZE 8
28#define GLX_GREEN_SIZE 9
29#define GLX_BLUE_SIZE 10
30#define GLX_RGBA_TYPE 0x8014
31typedef struct __GLXFBConfigRec *GLXFBConfig;
32
33typedef struct
34{
35 void *visual;
36 long visualid;
37 int screen;
38 int depth;
39 int c_class;
40 unsigned long red_mask;
41 unsigned long green_mask;
42 unsigned long blue_mask;
43 int colormap_size;
44 int bits_per_rgb;
45} XVisualInfo;
46
47typedef struct
48{
49 long background_pixmap;
50 unsigned long background_pixel;
51 long border_pixmap;
52 unsigned long border_pixel;
53 int bit_gravity;
54 int win_gravity;
55 int backing_store;
56 unsigned long backing_planes;
57 unsigned long backing_pixel;
58 int save_under;
59 long event_mask;
60 long do_not_propagate_mask;
61 int override_redirect;
62 long colormap;
63 long cursor;
64} XSetWindowAttributes;
65
66typedef struct {
67 void *ext_data;
68 void *display;
69 long root;
70 int width, height;
71 int mwidth, mheight;
72 int ndepths;
73 void *depths;
74 int root_depth;
75 void *root_visual;
76 long default_gc;
77 long cmap;
78 unsigned long white_pixel;
79 unsigned long black_pixel;
80 int max_maps, min_maps;
81 int backing_store;
82 int save_unders;
83 long root_input_mask;
84} Screen;
85
86typedef struct
87{
88 void *ext_data;
89 void *private1;
90 int fd;
91 int private2;
92 int proto_major_version;
93 int proto_minor_version;
94 char *vendor;
95 long private3;
96 long private4;
97 long private5;
98 int private6;
99 long (*resource_alloc)(void *);
100 int byte_order;
101 int bitmap_unit;
102 int bitmap_pad;
103 int bitmap_bit_order;
104 int nformats;
105 void *pixmap_format;
106 int private8;
107 int release;
108 void *private9, *private10;
109 int qlen;
110 unsigned long last_request_read;
111 unsigned long request;
112 char *private11;
113 char *private12;
114 char *private13;
115 char *private14;
116 unsigned max_request_size;
117 void *db;
118 int (*private15)(void *);
119 char *display_name;
120 int default_screen;
121 int nscreens;
122 Screen *screens;
123 unsigned long motion_buffer;
124 unsigned long private16;
125 int min_keycode;
126 int max_keycode;
127 char *private17;
128 char *private18;
129 int private19;
130 char *xdefaults;
131} *_XPrivDisplay;
132
133#define InputOutput 1
134#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
135#define ScreenOfDisplay(dpy, scr) (&((_XPrivDisplay)dpy)->screens[scr])
136#define CWBorderPixel (1L<<3)
137#define CWColormap (1L<<13)
138#define CWOverrideRedirect (1L<<9)
139#define AllocNone 0
140
141/*-------------------------------------------------------------------------*/
142
143static const char *lib_x11_files[] =
144{
145 "libX11.so.6",
146 "libX11.so.5",
147 "libX11.so.4",
148 "libX11.so",
149 NULL
150};
151static void *lib_x11 = NULL;
152static void * (*sym_XOpenDisplay) (char *name) = NULL;
153static long (*sym_XCreateColormap) (void *d, long w, void *vis, int alloc) = NULL;
154static long (*sym_XCreateWindow) (void *d, long par, int x, int y, unsigned int w, unsigned int h, unsigned int bd, int depth, unsigned int clas, void *vis, unsigned long valmask, void *attr) = NULL;
155static int (*sym_XCloseDisplay) (void *d) = NULL;
156//static void * (*sym_) () = NULL;
157
158static const char *lib_gl_files[] =
159{
160 "libGL.so.9",
161 "libGL.so.8",
162 "libGL.so.7",
163 "libGL.so.6",
164 "libGL.so.5",
165 "libGL.so.4",
166 "libGL.so.3",
167 "libGL.so.2",
168 "libGL.so.1",
169 "libGL.so",
170 NULL
171};
172static void *lib_gl = NULL;
173static GLXFBConfig * (*sym_glXChooseFBConfig) (void *d, int sc, const int *att, int *n) = NULL;
174static void * (*sym_glXGetVisualFromFBConfig) (void *d, GLXFBConfig fbconfig) = NULL;
175static void *(*sym_glXCreateNewContext) (void *d, GLXFBConfig config, int rtype, void *shr, int direct) = NULL;
176static long (*sym_glXCreateWindow) (void *d, GLXFBConfig config, long win, const int *attr) = NULL;
177static int (*sym_glXMakeContextCurrent) (void *d, long draw, long draw2, void *context) = NULL;
178static void (*sym_glXSwapBuffers) (void *d, long draw) = NULL;
179static const char * (*sym_glXQueryExtensionsString) (void *d, int ival) = NULL;
180static void * (*sym_glXGetProcAddressARB) (const char *sym) = NULL;
181static int (*sym_glXGetVideoSyncSGI) (unsigned int *cnt) = NULL;
182static int (*sym_glXWaitVideoSyncSGI) (int divisor, int remainder, unsigned int *cnt) = NULL;
183//static void * (*sym_) () = NULL;
184
185/*-------------------------------------------------------------------------*/
186
187static void *disp = NULL;
188static long gwin = 0;
189static void *context = NULL;
190
191static int _vsync_init_glx2(void);
192
193static void
194_vsync_shutdown_glx(void)
195{
196 if (disp) sym_XCloseDisplay(disp);
197 disp = NULL;
198}
199
200static void *
201lib_load(const char *files[])
202{
203 int i;
204 void *lib = NULL;
205
206 for (i = 0; files[i]; i++)
207 {
208 lib = dlopen(files[i], RTLD_LOCAL | RTLD_LAZY);
209 if (lib) return lib;
210 }
211 return NULL;
212}
213
214int
215_vsync_init_glx(void)
216{
217 int fail = 0;
218
219 /*---------------------------*/
220 lib_x11 = lib_load(lib_x11_files);
221 if (!lib_x11) goto err;
222
223 SYM(lib_x11, XOpenDisplay);
224 SYM(lib_x11, XCreateColormap);
225 SYM(lib_x11, XCreateWindow);
226 SYM(lib_x11, XCloseDisplay);
227 if (fail) goto err;
228
229 /*---------------------------*/
230 lib_gl = lib_load(lib_gl_files);
231 if (!lib_gl)
232 {
233 dlclose(lib_x11);
234 return 0;
235 }
236
237 SYM(lib_gl, glXChooseFBConfig);
238 SYM(lib_gl, glXGetVisualFromFBConfig);
239 SYM(lib_gl, glXCreateNewContext);
240 SYM(lib_gl, glXCreateWindow);
241 SYM(lib_gl, glXMakeContextCurrent);
242 SYM(lib_gl, glXSwapBuffers);
243 SYM(lib_gl, glXQueryExtensionsString);
244 SYM(lib_gl, glXGetProcAddressARB);
245 if (fail) goto err;
246
247 /*---------------------------*/
248 if (!_vsync_init_glx2()) goto err;
249 return 1;
250
251err:
252 if (disp) sym_XCloseDisplay(disp);
253 if (lib_gl) dlclose(lib_gl);
254 if (lib_x11) dlclose(lib_x11);
255 return 0;
256}
257
258static int
259_vsync_init_glx2(void)
260{
261 GLXFBConfig *fbconfigs;
262 int num = 0;
263 int attr[] =
264 {
265 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
266 GLX_RENDER_TYPE, GLX_RGBA_BIT,
267 GLX_DOUBLEBUFFER, 1,
268 GLX_RED_SIZE, 1,
269 GLX_GREEN_SIZE, 1,
270 GLX_BLUE_SIZE, 1,
271 0
272 };
273 XVisualInfo *vi;
274 XSetWindowAttributes wa;
275 long win;
276 const char *extns;
277
278 disp = sym_XOpenDisplay(NULL);
279 if (!disp) return 0;
280 fbconfigs = sym_glXChooseFBConfig(disp, 0, attr, &num);
281 if (!fbconfigs) return 0;
282 vi = sym_glXGetVisualFromFBConfig(disp, fbconfigs[0]);
283 if (!vi) return 0;
284 wa.override_redirect = 1;
285 wa.border_pixel = 0;
286 wa.colormap = sym_XCreateColormap(disp, RootWindow(disp, vi->screen),
287 vi->visual, AllocNone);
288 if (!wa.colormap) return 0;
289 win = sym_XCreateWindow(disp, RootWindow(disp, vi->screen),
290 -77, -777, 1, 1, 0, vi->depth, InputOutput,
291 vi->visual,
292 CWBorderPixel | CWColormap | CWOverrideRedirect, &wa);
293 if (!win) return 0;
294 context = sym_glXCreateNewContext(disp, fbconfigs[0], GLX_RGBA_TYPE,
295 NULL, 1);
296 if (!context) return 0;
297 gwin = sym_glXCreateWindow(disp, fbconfigs[0], win, NULL);
298 if (!gwin) return 0;
299 extns = sym_glXQueryExtensionsString(disp, 0);
300 if (!extns) return 0;
301 if (!strstr(extns, "GLX_SGI_swap_control")) return 0;
302 sym_glXGetVideoSyncSGI = sym_glXGetProcAddressARB("glXGetVideoSyncSGI");
303 sym_glXWaitVideoSyncSGI = sym_glXGetProcAddressARB("glXWaitVideoSyncSGI");
304 if ((!sym_glXGetVideoSyncSGI) || (!sym_glXWaitVideoSyncSGI)) return 0;
305
306 return 1;
307}
308
309double
310_vsync_wait_glx(void)
311{
312 double t;
313 unsigned int rc = 0;
314 static unsigned int prc = 0;
315
316again:
317 sym_glXMakeContextCurrent(disp, gwin, gwin, context);
318 sym_glXGetVideoSyncSGI(&rc);
319 sym_glXWaitVideoSyncSGI(1, 0, &rc);
320 if (prc == rc)
321 {
322 _vsync_shutdown_glx();
323 usleep(200000);
324 if (!_vsync_init_glx2()) exit(1);
325 goto again;
326 }
327 prc = rc;
328 t = ecore_time_get();
329 return t;
330}
diff --git a/src/lib/ecore_x/xlib/ecore_x_vsync.c b/src/lib/ecore_x/xlib/ecore_x_vsync.c
index bdf832c97b..34eb605f96 100644
--- a/src/lib/ecore_x/xlib/ecore_x_vsync.c
+++ b/src/lib/ecore_x/xlib/ecore_x_vsync.c
@@ -705,145 +705,6 @@ _drm_animator_tick_source_set(void)
705 705
706 706
707 707
708// disable gl vsync for now - nvidia doesnt work well.
709//#define ECORE_X_VSYNC_GL 1
710
711#ifdef ECORE_X_VSYNC_GL
712static Ecore_Con_Server *vsync_server = NULL;
713static Eina_Bool handlers = EINA_FALSE;
714static Eina_Prefix *_prefix = NULL;
715
716static Eina_Bool
717vsync_server_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
718{
719 Ecore_Con_Event_Server_Add *ev = event;
720 if (ev->server != vsync_server) return EINA_TRUE;
721 return EINA_FALSE;
722}
723
724static Eina_Bool
725vsync_server_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
726{
727 Ecore_Con_Event_Server_Del *ev = event;
728 if (ev->server != vsync_server) return EINA_TRUE;
729 if (vsync_server)
730 {
731 ecore_con_server_del(vsync_server);
732 vsync_server = NULL;
733 ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
734 ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
735 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
736 }
737 return EINA_FALSE;
738}
739
740static int ticking = 0;
741
742static Eina_Bool
743vsync_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
744{
745 Ecore_Con_Event_Server_Data *ev = event;
746 int i;
747 double t;
748 char *d;
749 if (ev->server != vsync_server) return EINA_TRUE;
750 d = ev->data;
751 if (ticking)
752 {
753 for (i = 0; i < ev->size - (int)(sizeof(double) - 1); i++)
754 {
755 memcpy(&t, &(d[i]), sizeof(double));
756 ecore_loop_time_set(t);
757 ecore_animator_custom_tick();
758 }
759 }
760 return EINA_FALSE;
761}
762
763static void
764vsync_tick_begin(void *data EINA_UNUSED)
765{
766 char val = 1;
767 ticking = val;
768 ecore_con_server_send(vsync_server, &val, 1);
769}
770
771static void
772vsync_tick_end(void *data EINA_UNUSED)
773{
774 char val = 0;
775 ticking = val;
776 ecore_con_server_send(vsync_server, &val, 1);
777}
778
779static Eina_Bool
780_glvsync_animator_tick_source_set(void)
781{
782 if (!vsync_server)
783 {
784 char buf[4096], run[4096], *disp, *s;
785 int tries = 0;
786
787 if (!handlers)
788 {
789 _prefix = eina_prefix_new(NULL, ecore_x_vsync_animator_tick_source_set,
790 "ECORE_X", "ecore_x", "checkme",
791 PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
792 PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
793 ecore_con_init();
794 }
795 disp = getenv("DISPLAY");
796 if (!disp) disp = ":0";
797 snprintf(buf, sizeof(buf), "ecore-x-vsync-%s", disp);
798 for (s = buf; *s; s++)
799 {
800 if (!(((*s >= 'a') && (*s <= 'z')) ||
801 ((*s >= 'A') && (*s <= 'Z')) ||
802 ((*s >= '0') && (*s <= '9')))) *s = '-';
803 }
804 vsync_server = ecore_con_server_connect(ECORE_CON_LOCAL_USER, buf, 1, NULL);
805 if (!vsync_server)
806 {
807 snprintf(run, sizeof(run), "%s/ecore_x/bin/%s/ecore_x_vsync",
808 eina_prefix_lib_get(_prefix), MODULE_ARCH);
809 ecore_exe_run(run, NULL);
810 }
811 while (!vsync_server)
812 {
813 tries++;
814 if (tries > 50) return EINA_FALSE;
815 usleep(10000);
816 vsync_server = ecore_con_server_connect(ECORE_CON_LOCAL_USER, buf, 1, NULL);
817 }
818 if (!handlers)
819 {
820 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, vsync_server_add, NULL);
821 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, vsync_server_del, NULL);
822 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, vsync_server_data, NULL);
823 handlers = EINA_FALSE;
824 }
825 }
826 if (vsync_root)
827 {
828 ecore_animator_custom_source_tick_begin_callback_set(vsync_tick_begin, NULL);
829 ecore_animator_custom_source_tick_end_callback_set(vsync_tick_end, NULL);
830 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
831 }
832 else
833 {
834 if (vsync_server)
835 {
836 ecore_con_server_del(vsync_server);
837 vsync_server = NULL;
838 }
839 ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
840 ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
841 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
842 }
843 return EINA_TRUE;
844}
845#endif
846
847// XXX: missing mode 3 == separate x connection with compiled in dri2 proto 708// XXX: missing mode 3 == separate x connection with compiled in dri2 proto
848// handling ala mesa (taken from mesa likely) 709// handling ala mesa (taken from mesa likely)
849 710
@@ -871,30 +732,6 @@ _vsync_init(void)
871 } 732 }
872 } 733 }
873#endif 734#endif
874 // nvidia gl vsync slave mode
875 if (mode == 0)
876 {
877 // we appear to have an nvidia driver running
878 if (!stat("/dev/nvidiactl", &stb))
879 {
880 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG"))
881 fprintf(stderr, "We appear to have an nvidia driver: drm flags %i\n", flags);
882 if (
883 // we have dri device AND it's an nvidia one
884 ((!stat("/dev/dri/card0", &stb)) &&
885 (flags & DRM_HAVE_NVIDIA))
886 ||
887 // or we have no dri device, and no nvidia flags
888 ((stat("/dev/dri/card0", &stb)) &&
889 (flags == 0))
890 )
891 {
892 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG"))
893 fprintf(stderr, "Using nvidia vsync slave proc\n");
894 mode = 2;
895 }
896 }
897 }
898 } 735 }
899 done = 1; 736 done = 1;
900} 737}
@@ -928,13 +765,6 @@ ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
928 vsync_root = root; 765 vsync_root = root;
929#ifdef ECORE_X_VSYNC_DRM 766#ifdef ECORE_X_VSYNC_DRM
930 if (mode == 1) return _drm_animator_tick_source_set(); 767 if (mode == 1) return _drm_animator_tick_source_set();
931# ifdef ECORE_X_VSYNC_GL
932 else
933# endif
934#endif
935#ifdef ECORE_X_VSYNC_GL
936 if (mode == 2) return _glvsync_animator_tick_source_set();
937 else return EINA_FALSE;
938#endif 768#endif
939 } 769 }
940 return EINA_TRUE; 770 return EINA_TRUE;