summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-09-09 18:59:21 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-09-09 18:59:21 +0900
commit5c82716fe899417902e17d0d26b7d467df186cbe (patch)
tree3c0a5d317224d2e9d9a35399478563412a058c4c
parentc1556b711239193cb7a63be3f647e185da83134d (diff)
evas: factorize some code.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c275
1 files changed, 103 insertions, 172 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index fc35a24d21..769b65acaa 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -702,12 +702,94 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
702} 702}
703 703
704void 704void
705evas_gl_common_image_push(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
706 int dx, int dy, int dw, int dh,
707 int sx, int sy, int sw, int sh,
708 int cx, int cy, int cw, int ch,
709 int r, int g, int b, int a, int smooth,
710 int yuv, int yuy2, int nv12)
711{
712 double ssx, ssy, ssw, ssh;
713 int nx, ny, nw, nh;
714
715 nx = dx; ny = dy; nw = dw; nh = dh;
716 RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
717 cx, cy, cw, ch);
718 if ((nw < 1) || (nh < 1)) return;
719 if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
720 {
721 if (yuv)
722 evas_gl_common_context_yuv_push(gc,
723 im->tex,
724 sx, sy, sw, sh,
725 dx, dy, dw, dh,
726 r, g, b, a,
727 smooth);
728 else if (yuy2)
729 evas_gl_common_context_yuy2_push(gc,
730 im->tex,
731 sx, sy, sw, sh,
732 dx, dy, dw, dh,
733 r, g, b, a,
734 smooth);
735 else if (nv12)
736 evas_gl_common_context_nv12_push(gc,
737 im->tex,
738 sx, sy, sw, sh,
739 dx, dy, dw, dh,
740 r, g, b, a,
741 smooth);
742 else
743 evas_gl_common_context_image_push(gc,
744 im->tex,
745 sx, sy, sw, sh,
746 dx, dy, dw, dh,
747 r, g, b, a,
748 smooth, im->tex_only);
749 return;
750 }
751
752 ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
753 ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
754 ssw = ((double)sw * (double)(nw)) / (double)(dw);
755 ssh = ((double)sh * (double)(nh)) / (double)(dh);
756
757 if (yuv)
758 evas_gl_common_context_yuv_push(gc,
759 im->tex,
760 ssx, ssy, ssw, ssh,
761 nx, ny, nw, nh,
762 r, g, b, a,
763 smooth);
764 else if (yuy2)
765 evas_gl_common_context_yuy2_push(gc,
766 im->tex,
767 ssx, ssy, ssw, ssh,
768 nx, ny, nw, nh,
769 r, g, b, a,
770 smooth);
771 else if (nv12)
772 evas_gl_common_context_nv12_push(gc,
773 im->tex,
774 ssx, ssy, ssw, ssh,
775 nx, ny, nw, nh,
776 r, g, b, a,
777 smooth);
778 else
779 evas_gl_common_context_image_push(gc,
780 im->tex,
781 ssx, ssy, ssw, ssh,
782 nx, ny, nw, nh,
783 r, g, b, a,
784 smooth, im->tex_only);
785}
786
787void
705evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth) 788evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth)
706{ 789{
707 static Cutout_Rects *rects = NULL; 790 static Cutout_Rects *rects = NULL;
708 RGBA_Draw_Context *dc; 791 RGBA_Draw_Context *dc;
709 int r, g, b, a; 792 int r, g, b, a;
710 double ssx, ssy, ssw, ssh;
711 Cutout_Rect *rct; 793 Cutout_Rect *rct;
712 int c, cx, cy, cw, ch; 794 int c, cx, cy, cw, ch;
713 int i; 795 int i;
@@ -755,111 +837,22 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
755 { 837 {
756 if (gc->dc->clip.use) 838 if (gc->dc->clip.use)
757 { 839 {
758 int nx, ny, nw, nh; 840 evas_gl_common_image_push(gc, im,
759 841 dx, dy, dw, dh,
760 nx = dx; ny = dy; nw = dw; nh = dh; 842 sx, sy, sw, sh,
761 RECTS_CLIP_TO_RECT(nx, ny, nw, nh, 843 gc->dc->clip.x, gc->dc->clip.y,
762 gc->dc->clip.x, gc->dc->clip.y, 844 gc->dc->clip.w, gc->dc->clip.h,
763 gc->dc->clip.w, gc->dc->clip.h); 845 r, g, b, a, smooth,
764 if ((nw < 1) || (nh < 1)) return; 846 yuv, yuy2, nv12);
765 if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh))
766 {
767 if (yuv)
768 evas_gl_common_context_yuv_push(gc,
769 im->tex,
770 sx, sy, sw, sh,
771 dx, dy, dw, dh,
772 r, g, b, a,
773 smooth);
774 else if (yuy2)
775 evas_gl_common_context_yuy2_push(gc,
776 im->tex,
777 sx, sy, sw, sh,
778 dx, dy, dw, dh,
779 r, g, b, a,
780 smooth);
781 else if (nv12)
782 evas_gl_common_context_nv12_push(gc,
783 im->tex,
784 sx, sy, sw, sh,
785 dx, dy, dw, dh,
786 r, g, b, a,
787 smooth);
788 else
789
790 evas_gl_common_context_image_push(gc,
791 im->tex,
792 sx, sy, sw, sh,
793 dx, dy, dw, dh,
794 r, g, b, a,
795 smooth, im->tex_only);
796 return;
797 }
798
799 ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
800 ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
801 ssw = ((double)sw * (double)(nw)) / (double)(dw);
802 ssh = ((double)sh * (double)(nh)) / (double)(dh);
803
804 if (yuv)
805 evas_gl_common_context_yuv_push(gc,
806 im->tex,
807 ssx, ssy, ssw, ssh,
808 nx, ny, nw, nh,
809 r, g, b, a,
810 smooth);
811 else if (yuy2)
812 evas_gl_common_context_yuy2_push(gc,
813 im->tex,
814 ssx, ssy, ssw, ssh,
815 nx, ny, nw, nh,
816 r, g, b, a,
817 smooth);
818 else if (nv12)
819 evas_gl_common_context_nv12_push(gc,
820 im->tex,
821 ssx, ssy, ssw, ssh,
822 nx, ny, nw, nh,
823 r, g, b, a,
824 smooth);
825 else
826 evas_gl_common_context_image_push(gc,
827 im->tex,
828 ssx, ssy, ssw, ssh,
829 nx, ny, nw, nh,
830 r, g, b, a,
831 smooth, im->tex_only);
832 } 847 }
833 else 848 else
834 { 849 {
835 if (yuv) 850 evas_gl_common_image_push(gc, im,
836 evas_gl_common_context_yuv_push(gc, 851 dx, dy, dw, dh,
837 im->tex, 852 sx, sy, sw, sh,
838 sx, sy, sw, sh, 853 sx, sy, sw, sh,
839 dx, dy, dw, dh, 854 r, g, b, a, smooth,
840 r, g, b, a, 855 yuv, yuy2, nv12);
841 smooth);
842 else if (yuy2)
843 evas_gl_common_context_yuy2_push(gc,
844 im->tex,
845 sx, sy, sw, sh,
846 dx, dy, dw, dh,
847 r, g, b, a,
848 smooth);
849 else if (nv12)
850 evas_gl_common_context_nv12_push(gc,
851 im->tex,
852 sx, sy, sw, sh,
853 dx, dy, dw, dh,
854 r, g, b, a,
855 smooth);
856 else
857 evas_gl_common_context_image_push(gc,
858 im->tex,
859 sx, sy, sw, sh,
860 dx, dy, dw, dh,
861 r, g, b, a,
862 smooth, im->tex_only);
863 } 856 }
864 return; 857 return;
865 } 858 }
@@ -877,76 +870,14 @@ evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx,
877 rects = evas_common_draw_context_apply_cutouts(dc, rects); 870 rects = evas_common_draw_context_apply_cutouts(dc, rects);
878 for (i = 0; i < rects->active; ++i) 871 for (i = 0; i < rects->active; ++i)
879 { 872 {
880 int nx, ny, nw, nh;
881
882 rct = rects->rects + i; 873 rct = rects->rects + i;
883 nx = dx; ny = dy; nw = dw; nh = dh; 874
884 RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h); 875 evas_gl_common_image_push(gc, im,
885 if ((nw < 1) || (nh < 1)) continue; 876 dx, dy, dw, dh,
886 if ((nx == dx) && (ny == dy) && (nw == dw) && (nh == dh)) 877 sx, sy, sw, sh,
887 { 878 rct->x, rct->y, rct->w, rct->h,
888 if (yuv) 879 r, g, b, a, smooth,
889 evas_gl_common_context_yuv_push(gc, 880 yuv, yuy2, nv12);
890 im->tex,
891 sx, sy, sw, sh,
892 dx, dy, dw, dh,
893 r, g, b, a,
894 smooth);
895 else if (yuy2)
896 evas_gl_common_context_yuy2_push(gc,
897 im->tex,
898 sx, sy, sw, sh,
899 dx, dy, dw, dh,
900 r, g, b, a,
901 smooth);
902 else if (nv12)
903 evas_gl_common_context_nv12_push(gc,
904 im->tex,
905 sx, sy, sw, sh,
906 dx, dy, dw, dh,
907 r, g, b, a,
908 smooth);
909 else
910 evas_gl_common_context_image_push(gc,
911 im->tex,
912 sx, sy, sw, sh,
913 dx, dy, dw, dh,
914 r, g, b, a,
915 smooth, im->tex_only);
916 continue;
917 }
918 ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
919 ssy = (double)sy + ((double)(sh * (ny - dy)) / (double)(dh));
920 ssw = ((double)sw * (double)(nw)) / (double)(dw);
921 ssh = ((double)sh * (double)(nh)) / (double)(dh);
922 if (yuv)
923 evas_gl_common_context_yuv_push(gc,
924 im->tex,
925 ssx, ssy, ssw, ssh,
926 nx, ny, nw, nh,
927 r, g, b, a,
928 smooth);
929 else if (yuy2)
930 evas_gl_common_context_yuy2_push(gc,
931 im->tex,
932 ssx, ssy, ssw, ssh,
933 nx, ny, nw, nh,
934 r, g, b, a,
935 smooth);
936 else if (nv12)
937 evas_gl_common_context_nv12_push(gc,
938 im->tex,
939 ssx, ssy, ssw, ssh,
940 nx, ny, nw, nh,
941 r, g, b, a,
942 smooth);
943 else
944 evas_gl_common_context_image_push(gc,
945 im->tex,
946 ssx, ssy, ssw, ssh,
947 nx, ny, nw, nh,
948 r, g, b, a,
949 smooth, im->tex_only);
950 } 881 }
951 /* restore clip info */ 882 /* restore clip info */
952 gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch; 883 gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;