summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2009-10-27 16:15:54 +0800
committerChia-I Wu <[email protected]>2009-10-27 17:45:13 +0800
commitf457f7a31c03f218cdcb31108fefb343d6be14a8 (patch)
treea44a14177d08286f192e3ec4f9d1102e405bf44b
parent11ff6a0e6f18d434ae0f9502ae0711977db6c22e (diff)
egl_android: Decide image config by matching the native pixmap.
-rw-r--r--src/egl/drivers/android/droid.h9
-rw-r--r--src/egl/drivers/android/droid_intel.c24
-rw-r--r--src/egl/drivers/android/droid_loader.c52
-rw-r--r--src/egl/drivers/android/egl_android.c34
4 files changed, 41 insertions, 78 deletions
diff --git a/src/egl/drivers/android/droid.h b/src/egl/drivers/android/droid.h
index 06ca7ab9e7f..7a8c7251579 100644
--- a/src/egl/drivers/android/droid.h
+++ b/src/egl/drivers/android/droid.h
@@ -64,11 +64,13 @@ struct droid_backend {
_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 {
@@ -80,9 +82,6 @@ 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 *
diff --git a/src/egl/drivers/android/droid_intel.c b/src/egl/drivers/android/droid_intel.c
index 32570b5ae03..3209ff9af73 100644
--- a/src/egl/drivers/android/droid_intel.c
+++ b/src/egl/drivers/android/droid_intel.c
@@ -472,7 +472,7 @@ intel_create_window_surface(struct droid_backend *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;
@@ -490,13 +490,6 @@ intel_create_image_surface(struct droid_backend *backend,
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");
@@ -508,9 +501,6 @@ intel_create_image_surface(struct droid_backend *backend,
update_native_buffer((struct droid_surface *) isurf);
- if (depth)
- *depth = cpp * 8;
-
return (struct droid_surface *) isurf;
}
@@ -542,6 +532,16 @@ intel_swap_native_buffers(struct droid_backend *backend,
}
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);
@@ -638,5 +638,7 @@ droid_backend_create_intel(const char *dev)
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;
}
diff --git a/src/egl/drivers/android/droid_loader.c b/src/egl/drivers/android/droid_loader.c
index 00b08a5960d..7832885d1d1 100644
--- a/src/egl/drivers/android/droid_loader.c
+++ b/src/egl/drivers/android/droid_loader.c
@@ -209,48 +209,6 @@ droid_backend_destroy(struct droid_backend *backend)
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)
{
@@ -313,8 +271,6 @@ droid_screen_create(struct droid_backend *backend)
;
screen->num_dri_configs = i;
- screen_find_image_configs(screen);
-
return screen;
fail:
@@ -480,11 +436,9 @@ droid_screen_get_drawable_data(struct droid_screen *screen,
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;
}
diff --git a/src/egl/drivers/android/egl_android.c b/src/egl/drivers/android/egl_android.c
index c1bc1f32241..d8eb5fd463f 100644
--- a/src/egl/drivers/android/egl_android.c
+++ b/src/egl/drivers/android/egl_android.c
@@ -412,14 +412,30 @@ droid_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
{
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");
@@ -433,23 +449,15 @@ droid_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
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) {