add some sync stuff.. wil be used soon

SVN revision: 45733
This commit is contained in:
Carsten Haitzler 2010-01-30 10:42:22 +00:00
parent 164a8b8142
commit 2af8f0e8b5
8 changed files with 243 additions and 7 deletions

View File

@ -199,6 +199,7 @@ struct _Ecore_Evas_Engine
Ecore_X_Pixmap mask;
Ecore_X_GC gc;
Ecore_X_XRegion *damages;
Ecore_X_Sync_Counter sync_counter;
int screen_num;
int px, py, pw, ph;
unsigned char direct_resize : 1;

View File

@ -36,6 +36,22 @@ _ecore_evas_x_protocols_set(Ecore_Evas *ee)
ecore_x_icccm_protocol_atoms_set(ee->prop.window, protos, num);
}
static void
_ecore_evas_x_sync_set(Ecore_Evas *ee)
{
if (!ee->engine.x.sync_counter)
ee->engine.x.sync_counter = ecore_x_sync_counter_new(0);
ecore_x_e_comp_sync_counter_set(ee->prop.window, ee->engine.x.sync_counter);
}
static void
_ecore_evas_x_sync_clear(Ecore_Evas *ee)
{
if (!ee->engine.x.sync_counter) return;
ecore_x_sync_counter_free(ee->engine.x.sync_counter);
ee->engine.x.sync_counter = 0;
}
#ifdef HAVE_ECORE_X_XCB
static xcb_visualtype_t *
xcb_visualtype_get(xcb_screen_t *screen, xcb_visualid_t visual)
@ -140,6 +156,7 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y,
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
ecore_x_window_defaults_set(win);
_ecore_evas_x_protocols_set(ee);
_ecore_evas_x_sync_set(ee);
}
else
{
@ -1033,6 +1050,7 @@ _ecore_evas_x_init(void)
static void
_ecore_evas_x_free(Ecore_Evas *ee)
{
_ecore_evas_x_sync_set(ee);
ecore_x_window_free(ee->prop.window);
if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap);
if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask);
@ -1061,6 +1079,7 @@ _ecore_evas_x_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Ev
{
ee->func.fn_delete_request = func;
_ecore_evas_x_protocols_set(ee);
_ecore_evas_x_sync_set(ee);
}
static void
@ -1532,6 +1551,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha)
0 /* window_group */,
0 /* is_urgent */);
_ecore_evas_x_protocols_set(ee);
_ecore_evas_x_sync_set(ee);
#endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */
}
else if (!strcmp(ee->driver, "xrender_x11"))
@ -1607,6 +1627,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha)
0 /* window_group */,
0 /* is_urgent */);
_ecore_evas_x_protocols_set(ee);
_ecore_evas_x_sync_set(ee);
#endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */
}
else if (!strcmp(ee->driver, "software_16_x11"))
@ -1675,6 +1696,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha)
0 /* window_group */,
0 /* is_urgent */);
_ecore_evas_x_protocols_set(ee);
_ecore_evas_x_sync_set(ee);
#endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */
}
}

View File

