_EGLSurface *surf,
NativeWindowType win);
struct droid_surface *(*create_image_surface)(struct droid_backend *backend,
- NativePixmapType pix,
- int *depth);
+ NativePixmapType pix);
void (*destroy_surface)(struct droid_backend *backend, struct droid_surface *surf);
void (*swap_native_buffers)(struct droid_backend *backend,
struct droid_surface *surf);
+
+ int (*match_pixmap)(struct droid_backend *backend, _EGLConfig *conf,
+ NativePixmapType pix);
};
struct droid_screen {
const __DRIconfig **dri_configs;
int num_dri_configs;
-
-#define DROID_MAX_IMAGE_DEPTH 32
- const __DRIconfig *image_configs[DROID_MAX_IMAGE_DEPTH + 1];
};
struct droid_backend *
static struct droid_surface *
intel_create_image_surface(struct droid_backend *backend,
- NativePixmapType pix, int *depth)
+ NativePixmapType pix)
{
struct droid_surface_intel *isurf;
int cpp;
return NULL;
}
- cpp = ui_bytes_per_pixel(pix->format);
- if (cpp * 8 > DROID_MAX_IMAGE_DEPTH) {
- LOGE("pixmap of depth %d is not supported", cpp * 8);
- _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCreateImage");
- return NULL;
- }
-
isurf = calloc(1, sizeof(*isurf));
if (!isurf) {
_eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
update_native_buffer((struct droid_surface *) isurf);
- if (depth)
- *depth = cpp * 8;
-
return (struct droid_surface *) isurf;
}
}
static int
+intel_match_pixmap(struct droid_backend *backend, _EGLConfig *conf,
+ NativePixmapType pix)
+{
+ int val;
+ val = GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE);
+ /* match the visual type */
+ return (pix->format == val);
+}
+
+static int
intel_initialize(struct droid_backend *backend, int *fd, int *screen_number)
{
struct droid_backend_intel *intel = lookup_backend(backend);
intel->base.destroy_surface = intel_destroy_surface;
intel->base.swap_native_buffers = intel_swap_native_buffers;
+ intel->base.match_pixmap = intel_match_pixmap;
+
return &intel->base;
}
backend->destroy(backend);
}
-static void
-screen_find_image_configs(struct droid_screen *screen)
-{
- struct droid_loader *loader = screen->loader;
- int depth, i;
-
- for (depth = 0; depth < DROID_MAX_IMAGE_DEPTH + 1; depth++) {
- for (i = 0; i < screen->num_dri_configs; i++) {
- const __DRIconfig *conf = screen->dri_configs[i];
- _EGLConfig egl_conf;
- EGLint rgba, val;
-
- droid_screen_convert_config(screen, conf, &egl_conf);
-
- val = GET_CONFIG_ATTRIB(&egl_conf, EGL_CONFIG_CAVEAT);
- if (val == EGL_SLOW_CONFIG)
- continue;
-
- rgba = GET_CONFIG_ATTRIB(&egl_conf, EGL_RED_SIZE);
- rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_GREEN_SIZE);
- rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_BLUE_SIZE);
- rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_ALPHA_SIZE);
- if (depth != rgba)
- continue;
-
- if (depth == 32) {
- val = GET_CONFIG_ATTRIB(&egl_conf, EGL_BIND_TO_TEXTURE_RGBA);
- if (val) {
- screen->image_configs[depth] = conf;
- break;
- }
- }
-
- val = GET_CONFIG_ATTRIB(&egl_conf, EGL_BIND_TO_TEXTURE_RGB);
- if (val) {
- screen->image_configs[depth] = conf;
- break;
- }
- }
- }
-}
-
struct droid_screen *
droid_screen_create(struct droid_backend *backend)
{
;
screen->num_dri_configs = i;
- screen_find_image_configs(screen);
-
return screen;
fail:
img->magic = __DRI_EGL_IMAGE_MAGIC;
img->drawable = drawable->dri_drawable;
img->level = 0;
- if (drawable->dri_config == screen->image_configs[32] &&
- loader->core->getConfigAttrib(drawable->dri_config,
- __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA,
- &val))
- img->texture_format_rgba = val;
+ if (loader->core->getConfigAttrib(drawable->dri_config,
+ __DRI_ATTRIB_ALPHA_SIZE, &val))
+ img->texture_format_rgba = (val > 0);
drawable->dri_image = img;
}
{
struct droid_egl_display *droid_dpy = lookup_display(dpy);
struct droid_egl_image *droid_img;
- const __DRIconfig *dri_conf;
- int depth;
+ struct droid_egl_config *droid_conf;
+ _EGLConfig *conf;
+ EGLint val, i;
+ /* only EGL_KHR_image_pixmap is supported */
if (target != EGL_NATIVE_PIXMAP_KHR || ctx) {
_eglError(EGL_BAD_PARAMETER, "eglCreateImageKHR");
return NULL;
}
+ for (i = 0; i < dpy->NumConfigs; i++) {
+ conf = dpy->Configs[i];
+ if (droid_dpy->backend->match_pixmap(droid_dpy->backend, conf,
+ (NativePixmapType) buffer)) {
+ EGLint val;
+ val = GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB);
+ val |= GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA);
+ if (val)
+ break;
+ }
+ }
+ if (i >= dpy->NumConfigs)
+ return NULL;
+
droid_img = calloc(1, sizeof(*droid_img));
if (!droid_img) {
_eglError(EGL_BAD_ALLOC, "eglCreateImageKHR");
droid_img->surface =
droid_dpy->backend->create_image_surface(droid_dpy->backend,
- (NativePixmapType) buffer,
- &depth);
+ (NativePixmapType) buffer);
if (!droid_img->surface) {
free(droid_img);
return NULL;
}
- dri_conf = droid_dpy->screen->image_configs[depth];
- if (!dri_conf) {
- droid_dpy->backend->destroy_surface(droid_dpy->backend,
- droid_img->surface);
- free(droid_img);
- return NULL;
- }
-
+ droid_conf = lookup_config(conf);
droid_img->drawable =
- droid_screen_create_drawable(droid_dpy->screen, dri_conf,
+ droid_screen_create_drawable(droid_dpy->screen, droid_conf->config,
droid_img->surface);
if (!droid_img->drawable) {