}
static int
-get_back_bo(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer)
+get_back_bo(struct dri2_egl_surface *dri2_surf)
{
struct dri2_egl_display *dri2_dpy =
dri2_egl_display(dri2_surf->base.Resource.Display);
- struct gbm_dri_bo *bo;
struct gbm_dri_surface *surf = dri2_surf->gbm_surf;
- int i, name, pitch;
+ int i;
if (dri2_surf->back == NULL) {
for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
if (dri2_surf->back->bo == NULL)
return -1;
+ return 0;
+}
+
+static void
+back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer)
+{
+ struct dri2_egl_display *dri2_dpy =
+ dri2_egl_display(dri2_surf->base.Resource.Display);
+ struct gbm_dri_bo *bo;
+ int name, pitch;
+
bo = (struct gbm_dri_bo *) dri2_surf->back->bo;
dri2_dpy->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME, &name);
buffer->pitch = pitch;
buffer->cpp = 4;
buffer->flags = 0;
-
- return 0;
}
static int
switch (attachments[i]) {
case __DRI_BUFFER_BACK_LEFT:
- if (get_back_bo(dri2_surf, &dri2_surf->buffers[j]) < 0) {
+ if (get_back_bo(dri2_surf) < 0) {
_eglError(EGL_BAD_ALLOC, "failed to allocate color buffer");
return NULL;
}
+ back_bo_to_dri_buffer(dri2_surf, &dri2_surf->buffers[j]);
break;
default:
if (get_aux_bo(dri2_surf, attachments[i], attachments[i + 1],
return buffer;
}
+static int
+dri_image_get_buffers(__DRIdrawable *driDrawable,
+ unsigned int format,
+ uint32_t *stamp,
+ void *loaderPrivate,
+ uint32_t buffer_mask,
+ struct __DRIimageList *buffers)
+{
+ struct dri2_egl_surface *dri2_surf = loaderPrivate;
+ struct gbm_dri_bo *bo;
+
+ if (get_back_bo(dri2_surf) < 0)
+ return 0;
+
+ bo = (struct gbm_dri_bo *) dri2_surf->back->bo;
+ buffers->image_mask = __DRI_IMAGE_BUFFER_BACK;
+ buffers->back = bo->image;
+
+ return 1;
+}
+
static void
dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
_EGLDisplay *disp, _EGLSurface *surface)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface);
- __DRIbuffer buffer;
- if (get_back_bo(dri2_surf, &buffer) < 0) {
+ if (get_back_bo(dri2_surf) < 0) {
_eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age");
return 0;
}
dri2_dpy->gbm_dri->get_buffers = dri2_get_buffers;
dri2_dpy->gbm_dri->flush_front_buffer = dri2_flush_front_buffer;
dri2_dpy->gbm_dri->get_buffers_with_format = dri2_get_buffers_with_format;
+ dri2_dpy->gbm_dri->image_get_buffers = dri_image_get_buffers;
dri2_dpy->gbm_dri->base.base.surface_lock_front_buffer = lock_front_buffer;
dri2_dpy->gbm_dri->base.base.surface_release_buffer = release_buffer;
count, out_count, surf->dri_private);
}
+static int
+image_get_buffers(__DRIdrawable *driDrawable,
+ unsigned int format,
+ uint32_t *stamp,
+ void *loaderPrivate,
+ uint32_t buffer_mask,
+ struct __DRIimageList *buffers)
+{
+ struct gbm_dri_surface *surf = loaderPrivate;
+ struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
+
+ if (dri->image_get_buffers == NULL)
+ return 0;
+
+ return dri->image_get_buffers(driDrawable, format, stamp,
+ surf->dri_private, buffer_mask, buffers);
+}
+
static const __DRIuseInvalidateExtension use_invalidate = {
{ __DRI_USE_INVALIDATE, 1 }
};
dri_get_buffers_with_format,
};
+const __DRIimageLoaderExtension image_loader_extension = {
+ { __DRI_IMAGE_LOADER, 1 },
+ image_get_buffers,
+ dri_flush_front_buffer,
+};
+
+
struct dri_extension_match {
const char *name;
int version;
dri->extensions[0] = &image_lookup_extension.base;
dri->extensions[1] = &use_invalidate.base;
dri->extensions[2] = &dri2_loader_extension.base;
- dri->extensions[3] = NULL;
+ dri->extensions[3] = &image_loader_extension.base;
+ dri->extensions[4] = NULL;
if (dri->dri2 == NULL)
return -1;
__DRIdri2LoaderExtension *loader;
const __DRIconfig **driver_configs;
- const __DRIextension *extensions[4];
+ const __DRIextension *extensions[5];
const __DRIextension **driver_extensions;
__DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *data);
+ int (*image_get_buffers)(__DRIdrawable *driDrawable,
+ unsigned int format,
+ uint32_t *stamp,
+ void *loaderPrivate,
+ uint32_t buffer_mask,
+ struct __DRIimageList *buffers);
struct wl_drm *wl_drm;
};