summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-10-27 17:19:39 +0800
committerChia-I Wu <olvaffe@gmail.com>2009-10-27 17:30:24 +0800
commit11ff6a0e6f18d434ae0f9502ae0711977db6c22e (patch)
tree560bfb6ee41d98a4b552dda20d3d1913d3e305e6
parentb4bf8be5470d54381878bf97750d958281a7c9c3 (diff)
egl_android: Set surface type and native visual type.
-rw-r--r--src/egl/drivers/android/droid.h3
-rw-r--r--src/egl/drivers/android/droid_intel.c29
-rw-r--r--src/egl/drivers/android/droid_loader.c6
-rw-r--r--src/egl/drivers/android/droid_ui.cpp27
-rw-r--r--src/egl/drivers/android/droid_ui.h1
-rw-r--r--src/egl/drivers/android/egl_android.c7
6 files changed, 68 insertions, 5 deletions
diff --git a/src/egl/drivers/android/droid.h b/src/egl/drivers/android/droid.h
index 1793f6a78c..06ca7ab9e7 100644
--- a/src/egl/drivers/android/droid.h
+++ b/src/egl/drivers/android/droid.h
@@ -47,6 +47,7 @@ struct droid_backend {
/* these are usually used by a loader */
const char *driver_name;
int (*initialize)(struct droid_backend *backend, int *fd, int *screen_number);
+ int (*process_config)(struct droid_backend *backend, _EGLConfig *conf);
void (*destroy)(struct droid_backend *backend);
__DRIbuffer *(*get_native_buffer)(struct droid_backend *backend,
@@ -96,7 +97,7 @@ droid_screen_create(struct droid_backend *backend);
void
droid_screen_destroy(struct droid_screen *screen);
-void
+int
droid_screen_convert_config(struct droid_screen *screen,
const __DRIconfig *conf, _EGLConfig *egl_conf);
diff --git a/src/egl/drivers/android/droid_intel.c b/src/egl/drivers/android/droid_intel.c
index 070b2706a9..32570b5ae0 100644
--- a/src/egl/drivers/android/droid_intel.c
+++ b/src/egl/drivers/android/droid_intel.c
@@ -565,6 +565,34 @@ intel_initialize(struct droid_backend *backend, int *fd, int *screen_number)
return 1;
}
+#include <assert.h>
+static int
+intel_process_config(struct droid_backend *backend, _EGLConfig *conf)
+{
+ int r, g, b, a;
+ int surface_type;
+ int format;
+
+ r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE);
+ g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE);
+ b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE);
+ a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE);
+ format = ui_get_rgb_format(r, g, b, a);
+
+ if (format) {
+ SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, format);
+ SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE,
+ EGL_WINDOW_BIT |
+ EGL_PIXMAP_BIT |
+ EGL_PBUFFER_BIT);
+ }
+ else {
+ SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
+ }
+
+ return 1;
+}
+
static void
intel_destroy(struct droid_backend *backend)
{
@@ -599,6 +627,7 @@ droid_backend_create_intel(const char *dev)
intel->base.driver_name = "i915";
intel->base.initialize = intel_initialize;
+ intel->base.process_config = intel_process_config;
intel->base.destroy = intel_destroy;
intel->base.get_native_buffer = intel_get_native_buffer;
diff --git a/src/egl/drivers/android/droid_loader.c b/src/egl/drivers/android/droid_loader.c
index 7dc846afb0..00b08a5960 100644
--- a/src/egl/drivers/android/droid_loader.c
+++ b/src/egl/drivers/android/droid_loader.c
@@ -357,7 +357,7 @@ static const struct {
{ EGL_STENCIL_SIZE, __DRI_ATTRIB_STENCIL_SIZE },
};
-void
+int
droid_screen_convert_config(struct droid_screen *screen,
const __DRIconfig *conf, _EGLConfig *egl_conf)
{
@@ -374,7 +374,7 @@ droid_screen_convert_config(struct droid_screen *screen,
if (!loader->core->getConfigAttrib(conf, dri_attrib, &dri_value)) {
LOGE("failed to get attribute %02d for %p", dri_attrib, conf);
- continue;
+ return 0;
}
switch (egl_attrib) {
@@ -392,6 +392,8 @@ droid_screen_convert_config(struct droid_screen *screen,
}
SET_CONFIG_ATTRIB(egl_conf, egl_attrib, egl_value);
}
+
+ return loader->backend->process_config(loader->backend, egl_conf);
}
struct droid_context *
diff --git a/src/egl/drivers/android/droid_ui.cpp b/src/egl/drivers/android/droid_ui.cpp
index 6ceff1b5fb..994480cdb7 100644
--- a/src/egl/drivers/android/droid_ui.cpp
+++ b/src/egl/drivers/android/droid_ui.cpp
@@ -52,3 +52,30 @@ int ui_bytes_per_pixel(int format)
{
return bytesPerPixel(format);
}
+
+int ui_get_rgb_format(int red, int green, int blue, int alpha)
+{
+ PixelFormatInfo info;
+ PixelFormat fmt;
+
+ /* look in the RGB range */
+ for (fmt = 1; fmt < PIXEL_FORMAT_YCbCr_422_SP; fmt++) {
+ status_t err = getPixelFormatInfo(fmt, &info);
+ if (err)
+ return -1;
+ /* bpp must be equal to depth */
+ if (info.bytesPerPixel * 8 != info.bitsPerPixel)
+ continue;
+
+ if ((info.h_red - info.l_red != red) ||
+ (info.h_green - info.l_green != green) ||
+ (info.h_blue - info.l_blue != blue) ||
+ (info.h_alpha - info.l_alpha != alpha))
+ continue;
+
+ /* mask? */
+ return fmt;
+ }
+
+ return -1;
+}
diff --git a/src/egl/drivers/android/droid_ui.h b/src/egl/drivers/android/droid_ui.h
index 3153ec849f..e7bdbf2a3f 100644
--- a/src/egl/drivers/android/droid_ui.h
+++ b/src/egl/drivers/android/droid_ui.h
@@ -32,6 +32,7 @@ extern "C" {
int ui_auth_gpu(drm_magic_t magic);
int ui_bytes_per_pixel(int format);
+int ui_get_rgb_format(int red, int green, int blue, int alpha);
#ifdef __cplusplus
}
diff --git a/src/egl/drivers/android/egl_android.c b/src/egl/drivers/android/egl_android.c
index 601e9fb09c..c1bc1f3224 100644
--- a/src/egl/drivers/android/egl_android.c
+++ b/src/egl/drivers/android/egl_android.c
@@ -137,8 +137,11 @@ droid_create_configs(_EGLDisplay *dpy, struct droid_egl_display *droid_dpy,
_eglInitConfig(&droid_conf->base, id);
droid_conf->config = configs[i];
- droid_screen_convert_config(droid_dpy->screen, droid_conf->config,
- &droid_conf->base);
+ if (!droid_screen_convert_config(droid_dpy->screen, droid_conf->config,
+ &droid_conf->base)) {
+ free(droid_conf);
+ continue;
+ }
val = GET_CONFIG_ATTRIB(&droid_conf->base, EGL_CONFIG_CAVEAT);
/* we do not want slow configs */