@ -1598,7 +1598,22 @@ EAPI int ecore_x_e_illume_top_shelf_geometry_get(Ecore_X_Window
EAPI void ecore_x_e_illume_bottom_panel_geometry_set(Ecore_X_Window win, int x, int y, int w, int h);
EAPI int ecore_x_e_illume_bottom_panel_geometry_get(Ecore_X_Window win, int *x, int *y, int *w, int *h);
EAPI void ecore_x_e_comp_sync_counter_set(Ecore_X_Window win, Ecore_X_Sync_Counter counter);
EAPI Ecore_X_Sync_Counter ecore_x_e_comp_sync_counter_get(Ecore_X_Window win);
EAPI void ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window win);
EAPI void ecore_x_e_comp_sync_supported_set(Ecore_X_Window root, Eina_Bool enabled);
EAPI Eina_Bool ecore_x_e_comp_sync_supported_get(Ecore_X_Window root);
EAPI void ecore_x_e_comp_sync_begin_send(Ecore_X_Window win);
EAPI void ecore_x_e_comp_sync_end_send(Ecore_X_Window win);
EAPI Ecore_X_Sync_Alarm ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter);
EAPI int ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm);
EAPI int ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val);
EAPI Ecore_X_Sync_Counter ecore_x_sync_counter_new(int val);
EAPI void ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter);
EAPI void ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter, int val);
EAPI void ecore_x_sync_counter_inc_wait(Ecore_X_Sync_Counter counter, int val);
EAPI void ecore_x_xinerama_query_screens_prefetch(void);
EAPI void ecore_x_xinerama_query_screens_fetch(void);
EAPI int ecore_x_xinerama_screen_count_get(void);
@ -1704,11 +1719,6 @@ EAPI int ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XReg
EAPI int ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y);
EAPI int ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect);
/* ecore_x_sync.c */
EAPI Ecore_X_Sync_Alarm ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter);
EAPI int ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm);
EAPI int ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val);
/* ecore_x_randr.c */
typedef struct _Ecore_X_Screen_Size Ecore_X_Screen_Size;
struct _Ecore_X_Screen_Size

View File

@ -229,4 +229,10 @@ EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_TOP_SHELF_GEOMETRY;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_BOTTOM_PANEL_GEOMETRY;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_COUNTER;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_BEGIN;
EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_END;
#endif /* _ECORE_X_ATOMS_H */

View File

@ -251,3 +251,9 @@ EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE_REQUEST = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_TOP_SHELF_GEOMETRY = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_BOTTOM_PANEL_GEOMETRY = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_COUNTER = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_BEGIN = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_END = 0;

View File

