/* 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,
void
droid_screen_destroy(struct droid_screen *screen);
-void
+int
droid_screen_convert_config(struct droid_screen *screen,
const __DRIconfig *conf, _EGLConfig *egl_conf);
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)
{
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;
{ EGL_STENCIL_SIZE, __DRI_ATTRIB_STENCIL_SIZE },
};
-void
+int
droid_screen_convert_config(struct droid_screen *screen,
const __DRIconfig *conf, _EGLConfig *egl_conf)
{
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) {
}
SET_CONFIG_ATTRIB(egl_conf, egl_attrib, egl_value);
}
+
+ return loader->backend->process_config(loader->backend, egl_conf);
}
struct droid_context *
{
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;
+}
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
}
_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 */