summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-12-29 03:32:46 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-12-29 03:32:46 +0000
commitb51bdcbc1e31586d50bd4b1e605030c60ef5e3b1 (patch)
tree1d76607ee5dad5f8c6edaf3acbac748534a48ad7 /legacy
parente1f4f1c1cfc698aea919d555b6af355520a07b95 (diff)
colorspace work mostly. not complete.
SVN revision: 27630
Diffstat (limited to 'legacy')
-rw-r--r--legacy/evas/src/modules/engines/gl_common/evas_gl_context.c2
-rw-r--r--legacy/evas/src/modules/engines/gl_common/evas_gl_image.c19
-rw-r--r--legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c5
-rw-r--r--legacy/evas/src/modules/engines/gl_x11/evas_engine.c5
-rw-r--r--legacy/evas/src/modules/engines/xrender_x11/evas_engine.c350
-rw-r--r--legacy/evas/src/modules/engines/xrender_x11/evas_engine.h5
-rw-r--r--legacy/evas/src/modules/engines/xrender_x11/evas_engine_image.c78
7 files changed, 311 insertions, 153 deletions
diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
index dd5668c69b..aac4e6e059 100644
--- a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
+++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c
@@ -97,7 +97,7 @@ evas_gl_common_context_use(Evas_GL_Context *gc)
97void 97void
98evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h) 98evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h)
99{ 99{
100 if ((gc->w == w) && (gc->h == h)) return; 100 //if ((gc->w == w) && (gc->h == h)) return;
101 gc->change.size = 1; 101 gc->change.size = 1;
102 gc->w = w; 102 gc->w = w;
103 gc->h = h; 103 gc->h = h;
diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c
index d3f97dae36..0ec490972a 100644
--- a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c
+++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c
@@ -140,6 +140,7 @@ evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int
140 im->im->image->data = NULL; 140 im->im->image->data = NULL;
141 if (im->tex) evas_gl_common_texture_free(im->tex); 141 if (im->tex) evas_gl_common_texture_free(im->tex);
142 im->tex = NULL; 142 im->tex = NULL;
143 im->cs.no_free = 0;
143 im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2); 144 im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
144 if ((data) && (im->cs.data)) 145 if ((data) && (im->cs.data))
145 memcpy(im->cs.data, data, im->im->image->h * sizeof(unsigned char *) * 2); 146 memcpy(im->cs.data, data, im->im->image->h * sizeof(unsigned char *) * 2);
@@ -254,10 +255,20 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
254 if (!im->tex) return; 255 if (!im->tex) return;
255 ow = (dw * im->tex->tw) / sw; 256 ow = (dw * im->tex->tw) / sw;
256 oh = (dh * im->tex->th) / sh; 257 oh = (dh * im->tex->th) / sh;
257 tx1 = (double)(sx ) / (double)(im->tex->w); 258 if (im->tex->rectangle)
258 ty1 = (double)(sy ) / (double)(im->tex->h); 259 {
259 tx2 = (double)(sx + sw) / (double)(im->tex->w); 260 tx1 = sx;
260 ty2 = (double)(sy + sh) / (double)(im->tex->h); 261 ty1 = sy;
262 tx2 = sx + sw;
263 ty2 = sy + sh;
264 }
265 else
266 {
267 tx1 = (double)(sx ) / (double)(im->tex->w);
268 ty1 = (double)(sy ) / (double)(im->tex->h);
269 tx2 = (double)(sx + sw) / (double)(im->tex->w);
270 ty2 = (double)(sy + sh) / (double)(im->tex->h);
271 }
261 evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh); 272 evas_gl_common_context_texture_set(gc, im->tex, smooth, ow, oh);
262 break; 273 break;
263 default: 274 default:
diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c
index a88a66b297..1a4621c87a 100644
--- a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c
+++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c
@@ -419,8 +419,9 @@ evas_gl_common_ycbcr601pl_texture_new(Evas_GL_Context *gc, unsigned char **rows,
419 int im_w, im_h, tw, th, y; 419 int im_w, im_h, tw, th, y;
420 GLenum texfmt; 420 GLenum texfmt;
421 GLhandleARB fshad; 421 GLhandleARB fshad;
422 422
423 if (!gc->ext.arb_texture_non_power_of_two) return NULL; 423// on an nv 6600gt this is fast - but on a 5500fx its DEAD SLOW!!!!!
424// if (!gc->ext.arb_texture_non_power_of_two) return NULL;
424 425
425 tex = calloc(1, sizeof(Evas_GL_Texture)); 426 tex = calloc(1, sizeof(Evas_GL_Texture));
426 if (!tex) return NULL; 427 if (!tex) return NULL;
diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
index 41a150878b..3cb81f18b4 100644
--- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
+++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
@@ -150,6 +150,7 @@ eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
150 Render_Engine *re; 150 Render_Engine *re;
151 151
152 re = (Render_Engine *)data; 152 re = (Render_Engine *)data;
153 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h);
153 /* smple bounding box */ 154 /* smple bounding box */
154 if (!re->win->draw.redraw) 155 if (!re->win->draw.redraw)
155 { 156 {
@@ -747,9 +748,10 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
747 eng_image_colorspace_get(data, image)); 748 eng_image_colorspace_get(data, image));
748 if (!im_new) 749 if (!im_new)
749 { 750 {
750 return im;
751 *image_data = NULL; 751 *image_data = NULL;
752 return im;
752 } 753 }
754 evas_gl_common_image_free(im);
753 im = im_new; 755 im = im_new;
754 } 756 }
755 else 757 else
@@ -790,6 +792,7 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
790 im2 = eng_image_new_from_data(data, w, h, image_data, 792 im2 = eng_image_new_from_data(data, w, h, image_data,
791 eng_image_alpha_get(data, image), 793 eng_image_alpha_get(data, image),
792 eng_image_colorspace_get(data, image)); 794 eng_image_colorspace_get(data, image));
795 if (!im2) return im;
793 evas_gl_common_image_free(im); 796 evas_gl_common_image_free(im);
794 im = im2; 797 im = im2;
795 } 798 }
diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c
index d9141dbd00..29cc969a8a 100644
--- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c
+++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.c
@@ -462,6 +462,130 @@ eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int
462 _xre_gradient_draw(surface, context, gradient, x, y, w, h); 462 _xre_gradient_draw(surface, context, gradient, x, y, w, h);
463} 463}
464 464
465static int
466eng_image_alpha_get(void *data, void *image)
467{
468 if (!image) return 0;
469 return _xre_image_alpha_get((XR_Image *)image);
470}
471
472static int
473eng_image_colorspace_get(void *data, void *image)
474{
475 if (!image) return EVAS_COLORSPACE_ARGB8888;
476 return ((XR_Image *)image)->cs.space;
477}
478
479static void *
480eng_image_alpha_set(void *data, void *image, int has_alpha)
481{
482 XR_Image *im;
483
484 im = (XR_Image *)image;
485 if (!im) return im;
486 if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
487 if (((im->alpha) && (has_alpha)) || ((!im->alpha) && (!has_alpha)))
488 return im;
489 if (im->references > 1)
490 {
491 XR_Image *old_im;
492
493 old_im = im;
494 im = _xre_image_copy(old_im);
495 if (im)
496 {
497 im->alpha = old_im->alpha;
498 _xre_image_free(old_im);
499 }
500 else
501 im = old_im;
502 }
503 else
504 _xre_image_dirty(im);
505 _xre_image_alpha_set(im, has_alpha);
506 return im;
507}
508
509static void *
510eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
511{
512 if (!image) return image;
513 _xre_image_border_set((XR_Image *)image, l, r, t, b);
514 return image;
515}
516
517static void
518eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
519{
520 if (!image) return;
521 _xre_image_border_get((XR_Image *)image, l, r, t, b);
522}
523
524static const char *
525eng_image_comment_get(void *data, void *image, char *key)
526{
527 if (!image) return NULL;
528 return ((XR_Image *)image)->comment;
529}
530
531static char *
532eng_image_format_get(void *data, void *image)
533{
534 if (!image) return NULL;
535 return ((XR_Image *)image)->format;
536}
537
538static void
539eng_image_colorspace_set(void *data, void *image, int cspace)
540{
541 XR_Image *im;
542
543 if (!image) return;
544 im = (XR_Image *)image;
545 if (im->cs.space == cspace) return;
546 switch (cspace)
547 {
548 case EVAS_COLORSPACE_ARGB8888:
549 if (im->cs.data)
550 {
551 if (!im->cs.no_free) free(im->cs.data);
552 im->cs.data = NULL;
553 im->cs.no_free = 0;
554 }
555 if (im->im) evas_common_image_unref(im->im);
556 im->im = NULL;
557 break;
558 case EVAS_COLORSPACE_YCBCR422P601_PL:
559 case EVAS_COLORSPACE_YCBCR422P709_PL:
560 if (im->im) evas_common_image_unref(im->im);
561 im->im = NULL;
562 if (im->cs.data)
563 {
564 if (!im->cs.no_free) free(im->cs.data);
565 }
566 im->cs.data = calloc(1, im->h * sizeof(unsigned char *) * 2);
567 im->cs.no_free = 0;
568 break;
569 default:
570 abort();
571 break;
572 }
573 im->cs.space = cspace;
574 _xre_image_dirty(im);
575 _xre_image_region_dirty(im, 0, 0, im->w, im->h);
576}
577
578static void
579eng_image_native_set(void *data, void *image, void *native)
580{
581}
582
583static void *
584eng_image_native_get(void *data, void *image)
585{
586 return NULL;
587}
588
465static void * 589static void *
466eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo) 590eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
467{ 591{
@@ -514,29 +638,35 @@ eng_image_size_get(void *data, void *image, int *w, int *h)
514static void * 638static void *
515eng_image_size_set(void *data, void *image, int w, int h) 639eng_image_size_set(void *data, void *image, int w, int h)
516{ 640{
517 if (!image) return image; 641 XR_Image *im, *im_old;
642
643 if (!image) return NULL;
644 im_old = image;
645 if ((im_old) && (im_old->w == w) && (im_old->h == h))
646 return image;
518 if ((w <= 0) || (h <= 0)) 647 if ((w <= 0) || (h <= 0))
519 { 648 {
520 _xre_image_free((XR_Image *)image); 649 _xre_image_free((XR_Image *)image);
521 return NULL; 650 return NULL;
522 } 651 }
523 if (((XR_Image *)image)->references > 1) 652 if (im_old)
524 { 653 {
525 XR_Image *old_image; 654 if (im_old->references > 1)
526
527 old_image = (XR_Image *)image;
528 image = _xre_image_copy((XR_Image *)old_image);
529 if (image)
530 { 655 {
531 ((XR_Image *)image)->alpha = old_image->alpha; 656 im = _xre_image_copy(im_old);
532 _xre_image_free(old_image); 657 if (im)
658 {
659 _xre_image_free(im_old);
660 return im;
661 }
662 return image;
533 } 663 }
534 else
535 image = old_image;
536 } 664 }
537 else 665 else
538 _xre_image_dirty((XR_Image *)image); 666 {
539 _xre_image_resize((XR_Image *)image, w, h); 667 _xre_image_dirty((XR_Image *)image);
668 _xre_image_resize((XR_Image *)image, w, h);
669 }
540 return image; 670 return image;
541} 671}
542 672
@@ -552,115 +682,113 @@ eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
552static void * 682static void *
553eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data) 683eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
554{ 684{
555 if (!image) return image; 685 XR_Image *im;
556 if (to_write) 686
687 if (!image)
557 { 688 {
558 if (((XR_Image *)image)->references > 1) 689 *image_data = NULL;
690 return NULL;
691 }
692 im = (XR_Image *)image;
693 if (im->im)
694 evas_common_load_image_data_from_file(im->im);
695 switch (im->cs.space)
696 {
697 case EVAS_COLORSPACE_ARGB8888:
698 if (to_write)
559 { 699 {
560 XR_Image *old_image; 700 if (im->references > 1)
561
562 old_image = (XR_Image *)image;
563 image = _xre_image_copy((XR_Image *)old_image);
564 if (image)
565 { 701 {
566 ((XR_Image *)image)->alpha = old_image->alpha; 702 XR_Image *im_old;
567 _xre_image_free(old_image); 703
704 im_old = im;
705 im = _xre_image_copy(im_old);
706 if (im)
707 _xre_image_free(im_old);
708 else
709 im = im_old;
568 } 710 }
569 else 711 else
570 image = old_image; 712 _xre_image_dirty(im);
571 } 713 }
572 else 714 break;
573 _xre_image_dirty((XR_Image *)image); 715 case EVAS_COLORSPACE_YCBCR422P601_PL:
716 case EVAS_COLORSPACE_YCBCR422P709_PL:
717 break;
718 default:
719 abort();
720 break;
574 } 721 }
575 if (image_data) *image_data = _xre_image_data_get((XR_Image *)image); 722 if (image_data) *image_data = _xre_image_data_get(im);
576 return image; 723 return im;
577} 724}
578 725
579static void * 726static void *
580eng_image_data_put(void *data, void *image, DATA32 *image_data) 727eng_image_data_put(void *data, void *image, DATA32 *image_data)
581{ 728{
729 XR_Image *im;
730
582 if (!image) return image; 731 if (!image) return image;
583 if (_xre_image_data_get((XR_Image *)image) != image_data) 732 im = (XR_Image *)image;
733
734 switch (im->cs.space)
584 { 735 {
585 XR_Image *old_image; 736 case EVAS_COLORSPACE_ARGB8888:
586 737 if (_xre_image_data_get(im) != image_data)
587 old_image = (XR_Image *)image;
588 image = _xre_image_data_find(image_data);
589 if (image != old_image)
590 { 738 {
591 if (!image) 739 XR_Image *im_old;
740
741 im_old = im;
742 image = _xre_image_data_find(image_data);
743 if (image != im_old)
592 { 744 {
593 image = _xre_image_new_from_data(old_image->xinf, old_image->w, old_image->h, image_data, old_image->alpha, EVAS_COLORSPACE_ARGB8888); 745 if (!image)
594 if (image)
595 { 746 {
596 ((XR_Image *)image)->alpha = old_image->alpha; 747 image = _xre_image_new_from_data(im_old->xinf, im_old->w, im_old->h, image_data, im_old->alpha, EVAS_COLORSPACE_ARGB8888);
597 _xre_image_free(old_image); 748 if (image)
749 {
750 ((XR_Image *)image)->alpha = im_old->alpha;
751 _xre_image_free(im_old);
752 }
753 else
754 image = im_old;
598 } 755 }
599 else 756 else
600 image = old_image; 757 {
758 _xre_image_free(im_old);
759 }
601 } 760 }
602 else 761 else
603 { 762 {
604 _xre_image_free(old_image); 763 _xre_image_free(image);
764 image = im_old;
605 } 765 }
606 } 766 }
607 else 767 break;
608 { 768 case EVAS_COLORSPACE_YCBCR422P601_PL:
609 _xre_image_free(image); 769 case EVAS_COLORSPACE_YCBCR422P709_PL:
610 } 770 if (_xre_image_data_get(im) != image_data)
611 } 771 {
612 return image; 772 if (im->data)
613} 773 {
614 774 if (im->free_data) free(im->data);
615static void * 775 im->data = NULL;
616eng_image_alpha_set(void *data, void *image, int has_alpha) 776 }
617{ 777 if (im->cs.data)
618 if (!image) return image; 778 {
619 if (((((XR_Image *)image)->alpha) && (has_alpha)) || 779 if (!im->cs.no_free) free(im->cs.data);
620 ((!((XR_Image *)image)->alpha) && (!has_alpha))) 780 }
621 return image; 781 im->cs.data = image_data;
622 if (((XR_Image *)image)->references > 1) 782 _xre_image_dirty(im);
623 {
624 XR_Image *old_image;
625
626 old_image = (XR_Image *)image;
627 image = _xre_image_copy((XR_Image *)old_image);
628 if (image)
629 {
630 ((XR_Image *)image)->alpha = old_image->alpha;
631 _xre_image_free(old_image);
632 } 783 }
633 else 784 break;
634 image = old_image; 785 default:
786 abort();
787 break;
635 } 788 }
636 else
637 _xre_image_dirty((XR_Image *)image);
638 _xre_image_alpha_set((XR_Image *)image, has_alpha);
639 return image; 789 return image;
640} 790}
641 791
642static int
643eng_image_alpha_get(void *data, void *image)
644{
645 if (!image) return 0;
646 return _xre_image_alpha_get((XR_Image *)image);
647}
648
649static void *
650eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
651{
652 if (!image) return image;
653 _xre_image_border_set((XR_Image *)image, l, r, t, b);
654 return image;
655}
656
657static void
658eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
659{
660 if (!image) return;
661 _xre_image_border_get((XR_Image *)image, l, r, t, b);
662}
663
664static void 792static void
665eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth) 793eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
666{ 794{
@@ -675,42 +803,6 @@ eng_image_draw(void *data, void *context, void *surface, void *image, int src_x,
675 smooth); 803 smooth);
676} 804}
677 805
678static const char *
679eng_image_comment_get(void *data, void *image, char *key)
680{
681 if (!image) return NULL;
682 return ((XR_Image *)image)->comment;
683}
684
685static char *
686eng_image_format_get(void *data, void *image)
687{
688 if (!image) return NULL;
689 return ((XR_Image *)image)->format;
690}
691
692static void
693eng_image_colorspace_set(void *data, void *image, int cspace)
694{
695}
696
697static int
698eng_image_colorspace_get(void *data, void *image)
699{
700 return EVAS_COLORSPACE_ARGB8888;
701}
702
703static void
704eng_image_native_set(void *data, void *image, void *native)
705{
706}
707
708static void *
709eng_image_native_get(void *data, void *image)
710{
711 return NULL;
712}
713
714static void 806static void
715eng_image_cache_flush(void *data) 807eng_image_cache_flush(void *data)
716{ 808{
diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h
index a99fca0d5b..40683e7483 100644
--- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h
+++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine.h
@@ -100,6 +100,11 @@ struct _XR_Image
100 const char *comment; 100 const char *comment;
101 Tilebuf *updates; 101 Tilebuf *updates;
102 RGBA_Image_Loadopts load_opts; 102 RGBA_Image_Loadopts load_opts;
103 struct {
104 int space;
105 void *data;
106 unsigned char no_free : 1;
107 } cs;
103 unsigned char alpha : 1; 108 unsigned char alpha : 1;
104 unsigned char dirty : 1; 109 unsigned char dirty : 1;
105 unsigned char free_data : 1; 110 unsigned char free_data : 1;
diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_image.c b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_image.c
index 8ae9b684cb..3ddd7e9864 100644
--- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_image.c
+++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_image.c
@@ -102,6 +102,7 @@ _xre_image_load(Ximage_Info *xinf, const char *file, const char *key, Evas_Image
102 } 102 }
103 im->xinf = xinf; 103 im->xinf = xinf;
104 im->xinf->references++; 104 im->xinf->references++;
105 im->cs.space = EVAS_COLORSPACE_ARGB8888;
105 im->fkey = strdup(buf); 106 im->fkey = strdup(buf);
106 im->file = evas_stringshare_add(file); 107 im->file = evas_stringshare_add(file);
107 if (key) im->key = evas_stringshare_add(key); 108 if (key) im->key = evas_stringshare_add(key);
@@ -125,11 +126,25 @@ _xre_image_new_from_data(Ximage_Info *xinf, int w, int h, void *data, int alpha,
125 if (!im) return NULL; 126 if (!im) return NULL;
126 im->xinf = xinf; 127 im->xinf = xinf;
127 im->xinf->references++; 128 im->xinf->references++;
129 im->cs.space = cspace;
128 im->w = w; 130 im->w = w;
129 im->h = h; 131 im->h = h;
130 im->references = 1; 132 im->references = 1;
131 im->data = data; 133 switch (im->cs.space)
132 im->alpha = alpha; 134 {
135 case EVAS_COLORSPACE_ARGB8888:
136 im->data = data;
137 im->alpha = alpha;
138 break;
139 case EVAS_COLORSPACE_YCBCR422P601_PL:
140 case EVAS_COLORSPACE_YCBCR422P709_PL:
141 im->cs.data = data;
142 im->cs.no_free = 1;
143 break;
144 default:
145 abort();
146 break;
147 }
133 im->dirty = 1; 148 im->dirty = 1;
134 __xre_image_dirty_hash_add(im); 149 __xre_image_dirty_hash_add(im);
135 return im; 150 return im;
@@ -142,27 +157,43 @@ _xre_image_new_from_copied_data(Ximage_Info *xinf, int w, int h, void *data, int
142 157
143 im = calloc(1, sizeof(XR_Image)); 158 im = calloc(1, sizeof(XR_Image));
144 if (!im) return NULL; 159 if (!im) return NULL;
145 im->data = malloc(w * h * 4); 160 im->cs.space = cspace;
146 if (!im->data) 161 switch (im->cs.space)
147 { 162 {
148 free(im); 163 case EVAS_COLORSPACE_ARGB8888:
149 return NULL; 164 im->data = malloc(w * h * 4);
150 } 165 if (!im->data)
151 if (data) 166 {
152 { 167 free(im);
153 Gfx_Func_Copy func; 168 return NULL;
154 169 }
155 func = evas_common_draw_func_copy_get(w * h, 0); 170 if (data)
156 if (func) func(data, im->data, w * h); 171 {
157 evas_common_cpu_end_opt(); 172 Gfx_Func_Copy func;
173
174 func = evas_common_draw_func_copy_get(w * h, 0);
175 if (func) func(data, im->data, w * h);
176 evas_common_cpu_end_opt();
177 }
178 im->alpha = alpha;
179 im->free_data = 1;
180 break;
181 case EVAS_COLORSPACE_YCBCR422P601_PL:
182 case EVAS_COLORSPACE_YCBCR422P709_PL:
183 im->cs.no_free = 0;
184 im->cs.data = calloc(1, h * sizeof(unsigned char *) * 2);
185 if ((data) && (im->cs.data))
186 memcpy(im->cs.data, data, h * sizeof(unsigned char *) * 2);
187 break;
188 default:
189 abort();
190 break;
158 } 191 }
159 im->w = w; 192 im->w = w;
160 im->h = h; 193 im->h = h;
161 im->references = 1; 194 im->references = 1;
162 im->xinf = xinf; 195 im->xinf = xinf;
163 im->xinf->references++; 196 im->xinf->references++;
164 im->free_data = 1;
165 im->alpha = alpha;
166 im->dirty = 1; 197 im->dirty = 1;
167 __xre_image_dirty_hash_add(im); 198 __xre_image_dirty_hash_add(im);
168 return im; 199 return im;
@@ -184,6 +215,7 @@ _xre_image_new(Ximage_Info *xinf, int w, int h)
184 im->w = w; 215 im->w = w;
185 im->h = h; 216 im->h = h;
186 im->references = 1; 217 im->references = 1;
218 im->cs.space = EVAS_COLORSPACE_ARGB8888;
187 im->xinf = xinf; 219 im->xinf = xinf;
188 im->xinf->references++; 220 im->xinf->references++;
189 im->free_data = 1; 221 im->free_data = 1;
@@ -196,6 +228,10 @@ _xre_image_new(Ximage_Info *xinf, int w, int h)
196static void 228static void
197__xre_image_real_free(XR_Image *im) 229__xre_image_real_free(XR_Image *im)
198{ 230{
231 if (im->cs.data)
232 {
233 if (!im->cs.no_free) free(im->cs.data);
234 }
199 if (im->file) evas_stringshare_del(im->file); 235 if (im->file) evas_stringshare_del(im->file);
200 if (im->key) evas_stringshare_del(im->key); 236 if (im->key) evas_stringshare_del(im->key);
201 if (im->fkey) free(im->fkey); 237 if (im->fkey) free(im->fkey);
@@ -257,6 +293,7 @@ _xre_image_copy(XR_Image *im)
257 XR_Image *im2; 293 XR_Image *im2;
258 void *data = NULL; 294 void *data = NULL;
259 295
296 /* FIXME: colorspace support */
260 if (im->data) data = im->data; 297 if (im->data) data = im->data;
261 else 298 else
262 { 299 {
@@ -281,6 +318,7 @@ _xre_image_copy(XR_Image *im)
281void 318void
282_xre_image_resize(XR_Image *im, int w, int h) 319_xre_image_resize(XR_Image *im, int w, int h)
283{ 320{
321 /* FIXME: colorspace support */
284 /* FIXME: ... */ 322 /* FIXME: ... */
285 if ((w == im->w) && (h == im->h)) return; 323 if ((w == im->w) && (h == im->h)) return;
286 if (im->surface) 324 if (im->surface)
@@ -389,6 +427,7 @@ _xre_image_data_get(XR_Image *im)
389{ 427{
390 void *data = NULL; 428 void *data = NULL;
391 429
430 /* FIXME: colorspace support */
392 if (im->data) data = im->data; 431 if (im->data) data = im->data;
393 else 432 else
394 { 433 {
@@ -420,6 +459,7 @@ _xre_image_data_put(XR_Image *im, void *data)
420{ 459{
421 void *imdata = NULL; 460 void *imdata = NULL;
422 461
462 /* FIXME: colorspace support */
423 if (!data) return; 463 if (!data) return;
424 if (im->data) 464 if (im->data)
425 { 465 {
@@ -462,6 +502,7 @@ _xre_image_data_put(XR_Image *im, void *data)
462void 502void
463_xre_image_alpha_set(XR_Image *im, int alpha) 503_xre_image_alpha_set(XR_Image *im, int alpha)
464{ 504{
505 /* FIXME: colorspace support */
465 if (im->alpha == alpha) return; 506 if (im->alpha == alpha) return;
466 im->alpha = alpha; 507 im->alpha = alpha;
467 if (im->surface) 508 if (im->surface)
@@ -488,6 +529,10 @@ _xre_image_alpha_set(XR_Image *im, int alpha)
488int 529int
489_xre_image_alpha_get(XR_Image *im) 530_xre_image_alpha_get(XR_Image *im)
490{ 531{
532 if (im->im)
533 {
534 if (im->im->cs.space != EVAS_COLORSPACE_ARGB8888) return 0;
535 }
491 return im->alpha; 536 return im->alpha;
492} 537}
493 538
@@ -519,6 +564,7 @@ _xre_image_surface_gen(XR_Image *im)
519{ 564{
520 void *data = NULL; 565 void *data = NULL;
521 566
567 /* FIXME: colorspace support */
522 if ((im->surface) && (!im->updates)) return; 568 if ((im->surface) && (!im->updates)) return;
523 if (im->data) data = im->data; 569 if (im->data) data = im->data;
524 else 570 else