return stapi;
}
+struct egl_g3d_choose_config_data {
+ _EGLConfig criteria;
+ enum pipe_format format;
+};
+
static int
egl_g3d_compare_config(const _EGLConfig *conf1, const _EGLConfig *conf2,
void *priv_data)
{
- const _EGLConfig *criteria = (const _EGLConfig *) priv_data;
+ struct egl_g3d_choose_config_data *data =
+ (struct egl_g3d_choose_config_data *) priv_data;
+ const _EGLConfig *criteria = &data->criteria;;
/* EGL_NATIVE_VISUAL_TYPE ignored? */
return _eglCompareConfigs(conf1, conf2, criteria, EGL_TRUE);
static EGLBoolean
egl_g3d_match_config(const _EGLConfig *conf, void *priv_data)
{
- const _EGLConfig *criteria = (const _EGLConfig *) priv_data;
+ struct egl_g3d_choose_config_data *data =
+ (struct egl_g3d_choose_config_data *) priv_data;
+ struct egl_g3d_config *gconf = egl_g3d_config(conf);
- if (!_eglMatchConfig(conf, criteria))
+ if (data->format != PIPE_FORMAT_NONE &&
+ data->format != gconf->native->color_format)
return EGL_FALSE;
- if (criteria->MatchNativePixmap != EGL_NONE &&
- criteria->MatchNativePixmap != EGL_DONT_CARE) {
- struct egl_g3d_display *gdpy = egl_g3d_display(conf->Display);
- struct egl_g3d_config *gconf = egl_g3d_config(conf);
- EGLNativePixmapType pix =
- (EGLNativePixmapType) criteria->MatchNativePixmap;
-
- if (!gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native))
- return EGL_FALSE;
- }
-
- return EGL_TRUE;
+ return _eglMatchConfig(conf, &data->criteria);
}
static EGLBoolean
egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
EGLConfig *configs, EGLint size, EGLint *num_configs)
{
- _EGLConfig criteria;
+ struct egl_g3d_choose_config_data data;
- if (!_eglParseConfigAttribList(&criteria, dpy, attribs))
+ if (!_eglParseConfigAttribList(&data.criteria, dpy, attribs))
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
+ data.format = PIPE_FORMAT_NONE;
+ if (data.criteria.MatchNativePixmap != EGL_NONE &&
+ data.criteria.MatchNativePixmap != EGL_DONT_CARE) {
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+
+ if (!gdpy->native->get_pixmap_format(gdpy->native,
+ (EGLNativePixmapType) data.criteria.MatchNativePixmap,
+ &data.format))
+ return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglChooseConfig");
+ }
+
return _eglFilterConfigArray(dpy->Configs, configs, size, num_configs,
- egl_g3d_match_config, egl_g3d_compare_config, &criteria);
+ egl_g3d_match_config, egl_g3d_compare_config, &data);
}
static _EGLContext *
int *num_configs);
/**
- * Test if a pixmap is supported by the given config. Required unless no
- * config has pixmap_bit set.
- *
- * This function is usually called to find a config that supports a given
- * pixmap. Thus, it is usually called with the same pixmap in a row.
- *
- * TODO should be get_pixmap_format() and return the pipe format of the
- * pixmap.
+ * Get the color format of the pixmap. Required unless no config has
+ * pixmap_bit set.
*/
- boolean (*is_pixmap_supported)(struct native_display *ndpy,
- EGLNativePixmapType pix,
- const struct native_config *nconf);
+ boolean (*get_pixmap_format)(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ enum pipe_format *format);
/**
* Copy the contents of the resource to the pixmap's front-left attachment.
}
static boolean
-wayland_display_is_pixmap_supported(struct native_display *ndpy,
- EGLNativePixmapType pix,
- const struct native_config *nconf)
+wayland_display_get_pixmap_format(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ enum pipe_format *format)
{
/* all wl_egl_pixmaps are supported */
+ *format = PIPE_FORMAT_NONE;
return TRUE;
}
display->base.get_param = wayland_display_get_param;
display->base.get_configs = wayland_display_get_configs;
- display->base.is_pixmap_supported = wayland_display_is_pixmap_supported;
+ display->base.get_pixmap_format = wayland_display_get_pixmap_format;
display->base.copy_to_pixmap = native_display_copy_to_pixmap;
display->base.create_window_surface = wayland_create_window_surface;
display->base.create_pixmap_surface = wayland_create_pixmap_surface;
}
static boolean
-dri2_display_is_pixmap_supported(struct native_display *ndpy,
- EGLNativePixmapType pix,
- const struct native_config *nconf)
+dri2_display_get_pixmap_format(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ enum pipe_format *format)
{
struct dri2_display *dri2dpy = dri2_display(ndpy);
- uint depth, nconf_depth;
+ boolean ret = EGL_TRUE;
+ uint depth;
depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix);
- nconf_depth = util_format_get_blocksizebits(nconf->color_format);
+ switch (depth) {
+ case 32:
+ case 24:
+ *format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+ case 16:
+ *format = PIPE_FORMAT_B5G6R5_UNORM;
+ break;
+ default:
+ *format = PIPE_FORMAT_NONE;
+ ret = EGL_FALSE;
+ break;
+ }
- /* simple depth match for now */
- return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));
+ return ret;
}
static int
dri2dpy->base.destroy = dri2_display_destroy;
dri2dpy->base.get_param = dri2_display_get_param;
dri2dpy->base.get_configs = dri2_display_get_configs;
- dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
+ dri2dpy->base.get_pixmap_format = dri2_display_get_pixmap_format;
dri2dpy->base.copy_to_pixmap = native_display_copy_to_pixmap;
dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
}
static boolean
-ximage_display_is_pixmap_supported(struct native_display *ndpy,
- EGLNativePixmapType pix,
- const struct native_config *nconf)
+ximage_display_get_pixmap_format(struct native_display *ndpy,
+ EGLNativePixmapType pix,
+ enum pipe_format *format)
{
struct ximage_display *xdpy = ximage_display(ndpy);
- enum pipe_format fmt = get_pixmap_format(&xdpy->base, pix);
- return (fmt == nconf->color_format);
+ *format = get_pixmap_format(&xdpy->base, pix);
+
+ return (*format != PIPE_FORMAT_NONE);
}
static boolean
xdpy->base.get_param = ximage_display_get_param;
xdpy->base.get_configs = ximage_display_get_configs;
- xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported;
+ xdpy->base.get_pixmap_format = ximage_display_get_pixmap_format;
xdpy->base.copy_to_pixmap = ximage_display_copy_to_pixmap;
xdpy->base.create_window_surface = ximage_display_create_window_surface;
xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface;