Mercurial > MadButterfly
comparison src/graph_engine_openvg.c @ 629:608f58b9b84d openvg
Use color transform and make compatible with OpenVG 1.0.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 17 Jul 2010 21:44:23 +0800 |
parents | 97bf0ff7a038 |
children | bd18951b51d5 |
comparison
equal
deleted
inserted
replaced
628:e50c4e111698 | 629:608f58b9b84d |
---|---|
430 attrib_list[i++] = 8; | 430 attrib_list[i++] = 8; |
431 attrib_list[i++] = EGL_BLUE_SIZE; | 431 attrib_list[i++] = EGL_BLUE_SIZE; |
432 attrib_list[i++] = 8; | 432 attrib_list[i++] = 8; |
433 attrib_list[i++] = EGL_ALPHA_SIZE; | 433 attrib_list[i++] = EGL_ALPHA_SIZE; |
434 attrib_list[i++] = 8; | 434 attrib_list[i++] = 8; |
435 attrib_list[i++] = EGL_ALPHA_MASK_SIZE; | |
436 attrib_list[i++] = 8; | |
437 break; | 435 break; |
438 | 436 |
439 case MB_IFMT_RGB24: | 437 case MB_IFMT_RGB24: |
440 attrib_list[i++] = EGL_RED_SIZE; | 438 attrib_list[i++] = EGL_RED_SIZE; |
441 attrib_list[i++] = 8; | 439 attrib_list[i++] = 8; |
442 attrib_list[i++] = EGL_GREEN_SIZE; | 440 attrib_list[i++] = EGL_GREEN_SIZE; |
443 attrib_list[i++] = 8; | 441 attrib_list[i++] = 8; |
444 attrib_list[i++] = EGL_BLUE_SIZE; | 442 attrib_list[i++] = EGL_BLUE_SIZE; |
445 attrib_list[i++] = 8; | 443 attrib_list[i++] = 8; |
446 attrib_list[i++] = EGL_ALPHA_MASK_SIZE; | |
447 attrib_list[i++] = 8; | |
448 break; | 444 break; |
449 | 445 |
450 case MB_IFMT_A8: | 446 case MB_IFMT_A8: |
451 attrib_list[i++] = EGL_ALPHA_SIZE; | 447 attrib_list[i++] = EGL_ALPHA_SIZE; |
452 attrib_list[i++] = 8; | 448 attrib_list[i++] = 8; |
453 attrib_list[i++] = EGL_ALPHA_MASK_SIZE; | |
454 attrib_list[i++] = 8; | |
455 break; | 449 break; |
456 | 450 |
457 case MB_IFMT_A1: | 451 case MB_IFMT_A1: |
458 attrib_list[i++] = EGL_ALPHA_SIZE; | 452 attrib_list[i++] = EGL_ALPHA_SIZE; |
459 attrib_list[i++] = 1; | |
460 attrib_list[i++] = EGL_ALPHA_MASK_SIZE; | |
461 attrib_list[i++] = 1; | 453 attrib_list[i++] = 1; |
462 break; | 454 break; |
463 | 455 |
464 case MB_IFMT_RGB16_565: | 456 case MB_IFMT_RGB16_565: |
465 attrib_list[i++] = EGL_RED_SIZE; | 457 attrib_list[i++] = EGL_RED_SIZE; |
466 attrib_list[i++] = 5; | 458 attrib_list[i++] = 5; |
467 attrib_list[i++] = EGL_GREEN_SIZE; | 459 attrib_list[i++] = EGL_GREEN_SIZE; |
468 attrib_list[i++] = 6; | 460 attrib_list[i++] = 6; |
469 attrib_list[i++] = EGL_BLUE_SIZE; | 461 attrib_list[i++] = EGL_BLUE_SIZE; |
470 attrib_list[i++] = 5; | |
471 attrib_list[i++] = EGL_ALPHA_MASK_SIZE; | |
472 attrib_list[i++] = 5; | 462 attrib_list[i++] = 5; |
473 break; | 463 break; |
474 | 464 |
475 default: | 465 default: |
476 return -1; | 466 return -1; |
721 free(canvas); | 711 free(canvas); |
722 } | 712 } |
723 | 713 |
724 void | 714 void |
725 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) { | 715 mbe_paint_with_alpha(mbe_t *canvas, co_comp_t alpha) { |
716 VGfloat color_trans[8] = {1, 1, 1, alpha, 0, 0, 0, 0}; | |
726 EGLDisplay display; | 717 EGLDisplay display; |
727 VGHandle mask; | |
728 EGLint w, h; | 718 EGLint w, h; |
729 EGLBoolean r; | 719 EGLBoolean r; |
730 | 720 |
731 _MK_CURRENT_CTX(canvas); | 721 _MK_CURRENT_CTX(canvas); |
732 | 722 |
734 | 724 |
735 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w); | 725 r = eglQuerySurface(display, canvas->tgt, EGL_WIDTH, &w); |
736 ASSERT(r == EGL_TRUE); | 726 ASSERT(r == EGL_TRUE); |
737 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h); | 727 r = eglQuerySurface(display, canvas->tgt, EGL_HEIGHT, &h); |
738 ASSERT(r == EGL_TRUE); | 728 ASSERT(r == EGL_TRUE); |
739 | 729 |
740 /* enable and fill mask layer with alpha value */ | 730 /* Setup color transform for alpha */ |
741 vgSeti(VG_MASKING, VG_TRUE); | 731 #ifdef OPENVG_1_1 |
742 mask = vgCreateMaskLayer(w, h); | 732 vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, color_trans); |
743 ASSERT(mask != VG_INVALID_HANDLE); | 733 vgSeti(VG_COLOR_TRANSFORM, VG_TRUE); |
744 vgFillMaskLayer(mask, 0, 0, w, h, alpha); | 734 #endif |
745 vgMask(mask, VG_SET_MASK, 0, 0, w, h); | 735 |
746 vgDestroyMaskLayer(mask); | |
747 | |
748 mbe_paint(canvas); | 736 mbe_paint(canvas); |
749 | 737 |
750 vgSeti(VG_MASKING, VG_FALSE); | 738 #ifdef OPENVG_1_1 |
739 vgSeti(VG_COLOR_TRANSFORM, VG_FALSE); | |
740 #endif | |
751 } | 741 } |
752 | 742 |
753 void | 743 void |
754 mbe_paint(mbe_t *canvas) { | 744 mbe_paint(mbe_t *canvas) { |
755 EGLDisplay display; | 745 EGLDisplay display; |