@ -243,7 +243,13 @@ _ecore_x_atoms_init(void)
{ "_E_ILLUME_QUICKPANEL_ZONE_REQUEST", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE_REQUEST },
{ "_E_ILLUME_QUICKPANEL_POSITION_UPDATE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE },
{ "_E_ILLUME_TOP_SHELF_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_TOP_SHELF_GEOMETRY },
{ "_E_ILLUME_BOTTOM_PANEL_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_BOTTOM_PANEL_GEOMETRY }
{ "_E_ILLUME_BOTTOM_PANEL_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_BOTTOM_PANEL_GEOMETRY },
{ "_E_COMP_SYNC_COUNTER", &ECORE_X_ATOM_E_COMP_SYNC_COUNTER },
{ "_E_COMP_SYNC_DRAW_DONE", &ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE },
{ "_E_COMP_SYNC_SUPPORTED", &ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED },
{ "_E_COMP_SYNC_BEGIN", &ECORE_X_ATOM_E_COMP_SYNC_BEGIN },
{ "_E_COMP_SYNC_END", &ECORE_X_ATOM_E_COMP_SYNC_END }
};
Atom *atoms;
char **names;

View File

@ -518,3 +518,145 @@ ecore_x_e_illume_bottom_panel_geometry_get(Ecore_X_Window win, int *x, int *y, i
if (h) *h = geom[3];
return 1;
}
EAPI void
ecore_x_e_comp_sync_counter_set(Ecore_X_Window win, Ecore_X_Sync_Counter counter)
{
if (counter)
ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER,
ECORE_X_ATOM_CARDINAL, &counter, 1);
else
ecore_x_window_prop_property_del(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER);
}
EAPI Ecore_X_Sync_Counter
ecore_x_e_comp_sync_counter_get(Ecore_X_Window win)
{
int ret = 0;
Ecore_X_Sync_Counter counter = 0;
ret =
ecore_x_window_prop_xid_get(win,
ECORE_X_ATOM_E_COMP_SYNC_COUNTER,
ECORE_X_ATOM_CARDINAL,
&counter, 1);
if (ret != 1) return 0;
return counter;
}
EAPI void
ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window win)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.display = _ecore_x_disp;
xev.xclient.window = win;
xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE;
xev.xclient.format = 32;
xev.xclient.data.l[0] = win;
xev.xclient.data.l[1] = 0; // later
xev.xclient.data.l[2] = 0; // later
xev.xclient.data.l[3] = 0; // later
xev.xclient.data.l[4] = 0; // later
XSendEvent(_ecore_x_disp, win, False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
EAPI void
ecore_x_e_comp_sync_supported_set(Ecore_X_Window root, Eina_Bool enabled)
{
Ecore_X_Window win;
if (enabled)
{
win = ecore_x_window_new(root, 1, 2, 3, 4);
ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
ECORE_X_ATOM_WINDOW, &win, 1);
ecore_x_window_prop_xid_set(root, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
ECORE_X_ATOM_WINDOW, &win, 1);
}
else
{
int ret;
ret =
ecore_x_window_prop_xid_get(root,
ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
ECORE_X_ATOM_WINDOW,
&win, 1);
if ((ret == 1) && (win))
{
ecore_x_window_prop_property_del(root, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED);
ecore_x_window_del(win);
}
}
}
EAPI Eina_Bool
ecore_x_e_comp_sync_supported_get(Ecore_X_Window root)
{
Ecore_X_Window win, win2;
int ret;
ret =
ecore_x_window_prop_xid_get(root,
ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
ECORE_X_ATOM_WINDOW,
&win, 1);
if ((ret == 1) && (win))
{
ret =
ecore_x_window_prop_xid_get(win,
ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
ECORE_X_ATOM_WINDOW,
&win2, 1);
if ((ret == 1) && (win2 == win))
{
return 1;
}
}
return 0;
}
EAPI void
ecore_x_e_comp_sync_begin_send(Ecore_X_Window win)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.display = _ecore_x_disp;
xev.xclient.window = win;
xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_BEGIN;
xev.xclient.format = 32;
xev.xclient.data.l[0] = win;
xev.xclient.data.l[1] = 0; // later
xev.xclient.data.l[2] = 0; // later
xev.xclient.data.l[3] = 0; // later
xev.xclient.data.l[4] = 0; // later
XSendEvent(_ecore_x_disp, win, False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
EAPI void
ecore_x_e_comp_sync_end_send(Ecore_X_Window win)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.display = _ecore_x_disp;
xev.xclient.window = win;
xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_END;
xev.xclient.format = 32;
xev.xclient.data.l[0] = win;
xev.xclient.data.l[1] = 0; // later
xev.xclient.data.l[2] = 0; // later
xev.xclient.data.l[3] = 0; // later
xev.xclient.data.l[4] = 0; // later
XSendEvent(_ecore_x_disp, win, False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}

View File

@ -66,3 +66,46 @@ ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val)
return 0;
}
EAPI Ecore_X_Sync_Counter
ecore_x_sync_counter_new(int val)
{
XSyncCounter counter;
XSyncValue v;
XSyncIntToValue(&v, val);
counter = XSyncCreateCounter(_ecore_x_disp, v);
return counter;
}
EAPI void
ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter)
{
XSyncDestroyCounter(_ecore_x_disp, counter);
}
EAPI void
ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter, int val)
{
XSyncValue v;
XSyncIntToValue(&v, val);
XSyncChangeCounter(_ecore_x_disp, counter, v);
}
EAPI void
ecore_x_sync_counter_inc_wait(Ecore_X_Sync_Counter counter, int val)
{
XSyncWaitCondition cond;
XSyncValue v, v2;
XSyncIntToValue(&v, val);
XSyncIntToValue(&v2, val + 2);
cond.trigger.counter = counter;
cond.trigger.value_type = XSyncRelative;
cond.trigger.wait_value = v;
cond.trigger.test_type = XSyncPositiveTransition;
cond.event_threshold = v2;
XSyncAwait(_ecore_x_disp, &cond, 1);
XSync(_ecore_x_disp, False);
}