summaryrefslogtreecommitdiff
path: root/src/lib/ector
diff options
context:
space:
mode:
authorJunsuChoi <jsuya.choi@samsung.com>2019-05-15 11:22:45 +0900
committerHermet Park <hermetpark@gmail.com>2019-05-15 11:22:45 +0900
commit10062fd957e924b03e75b6081d6613f8674c1bed (patch)
tree08ddf5a07e87f87b0b0f22f97fe6cbe535770c49 /src/lib/ector
parent6a5a5a43032370acf9085c47a3627d4539ac324a (diff)
ector_software_rasterizer: Improved masking calculation.
Summary: The memory allocation for the buffer size is improved to allocate only the width size. Test Plan: N/A Reviewers: Hermet, kimcinoo Reviewed By: Hermet Subscribers: cedric, #reviewers, smohanty, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8873
Diffstat (limited to 'src/lib/ector')
-rw-r--r--src/lib/ector/software/ector_software_rasterizer.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c
index 428c067..a368774 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -150,16 +150,11 @@ _blend_mask_add(int count, const SW_FT_Span *spans, void *user_data)
150 150
151 while (count--) 151 while (count--)
152 { 152 {
153 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
154 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x); 153 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
154 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
155 comp_func(ttarget, spans->len, color, spans->coverage); 155 comp_func(ttarget, spans->len, color, spans->coverage);
156 for (int i = 0; i < spans->len; i++) 156 for (int i = 0; i < spans->len; i++)
157 { 157 mtarget[i] = draw_mul_256(0xFF - (ttarget[i]>>24), mtarget[i]) + ttarget[i];
158 double adst = A_VAL(&mtarget[i]) == 0 ? 0 : (double)(A_VAL(&mtarget[i])) / (double)255;
159 double asrc = A_VAL(&ttarget[i]) == 0 ? 0 : (double)(A_VAL(&ttarget[i])) / (double)255;
160 uint32_t aout = (int)(((adst * (1 - asrc)) + asrc) * 255);
161 mtarget[i] = (aout<<24) + (0x00FFFFFF & mtarget[i]);
162 }
163 ++spans; 158 ++spans;
164 } 159 }
165} 160}
@@ -172,26 +167,20 @@ _blend_mask_sub(int count, const SW_FT_Span *spans, void *user_data)
172 167
173 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 168 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
174 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 169 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
175 uint32_t *mtarget = mask->pixels.u32; 170 uint32_t *mbuffer = mask->pixels.u32;
176 171
177 int tsize = sd->raster_buffer->generic->w * sd->raster_buffer->generic->h; 172 int tsize = sd->raster_buffer->generic->w;
178 uint32_t *tbuffer = alloca(sizeof(uint32_t) * tsize); 173 uint32_t *ttarget = alloca(sizeof(uint32_t) * tsize);
179 memset(tbuffer, 0x00, sizeof(uint32_t) * tsize);
180 174
181 while (count--) 175 while (count--)
182 { 176 {
183 uint32_t *ttarget = tbuffer + ((mask->generic->w * spans->y) + spans->x); 177 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
178 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
184 comp_func(ttarget, spans->len, color, spans->coverage); 179 comp_func(ttarget, spans->len, color, spans->coverage);
180 for (int i = 0; i < spans->len; i++)
181 mtarget[i] = draw_mul_256(0xFF - (ttarget[i]>>24), mtarget[i]);
185 ++spans; 182 ++spans;
186 } 183 }
187
188 for(int i = 0; i < tsize; i++)
189 {
190 double adst = A_VAL(&mtarget[i]) == 0 ? 0 : (double)(A_VAL(&mtarget[i])) / (double)255;
191 double asrc = A_VAL(&tbuffer[i]) == 0 ? 0 : (double)(A_VAL(&tbuffer[i])) / (double)255;
192 uint32_t aout = (int)((adst * (1 - asrc)) * 255);
193 mtarget[i] = (aout<<24) + (0x00FFFFFF & mtarget[i]);
194 }
195} 184}
196 185
197 186
@@ -203,25 +192,32 @@ _blend_mask_ins(int count, const SW_FT_Span *spans, void *user_data)
203 192
204 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col); 193 uint32_t color = DRAW_MUL4_SYM(sd->color, sd->mul_col);
205 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color); 194 RGBA_Comp_Func_Solid comp_func = efl_draw_func_solid_span_get(sd->op, color);
206 uint32_t *mtarget = mask->pixels.u32; 195 uint32_t *mbuffer = mask->pixels.u32;
207
208 int tsize = sd->raster_buffer->generic->w * sd->raster_buffer->generic->h;
209 uint32_t *tbuffer = alloca(sizeof(uint32_t) * tsize);
210 memset(tbuffer, 0x00, sizeof(uint32_t) * tsize);
211 196
212 while (count--) 197 int tsize = sd->raster_buffer->generic->w;
213 { 198 uint32_t *ttarget = alloca(sizeof(uint32_t) * tsize);
214 uint32_t *ttarget = tbuffer + ((mask->generic->w * spans->y) + spans->x);
215 comp_func(ttarget, spans->len, color, spans->coverage);
216 ++spans;
217 }
218 199
219 for(int i = 0; i < tsize; i++) 200 for(unsigned int y = 0; y < mask->generic->h; y++)
220 { 201 {
221 double adst = A_VAL(&mtarget[i]) == 0 ? 0 : (double)(A_VAL(&mtarget[i])) / (double)255; 202 for(unsigned int x = 0; x < mask->generic->w; x++)
222 double asrc = A_VAL(&tbuffer[i]) == 0 ? 0 : (double)(A_VAL(&tbuffer[i])) / (double)255; 203 {
223 uint32_t aout = (int)((adst * asrc) * 255); 204 if (x == (unsigned int)spans->x && x + spans->len <= mask->generic->w &&
224 mtarget[i] = (aout<<24) + (0x00FFFFFF & mtarget[i]); 205 y == (unsigned int)spans->y && count > 0)
206 {
207 memset(ttarget, 0x00, sizeof(uint32_t) * spans->len);
208 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
209 comp_func(ttarget, spans->len, color, spans->coverage);
210 for (int c = 0; c < spans->len; c++)
211 mtarget[c] = draw_mul_256(ttarget[c]>>24, mtarget[c]);
212 x += spans->len - 1;
213 ++spans;
214 --count;
215 }
216 else
217 {
218 mbuffer[x + (mask->generic->w * y)] = (0x00FFFFFF & mbuffer[x + (mask->generic->w * y)]);
219 }
220 }
225 } 221 }
226} 222}
227 223
@@ -245,12 +241,7 @@ _blend_mask_diff(int count, const SW_FT_Span *spans, void *user_data)
245 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x); 241 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
246 comp_func(ttarget, spans->len, color, spans->coverage); 242 comp_func(ttarget, spans->len, color, spans->coverage);
247 for (int i = 0; i < spans->len; i++) 243 for (int i = 0; i < spans->len; i++)
248 { 244 mtarget[i] = draw_mul_256(0xFF - (mtarget[i]>>24), ttarget[i]) + draw_mul_256(0xFF - (ttarget[i]>>24), mtarget[i]);
249 double adst = A_VAL(&mtarget[i]) == 0 ? 0 : (double)(A_VAL(&mtarget[i])) / (double)255;
250 double asrc = A_VAL(&ttarget[i]) == 0 ? 0 : (double)(A_VAL(&ttarget[i])) / (double)255;
251 uint32_t aout = (int)((((1 - adst) * asrc) + ((1 - asrc) * adst)) * 255);
252 mtarget[i] = (aout<<24) + (0x00FFFFFF & mtarget[i]);
253 }
254 ++spans; 245 ++spans;
255 } 246 }
256} 247}
@@ -648,10 +639,6 @@ _adjust_span_fill_methods(Span_Data *spdata)
648 spdata->unclipped_blend = NULL; 639 spdata->unclipped_blend = NULL;
649 } 640 }
650 641
651 //FIXME: Mask and mask case is not use clipping.
652 if (spdata->mask_op >= EFL_CANVAS_VG_NODE_BLEND_TYPE_MASK_ADD)
653 spdata->clip.enabled = EINA_FALSE;
654
655 // Clipping Function 642 // Clipping Function
656 if (spdata->clip.enabled) 643 if (spdata->clip.enabled)
657 { 644 {