Commit f457f7a31c03f218cdcb31108fefb343d6be14a8
- Diff rendering mode:
- inline
- side by side
|   | |||
| 64 | 64 | _EGLSurface *surf, | |
| 65 | 65 | NativeWindowType win); | |
| 66 | 66 | struct droid_surface *(*create_image_surface)(struct droid_backend *backend, | |
| 67 | NativePixmapType pix, | ||
| 68 | int *depth); | ||
| 67 | NativePixmapType pix); | ||
| 69 | 68 | void (*destroy_surface)(struct droid_backend *backend, struct droid_surface *surf); | |
| 70 | 69 | void (*swap_native_buffers)(struct droid_backend *backend, | |
| 71 | 70 | struct droid_surface *surf); | |
| 71 | |||
| 72 | int (*match_pixmap)(struct droid_backend *backend, _EGLConfig *conf, | ||
| 73 | NativePixmapType pix); | ||
| 72 | 74 | }; | |
| 73 | 75 | ||
| 74 | 76 | struct droid_screen { | |
| … | … | ||
| 82 | 82 | ||
| 83 | 83 | const __DRIconfig **dri_configs; | |
| 84 | 84 | int num_dri_configs; | |
| 85 | |||
| 86 | #define DROID_MAX_IMAGE_DEPTH 32 | ||
| 87 | const __DRIconfig *image_configs[DROID_MAX_IMAGE_DEPTH + 1]; | ||
| 88 | 85 | }; | |
| 89 | 86 | ||
| 90 | 87 | struct droid_backend * |
|   | |||
| 472 | 472 | ||
| 473 | 473 | static struct droid_surface * | |
| 474 | 474 | intel_create_image_surface(struct droid_backend *backend, | |
| 475 | NativePixmapType pix, int *depth) | ||
| 475 | NativePixmapType pix) | ||
| 476 | 476 | { | |
| 477 | 477 | struct droid_surface_intel *isurf; | |
| 478 | 478 | int cpp; | |
| … | … | ||
| 490 | 490 | return NULL; | |
| 491 | 491 | } | |
| 492 | 492 | ||
| 493 | cpp = ui_bytes_per_pixel(pix->format); | ||
| 494 | if (cpp * 8 > DROID_MAX_IMAGE_DEPTH) { | ||
| 495 | LOGE("pixmap of depth %d is not supported", cpp * 8); | ||
| 496 | _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCreateImage"); | ||
| 497 | return NULL; | ||
| 498 | } | ||
| 499 | |||
| 500 | 493 | isurf = calloc(1, sizeof(*isurf)); | |
| 501 | 494 | if (!isurf) { | |
| 502 | 495 | _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); | |
| … | … | ||
| 501 | 501 | ||
| 502 | 502 | update_native_buffer((struct droid_surface *) isurf); | |
| 503 | 503 | ||
| 504 | if (depth) | ||
| 505 | *depth = cpp * 8; | ||
| 506 | |||
| 507 | 504 | return (struct droid_surface *) isurf; | |
| 508 | 505 | } | |
| 509 | 506 | ||
| … | … | ||
| 532 | 532 | } | |
| 533 | 533 | ||
| 534 | 534 | static int | |
| 535 | intel_match_pixmap(struct droid_backend *backend, _EGLConfig *conf, | ||
| 536 | NativePixmapType pix) | ||
| 537 | { | ||
| 538 | int val; | ||
| 539 | val = GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE); | ||
| 540 | /* match the visual type */ | ||
| 541 | return (pix->format == val); | ||
| 542 | } | ||
| 543 | |||
| 544 | static int | ||
| 535 | 545 | intel_initialize(struct droid_backend *backend, int *fd, int *screen_number) | |
| 536 | 546 | { | |
| 537 | 547 | struct droid_backend_intel *intel = lookup_backend(backend); | |
| … | … | ||
| 637 | 637 | intel->base.create_image_surface = intel_create_image_surface; | |
| 638 | 638 | intel->base.destroy_surface = intel_destroy_surface; | |
| 639 | 639 | intel->base.swap_native_buffers = intel_swap_native_buffers; | |
| 640 | |||
| 641 | intel->base.match_pixmap = intel_match_pixmap; | ||
| 640 | 642 | ||
| 641 | 643 | return &intel->base; | |
| 642 | 644 | } |
|   | |||
| 209 | 209 | backend->destroy(backend); | |
| 210 | 210 | } | |
| 211 | 211 | ||
| 212 | static void | ||
| 213 | screen_find_image_configs(struct droid_screen *screen) | ||
| 214 | { | ||
| 215 | struct droid_loader *loader = screen->loader; | ||
| 216 | int depth, i; | ||
| 217 | |||
| 218 | for (depth = 0; depth < DROID_MAX_IMAGE_DEPTH + 1; depth++) { | ||
| 219 | for (i = 0; i < screen->num_dri_configs; i++) { | ||
| 220 | const __DRIconfig *conf = screen->dri_configs[i]; | ||
| 221 | _EGLConfig egl_conf; | ||
| 222 | EGLint rgba, val; | ||
| 223 | |||
| 224 | droid_screen_convert_config(screen, conf, &egl_conf); | ||
| 225 | |||
| 226 | val = GET_CONFIG_ATTRIB(&egl_conf, EGL_CONFIG_CAVEAT); | ||
| 227 | if (val == EGL_SLOW_CONFIG) | ||
| 228 | continue; | ||
| 229 | |||
| 230 | rgba = GET_CONFIG_ATTRIB(&egl_conf, EGL_RED_SIZE); | ||
| 231 | rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_GREEN_SIZE); | ||
| 232 | rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_BLUE_SIZE); | ||
| 233 | rgba += GET_CONFIG_ATTRIB(&egl_conf, EGL_ALPHA_SIZE); | ||
| 234 | if (depth != rgba) | ||
| 235 | continue; | ||
| 236 | |||
| 237 | if (depth == 32) { | ||
| 238 | val = GET_CONFIG_ATTRIB(&egl_conf, EGL_BIND_TO_TEXTURE_RGBA); | ||
| 239 | if (val) { | ||
| 240 | screen->image_configs[depth] = conf; | ||
| 241 | break; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | val = GET_CONFIG_ATTRIB(&egl_conf, EGL_BIND_TO_TEXTURE_RGB); | ||
| 246 | if (val) { | ||
| 247 | screen->image_configs[depth] = conf; | ||
| 248 | break; | ||
| 249 | } | ||
| 250 | } | ||
| 251 | } | ||
| 252 | } | ||
| 253 | |||
| 254 | 212 | struct droid_screen * | |
| 255 | 213 | droid_screen_create(struct droid_backend *backend) | |
| 256 | 214 | { | |
| … | … | ||
| 271 | 271 | ; | |
| 272 | 272 | screen->num_dri_configs = i; | |
| 273 | 273 | ||
| 274 | screen_find_image_configs(screen); | ||
| 275 | |||
| 276 | 274 | return screen; | |
| 277 | 275 | ||
| 278 | 276 | fail: | |
| … | … | ||
| 436 | 436 | img->magic = __DRI_EGL_IMAGE_MAGIC; | |
| 437 | 437 | img->drawable = drawable->dri_drawable; | |
| 438 | 438 | img->level = 0; | |
| 439 | if (drawable->dri_config == screen->image_configs[32] && | ||
| 440 | loader->core->getConfigAttrib(drawable->dri_config, | ||
| 441 | __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, | ||
| 442 | &val)) | ||
| 443 | img->texture_format_rgba = val; | ||
| 439 | if (loader->core->getConfigAttrib(drawable->dri_config, | ||
| 440 | __DRI_ATTRIB_ALPHA_SIZE, &val)) | ||
| 441 | img->texture_format_rgba = (val > 0); | ||
| 444 | 442 | ||
| 445 | 443 | drawable->dri_image = img; | |
| 446 | 444 | } |
|   | |||
| 412 | 412 | { | |
| 413 | 413 | struct droid_egl_display *droid_dpy = lookup_display(dpy); | |
| 414 | 414 | struct droid_egl_image *droid_img; | |
| 415 | const __DRIconfig *dri_conf; | ||
| 416 | int depth; | ||
| 415 | struct droid_egl_config *droid_conf; | ||
| 416 | _EGLConfig *conf; | ||
| 417 | EGLint val, i; | ||
| 417 | 418 | ||
| 419 | /* only EGL_KHR_image_pixmap is supported */ | ||
| 418 | 420 | if (target != EGL_NATIVE_PIXMAP_KHR || ctx) { | |
| 419 | 421 | _eglError(EGL_BAD_PARAMETER, "eglCreateImageKHR"); | |
| 420 | 422 | return NULL; | |
| 421 | 423 | } | |
| 422 | 424 | ||
| 425 | for (i = 0; i < dpy->NumConfigs; i++) { | ||
| 426 | conf = dpy->Configs[i]; | ||
| 427 | if (droid_dpy->backend->match_pixmap(droid_dpy->backend, conf, | ||
| 428 | (NativePixmapType) buffer)) { | ||
| 429 | EGLint val; | ||
| 430 | val = GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB); | ||
| 431 | val |= GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA); | ||
| 432 | if (val) | ||
| 433 | break; | ||
| 434 | } | ||
| 435 | } | ||
| 436 | if (i >= dpy->NumConfigs) | ||
| 437 | return NULL; | ||
| 438 | |||
| 423 | 439 | droid_img = calloc(1, sizeof(*droid_img)); | |
| 424 | 440 | if (!droid_img) { | |
| 425 | 441 | _eglError(EGL_BAD_ALLOC, "eglCreateImageKHR"); | |
| … | … | ||
| 449 | 449 | ||
| 450 | 450 | droid_img->surface = | |
| 451 | 451 | droid_dpy->backend->create_image_surface(droid_dpy->backend, | |
| 452 | (NativePixmapType) buffer, | ||
| 453 | &depth); | ||
| 452 | (NativePixmapType) buffer); | ||
| 454 | 453 | if (!droid_img->surface) { | |
| 455 | 454 | free(droid_img); | |
| 456 | 455 | return NULL; | |
| 457 | 456 | } | |
| 458 | 457 | ||
| 459 | dri_conf = droid_dpy->screen->image_configs[depth]; | ||
| 460 | if (!dri_conf) { | ||
| 461 | droid_dpy->backend->destroy_surface(droid_dpy->backend, | ||
| 462 | droid_img->surface); | ||
| 463 | free(droid_img); | ||
| 464 | return NULL; | ||
| 465 | } | ||
| 466 | |||
| 458 | droid_conf = lookup_config(conf); | ||
| 467 | 459 | droid_img->drawable = | |
| 468 | droid_screen_create_drawable(droid_dpy->screen, dri_conf, | ||
| 460 | droid_screen_create_drawable(droid_dpy->screen, droid_conf->config, | ||
| 469 | 461 | droid_img->surface); | |
| 470 | 462 | ||
| 471 | 463 | if (!droid_img->drawable) { |

