summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-05-21 20:23:15 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-05-21 20:26:57 +0200
commit6d0233afb8bf942a0268e37a75d38fc9a9023469 (patch)
tree7652a30794407a7ad807725e7fb5680b7c68811d /src
parent4542cfcbea6f8e2fe53185534cbc9d2be2ca42ee (diff)
evas/scale_sample: further deduplicate masking code
Summary: by adding a couple extra params to existing functions, we can reuse existing code instead of copying it around and adding more bugs no functional changes Depends on D8846 Reviewers: segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl_rendering Differential Revision: https://phab.enlightenment.org/D8847
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/common/evas_scale_sample.c130
1 files changed, 66 insertions, 64 deletions
diff --git a/src/lib/evas/common/evas_scale_sample.c b/src/lib/evas/common/evas_scale_sample.c
index 1af814a1f7..20376fcf2e 100644
--- a/src/lib/evas/common/evas_scale_sample.c
+++ b/src/lib/evas/common/evas_scale_sample.c
@@ -100,31 +100,37 @@ static void
100_evas_common_scale_rgba_sample_scale_nomask(int y, 100_evas_common_scale_rgba_sample_scale_nomask(int y,
101 int dst_clip_w, int dst_clip_h, int dst_w, 101 int dst_clip_w, int dst_clip_h, int dst_w,
102 DATA32 **row_ptr, int *lin_ptr, 102 DATA32 **row_ptr, int *lin_ptr,
103 DATA32 *dptr, RGBA_Gfx_Func func, unsigned int mul_col) 103 DATA32 *dptr, RGBA_Gfx_Func func, unsigned int mul_col,
104 DATA32 *srcptr, int src_w)
104{ 105{
105 DATA32 *buf, *dst_ptr; 106 DATA32 *buf;
106 int x; 107 int x;
107 108
108 /* a scanline buffer */ 109 /* a scanline buffer */
109 buf = alloca(dst_clip_w * sizeof(DATA32)); 110 if (!srcptr)
111 buf = alloca(dst_clip_w * sizeof(DATA32));
110 112
111 dptr = dptr + dst_w * y; 113 dptr = dptr + dst_w * y;
112 for (; y < dst_clip_h; y++) 114 for (; y < dst_clip_h; y++)
113 { 115 {
114 dst_ptr = buf; 116 if (!srcptr)
115 for (x = 0; x < dst_clip_w; x++)
116 { 117 {
117 DATA32 *ptr; 118 DATA32 *dst_ptr = buf;
119 for (x = 0; x < dst_clip_w; x++)
120 {
121 DATA32 *ptr;
118 122
119 ptr = row_ptr[y] + lin_ptr[x]; 123 ptr = row_ptr[y] + lin_ptr[x];
120 *dst_ptr = *ptr; 124 *dst_ptr = *ptr;
121 dst_ptr++; 125 dst_ptr++;
126 }
122 } 127 }
123 128
124 /* * blend here [clip_w *] buf -> dptr * */ 129 /* * blend here [clip_w *] buf -> dptr * */
125 func(buf, NULL, mul_col, dptr, dst_clip_w); 130 func(srcptr ?: buf, NULL, mul_col, dptr, dst_clip_w);
126 131
127 dptr += dst_w; 132 dptr += dst_w;
133 if (srcptr) srcptr += src_w;
128 } 134 }
129} 135}
130 136
@@ -135,9 +141,10 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
135 int mask_x, int mask_y, 141 int mask_x, int mask_y,
136 DATA32 **row_ptr, int *lin_ptr, RGBA_Image *mask_ie, 142 DATA32 **row_ptr, int *lin_ptr, RGBA_Image *mask_ie,
137 DATA32 *dptr, RGBA_Gfx_Func func, RGBA_Gfx_Func func2, 143 DATA32 *dptr, RGBA_Gfx_Func func, RGBA_Gfx_Func func2,
138 unsigned int mul_col) 144 unsigned int mul_col,
145 DATA32 *srcptr, int src_w)
139{ 146{
140 DATA32 *buf, *dst_ptr; 147 DATA32 *buf;
141 int x; 148 int x;
142 149
143 /* clamp/map to mask geometry */ 150 /* clamp/map to mask geometry */
@@ -158,25 +165,34 @@ _evas_common_scale_rgba_sample_scale_mask(int y,
158 { 165 {
159 DATA8 *mask; 166 DATA8 *mask;
160 167
161 dst_ptr = buf;
162 mask = mask_ie->image.data8 168 mask = mask_ie->image.data8
163 + ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w) 169 + ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
164 + (dst_clip_x - mask_x); 170 + (dst_clip_x - mask_x);
165 171
166 for (x = 0; x < dst_clip_w; x++) 172 if (!srcptr)
167 { 173 {
168 DATA32 *ptr; 174 DATA32 *dst_ptr = buf;
175 for (x = 0; x < dst_clip_w; x++)
176 {
177 DATA32 *ptr;
169 178
170 ptr = row_ptr[y] + lin_ptr[x]; 179 ptr = row_ptr[y] + lin_ptr[x];
171 *dst_ptr = *ptr; 180 *dst_ptr = *ptr;
172 dst_ptr++; 181 dst_ptr++;
182 }
173 } 183 }
174 184
175 /* * blend here [clip_w *] buf -> dptr * */ 185 /* * blend here [clip_w *] buf -> dptr * */
176 if (mul_col != 0xFFFFFFFF) func2(buf, NULL, mul_col, buf, dst_clip_w); 186 if (mul_col != 0xFFFFFFFF)
177 func(buf, mask, 0, dptr, dst_clip_w); 187 {
188 func2(srcptr ?: buf, NULL, mul_col, buf, dst_clip_w);
189 func(buf, mask, 0, dptr, dst_clip_w);
190 }
191 else
192 func(srcptr ?: buf, mask, 0, dptr, dst_clip_w);
178 193
179 dptr += dst_w; 194 dptr += dst_w;
195 if (srcptr) srcptr += src_w;
180 } 196 }
181} 197}
182 198
@@ -185,10 +201,8 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
185{ 201{
186 int x, y; 202 int x, y;
187 int *lin_ptr; 203 int *lin_ptr;
188 DATA32 *buf, *dptr;
189 DATA32 **row_ptr; 204 DATA32 **row_ptr;
190 DATA32 *ptr, *dst_ptr, *src_data, *dst_data; 205 DATA32 *ptr, *dst_ptr, *src_data, *dst_data;
191 DATA8 *mask;
192 int src_w, src_h, dst_w, dst_h; 206 int src_w, src_h, dst_w, dst_h;
193 RGBA_Gfx_Func func, func2 = NULL; 207 RGBA_Gfx_Func func, func2 = NULL;
194 208
@@ -353,42 +367,22 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
353 { 367 {
354 ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x); 368 ptr = src_data + (((dst_clip_y - dst_region_y) + src_region_y) * src_w) + ((dst_clip_x - dst_region_x) + src_region_x);
355 369
356 /* image masking */
357 if (mask_ie)
358 {
359 if (mul_col != 0xffffffff)
360 buf = alloca(dst_clip_w * sizeof(DATA32));
361
362 for (y = 0; y < dst_clip_h; y++)
363 {
364 mask = mask_ie->image.data8
365 + ((dst_clip_y - mask_y + y) * mask_ie->cache_entry.w)
366 + (dst_clip_x - mask_x);
367
368 /* * blend here [clip_w *] ptr -> dst_ptr * */
369 if (mul_col != 0xffffffff)
370 {
371 func2(ptr, NULL, mul_col, buf, dst_clip_w);
372 func(buf, mask, 0, dst_ptr, dst_clip_w);
373 }
374 else
375 func(ptr, mask, 0, dst_ptr, dst_clip_w);
376 370
377 ptr += src_w; 371 if (mask_ie)
378 dst_ptr += dst_w; 372 _evas_common_scale_rgba_sample_scale_mask(0,
379 } 373 dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h,
380 } 374 dst_w, mask_x, mask_y,
375 NULL, NULL,
376 mask_ie, dst_ptr,
377 func, func2, mul_col,
378 ptr, src_w);
381 else 379 else
382 { 380 _evas_common_scale_rgba_sample_scale_nomask(0,
383 for (y = 0; y < dst_clip_h; y++) 381 dst_clip_w, dst_clip_h, dst_w,
384 { 382 NULL, NULL,
385 /* * blend here [clip_w *] ptr -> dst_ptr * */ 383 dst_ptr,
386 func(ptr, NULL, mul_col, dst_ptr, dst_clip_w); 384 func, mul_col,
387 385 ptr, src_w);
388 ptr += src_w;
389 dst_ptr += dst_w;
390 }
391 }
392 } 386 }
393 else 387 else
394 { 388 {
@@ -409,13 +403,15 @@ evas_common_scale_rgba_sample_draw(RGBA_Image *src, RGBA_Image *dst, int dst_cli
409 dst_w, mask_x, mask_y, 403 dst_w, mask_x, mask_y,
410 row_ptr, lin_ptr, 404 row_ptr, lin_ptr,
411 mask_ie, dst_ptr, 405 mask_ie, dst_ptr,
412 func, func2, mul_col); 406 func, func2, mul_col,
407 NULL, 0);
413 else 408 else
414 _evas_common_scale_rgba_sample_scale_nomask(0, 409 _evas_common_scale_rgba_sample_scale_nomask(0,
415 dst_clip_w, dst_clip_h, dst_w, 410 dst_clip_w, dst_clip_h, dst_w,
416 row_ptr, lin_ptr, 411 row_ptr, lin_ptr,
417 dst_ptr, 412 dst_ptr,
418 func, mul_col); 413 func, mul_col,
414 NULL, 0);
419 } 415 }
420} 416}
421 417
@@ -730,7 +726,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
730 dst_clip_w, dst_clip_h >> 1, dst_w, 726 dst_clip_w, dst_clip_h >> 1, dst_w,
731 dc->clip.mask_x, dc->clip.mask_y, 727 dc->clip.mask_x, dc->clip.mask_y,
732 row_ptr, lin_ptr, dc->clip.mask, 728 row_ptr, lin_ptr, dc->clip.mask,
733 dptr, func, func2, mul_col); 729 dptr, func, func2, mul_col,
730 NULL, 0);
734 731
735 } 732 }
736 else 733 else
@@ -738,7 +735,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
738 _evas_common_scale_rgba_sample_scale_nomask(0, 735 _evas_common_scale_rgba_sample_scale_nomask(0,
739 dst_clip_w, dst_clip_h >> 1, dst_w, 736 dst_clip_w, dst_clip_h >> 1, dst_w,
740 row_ptr, lin_ptr, 737 row_ptr, lin_ptr,
741 dptr, func, mul_col); 738 dptr, func, mul_col,
739 NULL, 0);
742 } 740 }
743 741
744 msg = eina_thread_queue_wait(main_queue, &ref); 742 msg = eina_thread_queue_wait(main_queue, &ref);
@@ -756,7 +754,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
756 dst_clip_w, dst_clip_h, dst_w, 754 dst_clip_w, dst_clip_h, dst_w,
757 dc->clip.mask_x, dc->clip.mask_y, 755 dc->clip.mask_x, dc->clip.mask_y,
758 row_ptr, lin_ptr, dc->clip.mask, 756 row_ptr, lin_ptr, dc->clip.mask,
759 dptr, func, func2, mul_col); 757 dptr, func, func2, mul_col,
758 NULL, 0);
760 759
761 } 760 }
762 else 761 else
@@ -764,7 +763,8 @@ scale_rgba_in_to_out_clip_sample_internal(RGBA_Image *src, RGBA_Image *dst,
764 _evas_common_scale_rgba_sample_scale_nomask(0, 763 _evas_common_scale_rgba_sample_scale_nomask(0,
765 dst_clip_w, dst_clip_h, dst_w, 764 dst_clip_w, dst_clip_h, dst_w,
766 row_ptr, lin_ptr, 765 row_ptr, lin_ptr,
767 dptr, func, mul_col); 766 dptr, func, mul_col,
767 NULL, 0);
768 } 768 }
769 } 769 }
770 } 770 }
@@ -807,13 +807,15 @@ _evas_common_scale_sample_thread(void *data EINA_UNUSED,
807 todo->mask_x, todo->mask_y, 807 todo->mask_x, todo->mask_y,
808 todo->row_ptr, todo->lin_ptr, todo->mask8, 808 todo->row_ptr, todo->lin_ptr, todo->mask8,
809 todo->dptr, todo->func, todo->func2, 809 todo->dptr, todo->func, todo->func2,
810 todo->mul_col); 810 todo->mul_col,
811 NULL, 0);
811 else 812 else
812 _evas_common_scale_rgba_sample_scale_nomask(h, 813 _evas_common_scale_rgba_sample_scale_nomask(h,
813 todo->dst_clip_w, todo->dst_clip_h, 814 todo->dst_clip_w, todo->dst_clip_h,
814 todo->dst_w, 815 todo->dst_w,
815 todo->row_ptr, todo->lin_ptr, 816 todo->row_ptr, todo->lin_ptr,
816 todo->dptr, todo->func, todo->mul_col); 817 todo->dptr, todo->func, todo->mul_col,
818 NULL, 0);
817 } 819 }
818 820
819 end: 821 end: