summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@profusion.mobi>2012-11-28 22:49:19 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-11-28 22:49:19 +0000
commit6ae734468301f732c9668f4cb74bc73e47c8baae (patch)
treea619d19a180f0d13a3c486b36ca9be46e1094f5e /src/lib/evas/common
parent951a95c9840b079b4e24162cab89909a5b4472c5 (diff)
evas/image: Refactor common code for image drawing
This patch refactors common code for image draws - so that it can be used by other engines and *threaded* X11. Signed-off-by: Paulo Alcantara <pcacjr@profusion.mobi> Patch by: Paulo Alcantara <pcacjr@profusion.mobi> SVN revision: 79795
Diffstat (limited to '')
-rw-r--r--src/lib/evas/common/evas_scale_main.c53
-rw-r--r--src/lib/evas/common/evas_scale_main.h3
-rw-r--r--src/lib/evas/common/evas_scale_sample.c58
-rw-r--r--src/lib/evas/common/evas_scale_smooth.c79
4 files changed, 80 insertions, 113 deletions
diff --git a/src/lib/evas/common/evas_scale_main.c b/src/lib/evas/common/evas_scale_main.c
index 8ccfe706c1..24047c195c 100644
--- a/src/lib/evas/common/evas_scale_main.c
+++ b/src/lib/evas/common/evas_scale_main.c
@@ -31,3 +31,56 @@ evas_common_scale_rgba_in_to_out_clip_prepare(Cutout_Rects *reuse, const RGBA_Im
31 return EINA_TRUE; 31 return EINA_TRUE;
32} 32}
33 33
34EAPI void
35evas_common_scale_rgba_in_to_out_clip_cb(RGBA_Image *src, RGBA_Image *dst,
36 RGBA_Draw_Context *dc,
37 int src_region_x, int src_region_y,
38 int src_region_w, int src_region_h,
39 int dst_region_x, int dst_region_y,
40 int dst_region_w, int dst_region_h,
41 Evas_Common_Scale_In_To_Out_Clip_Cb cb)
42{
43 static Cutout_Rects *rects = NULL;
44 Cutout_Rect *r;
45 int c, cx, cy, cw, ch;
46 int i;
47 /* handle cutouts here! */
48
49 if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
50 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
51 return;
52
53 /* no cutouts - cut right to the chase */
54 if (!dc->cutout.rects)
55 {
56 cb(src, dst, dc,
57 src_region_x, src_region_y, src_region_w, src_region_h,
58 dst_region_x, dst_region_y, dst_region_w, dst_region_h);
59 return;
60 }
61
62 /* save out clip info */
63 c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
64 evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
65 evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
66
67 /* our clip is 0 size.. abort */
68 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
69 {
70 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
71 return;
72 }
73
74 rects = evas_common_draw_context_apply_cutouts(dc, rects);
75 for (i = 0; i < rects->active; ++i)
76 {
77 r = rects->rects + i;
78 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
79 cb(src, dst, dc,
80 src_region_x, src_region_y, src_region_w, src_region_h,
81 dst_region_x, dst_region_y, dst_region_w, dst_region_h);
82 }
83
84 /* restore clip info */
85 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
86}
diff --git a/src/lib/evas/common/evas_scale_main.h b/src/lib/evas/common/evas_scale_main.h
index e2ef8fa9ce..a126457162 100644
--- a/src/lib/evas/common/evas_scale_main.h
+++ b/src/lib/evas/common/evas_scale_main.h
@@ -1,11 +1,12 @@
1#ifndef _EVAS_SCALE_MAIN_H 1#ifndef _EVAS_SCALE_MAIN_H
2#define _EVAS_SCALE_MAIN_H 2#define _EVAS_SCALE_MAIN_H
3 3
4typedef void (*Evas_Common_Scale_In_To_Out_Clip_Cb)(RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
4 5
5EAPI void evas_common_scale_init (void); 6EAPI void evas_common_scale_init (void);
6 7
8EAPI void evas_common_scale_rgba_in_to_out_clip_cb (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h, Evas_Common_Scale_In_To_Out_Clip_Cb cb);
7EAPI void evas_common_scale_rgba_in_to_out_clip_smooth (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); 9EAPI void evas_common_scale_rgba_in_to_out_clip_smooth (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
8
9EAPI void evas_common_scale_rgba_in_to_out_clip_sample (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h); 10EAPI void evas_common_scale_rgba_in_to_out_clip_sample (RGBA_Image *src, RGBA_Image *dst, RGBA_Draw_Context *dc, int src_region_x, int src_region_y, int src_region_w, int src_region_h, int dst_region_x, int dst_region_y, int dst_region_w, int dst_region_h);
10 11
11EAPI void evas_common_rgba_image_scalecache_dump(void); 12EAPI void evas_common_rgba_image_scalecache_dump(void);
diff --git a/src/lib/evas/common/evas_scale_sample.c b/src/lib/evas/common/evas_scale_sample.c
index f78aad3879..9a94f904ea 100644
--- a/src/lib/evas/common/evas_scale_sample.c
+++ b/src/lib/evas/common/evas_scale_sample.c
@@ -5,55 +5,17 @@ static void scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Imag
5 5
6EAPI void 6EAPI void
7evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst, 7evas_common_scale_rgba_in_to_out_clip_sample(RGBA_Image *src, RGBA_Image *dst,
8 RGBA_Draw_Context *dc, 8 RGBA_Draw_Context *dc,
9 int src_region_x, int src_region_y, 9 int src_region_x, int src_region_y,
10 int src_region_w, int src_region_h, 10 int src_region_w, int src_region_h,
11 int dst_region_x, int dst_region_y, 11 int dst_region_x, int dst_region_y,
12 int dst_region_w, int dst_region_h) 12 int dst_region_w, int dst_region_h)
13{ 13{
14 static Cutout_Rects *rects = NULL; 14 evas_common_scale_rgba_in_to_out_clip_cb
15 Cutout_Rect *r; 15 (src, dst, dc,
16 int c, cx, cy, cw, ch; 16 src_region_x, src_region_y, src_region_w, src_region_h,
17 int i; 17 dst_region_x, dst_region_y, dst_region_w, dst_region_h,
18 /* handle cutouts here! */ 18 scale_rgba_in_to_out_clip_sample_internal);
19
20 if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
21 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
22 return;
23 /* no cutouts - cut right to the chase */
24 if (!dc->cutout.rects)
25 {
26 scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
27 src_region_x, src_region_y,
28 src_region_w, src_region_h,
29 dst_region_x, dst_region_y,
30 dst_region_w, dst_region_h);
31 return;
32 }
33 /* save out clip info */
34 c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
35 evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
36 evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
37 /* our clip is 0 size.. abort */
38 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
39 {
40 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
41 return;
42 }
43 rects = evas_common_draw_context_apply_cutouts(dc, rects);
44 for (i = 0; i < rects->active; ++i)
45 {
46 r = rects->rects + i;
47 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
48 scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
49 src_region_x, src_region_y,
50 src_region_w, src_region_h,
51 dst_region_x, dst_region_y,
52 dst_region_w, dst_region_h);
53
54 }
55 /* restore clip info */
56 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
57} 19}
58 20
59EAPI void 21EAPI void
diff --git a/src/lib/evas/common/evas_scale_smooth.c b/src/lib/evas/common/evas_scale_smooth.c
index e4dfd2cc6f..9efcc8b575 100644
--- a/src/lib/evas/common/evas_scale_smooth.c
+++ b/src/lib/evas/common/evas_scale_smooth.c
@@ -110,72 +110,23 @@ evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
110 int dst_region_x, int dst_region_y, 110 int dst_region_x, int dst_region_y,
111 int dst_region_w, int dst_region_h) 111 int dst_region_w, int dst_region_h)
112{ 112{
113# ifdef BUILD_MMX 113 Evas_Common_Scale_In_To_Out_Clip_Cb cb;
114#ifdef BUILD_MMX
114 int mmx, sse, sse2; 115 int mmx, sse, sse2;
115# endif 116
116 static Cutout_Rects *rects = NULL;
117 Cutout_Rect *r;
118 int c, cx, cy, cw, ch;
119 int i;
120 /* handle cutouts here! */
121
122 if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
123 if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
124 return;
125# ifdef BUILD_MMX
126 evas_common_cpu_can_do(&mmx, &sse, &sse2); 117 evas_common_cpu_can_do(&mmx, &sse, &sse2);
127# endif 118 if (mmx)
128 /* no cutouts - cut right to the chase */ 119 cb = evas_common_scale_rgba_in_to_out_clip_smooth_mmx;
129 if (!dc->cutout.rects) 120 else
130 { 121#endif
131# ifdef BUILD_MMX 122 cb = evas_common_scale_rgba_in_to_out_clip_smooth_c;
132 if (mmx) 123
133 evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc, 124 evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc,
134 src_region_x, src_region_y, 125 src_region_x, src_region_y,
135 src_region_w, src_region_h, 126 src_region_w, src_region_h,
136 dst_region_x, dst_region_y, 127 dst_region_x, dst_region_y,
137 dst_region_w, dst_region_h); 128 dst_region_w, dst_region_h,
138 else 129 cb);
139# endif
140 evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
141 src_region_x, src_region_y,
142 src_region_w, src_region_h,
143 dst_region_x, dst_region_y,
144 dst_region_w, dst_region_h);
145 return;
146 }
147 /* save out clip info */
148 c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
149 evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
150 evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
151 /* our clip is 0 size.. abort */
152 if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
153 {
154 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
155 return;
156 }
157 rects = evas_common_draw_context_apply_cutouts(dc, rects);
158 for (i = 0; i < rects->active; ++i)
159 {
160 r = rects->rects + i;
161 evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
162# ifdef BUILD_MMX
163 if (mmx)
164 evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc,
165 src_region_x, src_region_y,
166 src_region_w, src_region_h,
167 dst_region_x, dst_region_y,
168 dst_region_w, dst_region_h);
169 else
170# endif
171 evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
172 src_region_x, src_region_y,
173 src_region_w, src_region_h,
174 dst_region_x, dst_region_y,
175 dst_region_w, dst_region_h);
176 }
177 /* restore clip info */
178 dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
179} 130}
180 131
181EAPI void 132EAPI void