Commit 11ff6a0e6f18d434ae0f9502ae0711977db6c22e
egl_android: Set surface type and native visual type.
| |   |
| 47 | 47 | /* these are usually used by a loader */ |
| 48 | 48 | const char *driver_name; |
| 49 | 49 | int (*initialize)(struct droid_backend *backend, int *fd, int *screen_number); |
| int (*process_config)(struct droid_backend *backend, _EGLConfig *conf); |
| 50 | 51 | void (*destroy)(struct droid_backend *backend); |
| 51 | 52 | |
| 52 | 53 | __DRIbuffer *(*get_native_buffer)(struct droid_backend *backend, |
| … | … | |
| 97 | 97 | void |
| 98 | 98 | droid_screen_destroy(struct droid_screen *screen); |
| 99 | 99 | |
| void |
| int |
| 101 | 101 | droid_screen_convert_config(struct droid_screen *screen, |
| 102 | 102 | const __DRIconfig *conf, _EGLConfig *egl_conf); |
| 103 | 103 | |
| |   |
| 565 | 565 | return 1; |
| 566 | 566 | } |
| 567 | 567 | |
| #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; |
| } |
|
| 568 | 596 | static void |
| 569 | 597 | intel_destroy(struct droid_backend *backend) |
| 570 | 598 | { |
| … | … | |
| 627 | 627 | |
| 628 | 628 | intel->base.driver_name = "i915"; |
| 629 | 629 | intel->base.initialize = intel_initialize; |
| intel->base.process_config = intel_process_config; |
| 630 | 631 | intel->base.destroy = intel_destroy; |
| 631 | 632 | |
| 632 | 633 | intel->base.get_native_buffer = intel_get_native_buffer; |
| |   |
| 357 | 357 | { EGL_STENCIL_SIZE, __DRI_ATTRIB_STENCIL_SIZE }, |
| 358 | 358 | }; |
| 359 | 359 | |
| void |
| int |
| 361 | 361 | droid_screen_convert_config(struct droid_screen *screen, |
| 362 | 362 | const __DRIconfig *conf, _EGLConfig *egl_conf) |
| 363 | 363 | { |
| … | … | |
| 374 | 374 | |
| 375 | 375 | if (!loader->core->getConfigAttrib(conf, dri_attrib, &dri_value)) { |
| 376 | 376 | LOGE("failed to get attribute %02d for %p", dri_attrib, conf); |
| continue; |
| return 0; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | switch (egl_attrib) { |
| … | … | |
| 392 | 392 | } |
| 393 | 393 | SET_CONFIG_ATTRIB(egl_conf, egl_attrib, egl_value); |
| 394 | 394 | } |
|
| return loader->backend->process_config(loader->backend, egl_conf); |
| 395 | 397 | } |
| 396 | 398 | |
| 397 | 399 | struct droid_context * |
| |   |
| 52 | 52 | { |
| 53 | 53 | return bytesPerPixel(format); |
| 54 | 54 | } |
|
| 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; |
| } |
| |   |
| 32 | 32 | |
| 33 | 33 | int ui_auth_gpu(drm_magic_t magic); |
| 34 | 34 | int ui_bytes_per_pixel(int format); |
| int ui_get_rgb_format(int red, int green, int blue, int alpha); |
| 35 | 36 | |
| 36 | 37 | #ifdef __cplusplus |
| 37 | 38 | } |
| |   |
| 137 | 137 | |
| 138 | 138 | _eglInitConfig(&droid_conf->base, id); |
| 139 | 139 | 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; |
| } |
| 142 | 145 | |
| 143 | 146 | val = GET_CONFIG_ATTRIB(&droid_conf->base, EGL_CONFIG_CAVEAT); |
| 144 | 147 | /* we do not want slow configs */ |