summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2014-01-28 17:03:03 -0800
committerChad Versace <[email protected]>2014-03-17 15:39:23 -0700
commiteef68a9094396ee85f73a94911f8919d232b9a08 (patch)
tree1f349242fae19a69016a8defbd0035cc5f1367e2
parent88b9e600a6c9ad191c4cb9ba981b5aa15bbe2b81 (diff)
egl/dri2: Dispatch eglCreateImageKHR by display, not driver
Add dri2_egl_display_vtbl::create_image, set it for each platform, and let egl_dri2 dispatch eglCreateImageKHR to that. To remove ambiguity, rename egl_dri2.c:dri2_create_image() to dri2_create_image_from_dri(). This prepares for the EGL platform extensions. Signed-off-by: Chad Versace <[email protected]>
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c22
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h5
-rw-r--r--src/egl/drivers/dri2/platform_android.c9
-rw-r--r--src/egl/drivers/dri2/platform_drm.c3
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c1
-rw-r--r--src/egl/drivers/dri2/platform_x11.c13
6 files changed, 35 insertions, 18 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 722131cb934..76dc7734d9e 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1220,8 +1220,18 @@ dri2_release_tex_image(_EGLDriver *drv,
return EGL_TRUE;
}
+static _EGLImage*
+dri2_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+ EGLenum target, EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+ return dri2_dpy->vtbl->create_image(drv, dpy, ctx, target, buffer,
+ attr_list);
+}
+
static _EGLImage *
-dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image)
+dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
{
struct dri2_egl_image *dri2_img;
@@ -1265,7 +1275,7 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
renderbuffer, NULL);
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#ifdef HAVE_DRM_PLATFORM
@@ -1311,7 +1321,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
pitch,
NULL);
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#endif
@@ -1374,7 +1384,7 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
return NULL;
}
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#endif
@@ -1744,7 +1754,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
if (!dri_image)
return EGL_NO_IMAGE_KHR;
- res = dri2_create_image(disp, dri_image);
+ res = dri2_create_image_from_dri(disp, dri_image);
if (res)
dri2_take_dma_buf_ownership(fds, num_fds);
@@ -2157,7 +2167,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.PostSubBufferNV = dri2_post_sub_buffer;
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
- dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
+ dri2_drv->base.API.CreateImageKHR = dri2_create_image;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
#ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 104b86593f9..ad74015f733 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -109,6 +109,11 @@ struct dri2_egl_display_vtbl {
EGLBoolean (*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf, EGLint interval);
+ _EGLImage* (*create_image)(_EGLDriver *drv, _EGLDisplay *dpy,
+ _EGLContext *ctx, EGLenum target,
+ EGLClientBuffer buffer,
+ const EGLint *attr_list);
+
EGLBoolean (*swap_buffers)(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLSurface *surf);
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index e21ba137f44..db9edfaee57 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -421,12 +421,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
}
static void
-droid_init_driver_functions(_EGLDriver *drv)
-{
- drv->API.CreateImageKHR = droid_create_image_khr;
-}
-
-static void
droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
}
@@ -645,6 +639,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.create_pixmap_surface = dri2_fallback_pixmap_surface,
.create_pbuffer_surface = droid_create_pbuffer_surface,
.destroy_surface = droid_destroy_surface,
+ .create_image = droid_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -717,8 +712,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
dpy->VersionMajor = 1;
dpy->VersionMinor = 4;
- droid_init_driver_functions(drv);
-
/* Fill vtbl last to prevent accidentally calling virtual function during
* initialization.
*/
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 1459e68d48c..8f9149d98aa 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -447,6 +447,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_drm_destroy_surface,
+ .create_image = dri2_drm_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -549,8 +550,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
i + 1, EGL_WINDOW_BIT, attr_list, NULL);
}
- drv->API.CreateImageKHR = dri2_drm_create_image_khr;
-
disp->Extensions.EXT_buffer_age = EGL_TRUE;
#ifdef HAVE_WAYLAND_PLATFORM
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 78a3ae0e94c..02d70390fd2 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -938,6 +938,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_wl_destroy_surface,
+ .create_image = dri2_create_image_khr,
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 3c97a95c168..82f3ce9fdc0 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -993,12 +993,22 @@ dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
}
}
+static _EGLImage*
+dri2_x11_swrast_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
+ _EGLContext *ctx, EGLenum target,
+ EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ return NULL;
+}
+
static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
.authenticate = NULL,
.create_window_surface = dri2_x11_create_window_surface,
.create_pixmap_surface = dri2_x11_create_pixmap_surface,
.create_pbuffer_surface = dri2_x11_create_pbuffer_surface,
.destroy_surface = dri2_x11_destroy_surface,
+ .create_image = dri2_x11_swrast_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_x11_swap_buffers,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
@@ -1014,6 +1024,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
.create_pixmap_surface = dri2_x11_create_pixmap_surface,
.create_pbuffer_surface = dri2_x11_create_pbuffer_surface,
.destroy_surface = dri2_x11_destroy_surface,
+ .create_image = dri2_x11_create_image_khr,
.swap_interval = dri2_x11_swap_interval,
.swap_buffers = dri2_x11_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -1143,8 +1154,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
- drv->API.CreateImageKHR = dri2_x11_create_image_khr;
-
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");