#include "egl_g3d_api.h"
#include "egl_g3d_image.h"
-/* move this to native display? */
+/* for struct winsys_handle */
#include "state_tracker/drm_driver.h"
/**
_EGLImage *img, const EGLint *attribs)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- struct pipe_screen *screen = gdpy->native->screen;
struct pipe_resource templ;
struct winsys_handle wsh;
_EGLImageAttribs attrs;
EGLint format;
- /* winsys_handle is in theory platform-specific */
if (dpy->Platform != _EGL_PLATFORM_DRM)
return NULL;
wsh.stride =
attrs.DRMBufferStrideMESA * util_format_get_blocksize(templ.format);
- return screen->resource_from_handle(screen, &templ, &wsh);
+ return gdpy->native->buffer->import_buffer(gdpy->native, &templ, &wsh);
}
#endif /* EGL_MESA_drm_image */
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct egl_g3d_image *gimg = egl_g3d_image(img);
- struct pipe_screen *screen = gdpy->native->screen;
struct winsys_handle wsh;
- /* winsys_handle is in theory platform-specific */
if (dpy->Platform != _EGL_PLATFORM_DRM)
return EGL_FALSE;
if (name) {
memset(&handle, 0, sizeof(handle));
wsh.type = DRM_API_HANDLE_TYPE_SHARED;
- if (!screen->resource_get_handle(screen, gimg->texture, &wsh)) {
+ if (!gdpy->native->buffer->export_buffer(gdpy->native,
+ gimg->texture, &wsh))
return EGL_FALSE;
- }
*name = wsh.handle;
}
if (handle || stride) {
memset(&wsh, 0, sizeof(wsh));
wsh.type = DRM_API_HANDLE_TYPE_KMS;
- if (!screen->resource_get_handle(screen, gimg->texture, &wsh))
+ if (!gdpy->native->buffer->export_buffer(gdpy->native,
+ gimg->texture, &wsh))
return EGL_FALSE;
if (handle)
return TRUE;
}
+static struct pipe_resource *
+drm_display_import_buffer(struct native_display *ndpy,
+ const struct pipe_resource *templ,
+ void *buf)
+{
+ return ndpy->screen->resource_from_handle(ndpy->screen,
+ templ, (struct winsys_handle *) buf);
+}
+
+static boolean
+drm_display_export_buffer(struct native_display *ndpy,
+ struct pipe_resource *res,
+ void *buf)
+{
+ return ndpy->screen->resource_get_handle(ndpy->screen,
+ res, (struct winsys_handle *) buf);
+}
+
+static struct native_display_buffer drm_display_buffer = {
+ drm_display_import_buffer,
+ drm_display_export_buffer
+};
+
static struct native_display *
drm_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
drmdpy->base.get_param = drm_display_get_param;
drmdpy->base.get_configs = drm_display_get_configs;
+ drmdpy->base.buffer = &drm_display_buffer;
drm_display_init_modeset(&drmdpy->base);
return &drmdpy->base;