Commit 11ff6a0e6f18d434ae0f9502ae0711977db6c22e

  • avatar
  • Chia-I Wu <olvaffe @gm…l.com>
  • Tue Oct 27 10:30:24 CET 2009
egl_android: Set surface type and native visual type.
  
4747 /* these are usually used by a loader */
4848 const char *driver_name;
4949 int (*initialize)(struct droid_backend *backend, int *fd, int *screen_number);
50 int (*process_config)(struct droid_backend *backend, _EGLConfig *conf);
5051 void (*destroy)(struct droid_backend *backend);
5152
5253 __DRIbuffer *(*get_native_buffer)(struct droid_backend *backend,
9797void
9898droid_screen_destroy(struct droid_screen *screen);
9999
100void
100int
101101droid_screen_convert_config(struct droid_screen *screen,
102102 const __DRIconfig *conf, _EGLConfig *egl_conf);
103103
  
565565 return 1;
566566}
567567
568#include <assert.h>
569static int
570intel_process_config(struct droid_backend *backend, _EGLConfig *conf)
571{
572 int r, g, b, a;
573 int surface_type;
574 int format;
575
576 r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE);
577 g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE);
578 b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE);
579 a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE);
580 format = ui_get_rgb_format(r, g, b, a);
581
582 if (format) {
583 SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, format);
584 SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE,
585 EGL_WINDOW_BIT |
586 EGL_PIXMAP_BIT |
587 EGL_PBUFFER_BIT);
588 }
589 else {
590 SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
591 }
592
593 return 1;
594}
595
568596static void
569597intel_destroy(struct droid_backend *backend)
570598{
627627
628628 intel->base.driver_name = "i915";
629629 intel->base.initialize = intel_initialize;
630 intel->base.process_config = intel_process_config;
630631 intel->base.destroy = intel_destroy;
631632
632633 intel->base.get_native_buffer = intel_get_native_buffer;
  
357357 { EGL_STENCIL_SIZE, __DRI_ATTRIB_STENCIL_SIZE },
358358};
359359
360void
360int
361361droid_screen_convert_config(struct droid_screen *screen,
362362 const __DRIconfig *conf, _EGLConfig *egl_conf)
363363{
374374
375375 if (!loader->core->getConfigAttrib(conf, dri_attrib, &dri_value)) {
376376 LOGE("failed to get attribute %02d for %p", dri_attrib, conf);
377 continue;
377 return 0;
378378 }
379379
380380 switch (egl_attrib) {
392392 }
393393 SET_CONFIG_ATTRIB(egl_conf, egl_attrib, egl_value);
394394 }
395
396 return loader->backend->process_config(loader->backend, egl_conf);
395397}
396398
397399struct droid_context *
  
5252{
5353 return bytesPerPixel(format);
5454}
55
56int ui_get_rgb_format(int red, int green, int blue, int alpha)
57{
58 PixelFormatInfo info;
59 PixelFormat fmt;
60
61 /* look in the RGB range */
62 for (fmt = 1; fmt < PIXEL_FORMAT_YCbCr_422_SP; fmt++) {
63 status_t err = getPixelFormatInfo(fmt, &info);
64 if (err)
65 return -1;
66 /* bpp must be equal to depth */
67 if (info.bytesPerPixel * 8 != info.bitsPerPixel)
68 continue;
69
70 if ((info.h_red - info.l_red != red) ||
71 (info.h_green - info.l_green != green) ||
72 (info.h_blue - info.l_blue != blue) ||
73 (info.h_alpha - info.l_alpha != alpha))
74 continue;
75
76 /* mask? */
77 return fmt;
78 }
79
80 return -1;
81}
  
3232
3333int ui_auth_gpu(drm_magic_t magic);
3434int ui_bytes_per_pixel(int format);
35int ui_get_rgb_format(int red, int green, int blue, int alpha);
3536
3637#ifdef __cplusplus
3738}
  
137137
138138 _eglInitConfig(&droid_conf->base, id);
139139 droid_conf->config = configs[i];
140 droid_screen_convert_config(droid_dpy->screen, droid_conf->config,
141 &droid_conf->base);
140 if (!droid_screen_convert_config(droid_dpy->screen, droid_conf->config,
141 &droid_conf->base)) {
142 free(droid_conf);
143 continue;
144 }
142145
143146 val = GET_CONFIG_ATTRIB(&droid_conf->base, EGL_CONFIG_CAVEAT);
144147 /* we do not want slow configs */