diff options
author | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-22 18:58:32 +0400 |
---|---|---|
committer | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-22 18:58:32 +0400 |
commit | a05a048e8f9a8eb59463374232e6a4ef59a0036f (patch) | |
tree | d100281a4e22e86418937173e6935faba305aff2 /EGL | |
parent | ccdf3d69b63094036a3165b4e0e1e127cf46a826 (diff) | |
download | emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.tar.gz emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.tar.bz2 emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.zip |
YaGL: EGL_EXT_buffer_age implemented
Change-Id: I284667036114e88ea954a6c965e4eba8bd240f81
Diffstat (limited to 'EGL')
-rw-r--r-- | EGL/gbm/yagl_gbm_pixmap.c | 6 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_platform.c | 1 | ||||
-rw-r--r-- | EGL/gbm/yagl_gbm_window.c | 8 | ||||
-rw-r--r-- | EGL/wayland/yagl_wayland_platform.c | 1 | ||||
-rw-r--r-- | EGL/wayland/yagl_wayland_window.c | 28 | ||||
-rw-r--r-- | EGL/wayland/yagl_wayland_window.h | 1 | ||||
-rw-r--r-- | EGL/x11/yagl_x11_drawable.c | 6 | ||||
-rw-r--r-- | EGL/x11/yagl_x11_platform.c | 1 | ||||
-rw-r--r-- | EGL/yagl_display.c | 10 | ||||
-rw-r--r-- | EGL/yagl_egl_calls.c | 8 | ||||
-rw-r--r-- | EGL/yagl_native_drawable.h | 2 | ||||
-rw-r--r-- | EGL/yagl_native_platform.h | 2 |
12 files changed, 73 insertions, 1 deletions
diff --git a/EGL/gbm/yagl_gbm_pixmap.c b/EGL/gbm/yagl_gbm_pixmap.c index 317b400..ce33172 100644 --- a/EGL/gbm/yagl_gbm_pixmap.c +++ b/EGL/gbm/yagl_gbm_pixmap.c @@ -30,6 +30,11 @@ static int yagl_gbm_pixmap_get_buffer(struct yagl_native_drawable *drawable, return 1; } +static int yagl_gbm_pixmap_get_buffer_age(struct yagl_native_drawable *drawable) +{ + return 0; +} + static void yagl_gbm_pixmap_swap_buffers(struct yagl_native_drawable *drawable) { } @@ -94,6 +99,7 @@ struct yagl_native_drawable yagl_native_drawable_init(pixmap, dpy, os_pixmap); pixmap->get_buffer = &yagl_gbm_pixmap_get_buffer; + pixmap->get_buffer_age = &yagl_gbm_pixmap_get_buffer_age; pixmap->swap_buffers = &yagl_gbm_pixmap_swap_buffers; pixmap->wait = &yagl_gbm_pixmap_wait; pixmap->copy_to_pixmap = &yagl_gbm_pixmap_copy_to_pixmap; diff --git a/EGL/gbm/yagl_gbm_platform.c b/EGL/gbm/yagl_gbm_platform.c index c49fa1f..bc98f54 100644 --- a/EGL/gbm/yagl_gbm_platform.c +++ b/EGL/gbm/yagl_gbm_platform.c @@ -35,6 +35,7 @@ static struct yagl_native_display struct yagl_native_platform yagl_gbm_platform = { .pixmaps_supported = 1, + .buffer_age_supported = 1, .probe = yagl_gbm_platform_probe, .wrap_display = yagl_gbm_wrap_display }; diff --git a/EGL/gbm/yagl_gbm_window.c b/EGL/gbm/yagl_gbm_window.c index 5dc36ae..69de99a 100644 --- a/EGL/gbm/yagl_gbm_window.c +++ b/EGL/gbm/yagl_gbm_window.c @@ -33,6 +33,13 @@ static int yagl_gbm_window_get_buffer(struct yagl_native_drawable *drawable, return 1; } +static int yagl_gbm_window_get_buffer_age(struct yagl_native_drawable *drawable) +{ + struct gbm_surface *sfc = YAGL_GBM_WINDOW(drawable->os_drawable); + + return sfc->get_buffer_age(sfc); +} + static void yagl_gbm_window_swap_buffers(struct yagl_native_drawable *drawable) { struct gbm_surface *sfc = YAGL_GBM_WINDOW(drawable->os_drawable); @@ -102,6 +109,7 @@ struct yagl_native_drawable yagl_native_drawable_init(window, dpy, os_window); window->get_buffer = &yagl_gbm_window_get_buffer; + window->get_buffer_age = &yagl_gbm_window_get_buffer_age; window->swap_buffers = &yagl_gbm_window_swap_buffers; window->wait = &yagl_gbm_window_wait; window->copy_to_pixmap = &yagl_gbm_window_copy_to_pixmap; diff --git a/EGL/wayland/yagl_wayland_platform.c b/EGL/wayland/yagl_wayland_platform.c index c9ef241..78ebedc 100644 --- a/EGL/wayland/yagl_wayland_platform.c +++ b/EGL/wayland/yagl_wayland_platform.c @@ -53,6 +53,7 @@ static struct yagl_native_display struct yagl_native_platform yagl_wayland_platform = { .pixmaps_supported = 0, + .buffer_age_supported = 1, .probe = yagl_wayland_platform_probe, .wrap_display = yagl_wayland_wrap_display }; diff --git a/EGL/wayland/yagl_wayland_window.c b/EGL/wayland/yagl_wayland_window.c index c94ce29..3ed9bc8 100644 --- a/EGL/wayland/yagl_wayland_window.c +++ b/EGL/wayland/yagl_wayland_window.c @@ -116,6 +116,7 @@ static int yagl_wayland_window_lock_back(struct yagl_wayland_window *window) strerror(-ret)); window->back->drm_sfc = NULL; } + window->back->age = 0; } if (!window->back->drm_sfc) { @@ -215,13 +216,28 @@ static int yagl_wayland_window_get_buffer(struct yagl_native_drawable *drawable, return 1; } +static int yagl_wayland_window_get_buffer_age(struct yagl_native_drawable *drawable) +{ + struct yagl_wayland_window *window = (struct yagl_wayland_window*)drawable; + + YAGL_LOG_FUNC_SET(yagl_wayland_window_get_buffer_age); + + if (!yagl_wayland_window_lock_back(window)) { + YAGL_LOG_ERROR("Cannot lock back for egl_window %p", + YAGL_WAYLAND_WINDOW(drawable->os_drawable)); + return 0; + } + + return window->back->age; +} + static void yagl_wayland_window_swap_buffers(struct yagl_native_drawable *drawable) { struct yagl_wayland_window *window = (struct yagl_wayland_window*)drawable; struct yagl_wayland_display *dpy = (struct yagl_wayland_display*)drawable->dpy; struct wl_display *wl_dpy = YAGL_WAYLAND_DPY(drawable->dpy->os_dpy); struct wl_egl_window *egl_window = YAGL_WAYLAND_WINDOW(drawable->os_drawable); - int ret = 0; + int i, ret = 0; YAGL_LOG_FUNC_SET(yagl_wayland_window_swap_buffers); @@ -243,6 +259,14 @@ static void yagl_wayland_window_swap_buffers(struct yagl_native_drawable *drawab window); wl_proxy_set_queue((struct wl_proxy*)window->frame_callback, dpy->queue); + for (i = 0; + i < sizeof(window->color_buffers)/sizeof(window->color_buffers[0]); + ++i) { + if (window->color_buffers[i].age > 0) { + ++window->color_buffers[i].age; + } + } + /* * Make sure we have a back buffer in case we're swapping without ever * rendering. @@ -253,6 +277,7 @@ static void yagl_wayland_window_swap_buffers(struct yagl_native_drawable *drawab } window->front = window->back; + window->front->age = 1; window->back = NULL; if (!window->front->wl_buffer) { @@ -389,6 +414,7 @@ struct yagl_native_drawable yagl_native_drawable_init(&window->base, dpy, os_window); window->base.get_buffer = &yagl_wayland_window_get_buffer; + window->base.get_buffer_age = &yagl_wayland_window_get_buffer_age; window->base.swap_buffers = &yagl_wayland_window_swap_buffers; window->base.wait = &yagl_wayland_window_wait; window->base.copy_to_pixmap = &yagl_wayland_window_copy_to_pixmap; diff --git a/EGL/wayland/yagl_wayland_window.h b/EGL/wayland/yagl_wayland_window.h index 8ec4fc8..cbcf394 100644 --- a/EGL/wayland/yagl_wayland_window.h +++ b/EGL/wayland/yagl_wayland_window.h @@ -18,6 +18,7 @@ struct yagl_wayland_window struct vigs_drm_surface *drm_sfc; struct wl_buffer *wl_buffer; int locked; + int age; } color_buffers[3], *back, *front; int width; diff --git a/EGL/x11/yagl_x11_drawable.c b/EGL/x11/yagl_x11_drawable.c index a9aa713..8fd2bb5 100644 --- a/EGL/x11/yagl_x11_drawable.c +++ b/EGL/x11/yagl_x11_drawable.c @@ -58,6 +58,11 @@ static int yagl_x11_drawable_get_buffer(struct yagl_native_drawable *drawable, return 1; } +static int yagl_x11_drawable_get_buffer_age(struct yagl_native_drawable *drawable) +{ + return 0; +} + static void yagl_x11_drawable_swap_buffers(struct yagl_native_drawable *drawable) { Display *x_dpy = YAGL_X11_DPY(drawable->dpy->os_dpy); @@ -276,6 +281,7 @@ struct yagl_native_drawable *yagl_x11_drawable_create(struct yagl_native_display os_drawable); drawable->base.get_buffer = &yagl_x11_drawable_get_buffer; + drawable->base.get_buffer_age = &yagl_x11_drawable_get_buffer_age; drawable->base.swap_buffers = &yagl_x11_drawable_swap_buffers; drawable->base.wait = &yagl_x11_drawable_wait; drawable->base.copy_to_pixmap = &yagl_x11_drawable_copy_to_pixmap; diff --git a/EGL/x11/yagl_x11_platform.c b/EGL/x11/yagl_x11_platform.c index 2633eda..34eadf6 100644 --- a/EGL/x11/yagl_x11_platform.c +++ b/EGL/x11/yagl_x11_platform.c @@ -51,6 +51,7 @@ static struct yagl_native_display struct yagl_native_platform yagl_x11_platform = { .pixmaps_supported = 1, + .buffer_age_supported = 0, .probe = yagl_x11_platform_probe, .wrap_display = yagl_x11_wrap_display }; diff --git a/EGL/yagl_display.c b/EGL/yagl_display.c index be8d901..d00b8f3 100644 --- a/EGL/yagl_display.c +++ b/EGL/yagl_display.c @@ -23,6 +23,8 @@ #define YAGL_EGL_WL_BIND_WAYLAND_DISPLAY_EXTENSIONS "EGL_WL_bind_wayland_display " +#define YAGL_EGL_BUFFER_AGE_EXTENSIONS "EGL_EXT_buffer_age " + static pthread_once_t g_displays_init = PTHREAD_ONCE_INIT; static pthread_mutex_t g_displays_mutex; static YAGL_DECLARE_LIST(g_displays); @@ -250,6 +252,10 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy) len += strlen(YAGL_EGL_WL_BIND_WAYLAND_DISPLAY_EXTENSIONS); } + if (dpy->native_dpy->platform->buffer_age_supported) { + len += strlen(YAGL_EGL_BUFFER_AGE_EXTENSIONS); + } + dpy->extensions = yagl_malloc(len + 1); strcpy(dpy->extensions, YAGL_EGL_BASE_EXTENSIONS); @@ -261,6 +267,10 @@ const char *yagl_display_get_extensions(struct yagl_display *dpy) if (dpy->native_dpy->WL_bind_wayland_display_supported) { strcat(dpy->extensions, YAGL_EGL_WL_BIND_WAYLAND_DISPLAY_EXTENSIONS); } + + if (dpy->native_dpy->platform->buffer_age_supported) { + strcat(dpy->extensions, YAGL_EGL_BUFFER_AGE_EXTENSIONS); + } } pthread_mutex_unlock(&dpy->mutex); diff --git a/EGL/yagl_egl_calls.c b/EGL/yagl_egl_calls.c index e54d0a8..7a70275 100644 --- a/EGL/yagl_egl_calls.c +++ b/EGL/yagl_egl_calls.c @@ -688,6 +688,14 @@ YAGL_API EGLBoolean eglQuerySurface( EGLDisplay dpy_, *value = 0; retval = EGL_TRUE; break; + case EGL_BUFFER_AGE_EXT: + if (dpy->native_dpy->platform->buffer_age_supported && + surface->native_drawable) { + *value = surface->native_drawable->get_buffer_age(surface->native_drawable); + retval = EGL_TRUE; + break; + } + /* Fall through. */ default: do { yagl_mem_probe_write_EGLint(value); diff --git a/EGL/yagl_native_drawable.h b/EGL/yagl_native_drawable.h index 56b2870..68547ed 100644 --- a/EGL/yagl_native_drawable.h +++ b/EGL/yagl_native_drawable.h @@ -23,6 +23,8 @@ struct yagl_native_drawable uint32_t */*buffer_name*/, struct vigs_drm_surface **/*buffer_sfc*/); + int (*get_buffer_age)(struct yagl_native_drawable */*drawable*/); + void (*swap_buffers)(struct yagl_native_drawable */*drawable*/); /* diff --git a/EGL/yagl_native_platform.h b/EGL/yagl_native_platform.h index afb0f98..4ff4904 100644 --- a/EGL/yagl_native_platform.h +++ b/EGL/yagl_native_platform.h @@ -10,6 +10,8 @@ struct yagl_native_platform { int pixmaps_supported; + int buffer_age_supported; + int (*probe)(yagl_os_display /*os_dpy*/); struct yagl_native_display *(*wrap_display)(yagl_os_display /*os_dpy*/, |