summaryrefslogtreecommitdiff
path: root/src/lib/ector
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-08-30 13:42:54 +0900
committerHermet Park <hermetpark@gmail.com>2019-08-30 13:44:56 +0900
commite4b9807ee3e7b0feb4d80b80d112bf838f49dbd0 (patch)
tree4a9bb191ff7f054b3b6aad3bb7bb454e5dbf4b7a /src/lib/ector
parent17320a13180fdfbf75f5648d2f06a8d2155c8a0d (diff)
ector: remove unnecessary blending processing.
gradient buffer in masking doesn't need to apply anti-aliasing since it would be taken by masking buffer. This also fixes memory overflow case if the tbuffer is lack of size.
Diffstat (limited to 'src/lib/ector')
-rw-r--r--src/lib/ector/software/ector_software_rasterizer.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c
index bd8055f..447598c 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -296,12 +296,11 @@ _blend_gradient(int count, const SW_FT_Span *spans, void *user_data)
296static void 296static void
297_blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data) 297_blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
298{ 298{
299 RGBA_Comp_Func comp_func;
300 Span_Data *sd = (Span_Data *)(user_data); 299 Span_Data *sd = (Span_Data *)(user_data);
301 src_fetch fetchfunc = NULL; 300 src_fetch fetchfunc = NULL;
302 uint32_t *buffer; 301 uint32_t *buffer;
303 const int pix_stride = sd->raster_buffer->stride / 4; 302 const int pix_stride = sd->raster_buffer->stride / 4;
304 uint32_t gradientbuffer[BLEND_GRADIENT_BUFFER_SIZE]; 303 uint32_t gbuffer[BLEND_GRADIENT_BUFFER_SIZE]; //gradient buffer
305 304
306 // FIXME: Get the proper composition function using ,color, ECTOR_OP etc. 305 // FIXME: Get the proper composition function using ,color, ECTOR_OP etc.
307 if (sd->type == LinearGradient) fetchfunc = &fetch_linear_gradient; 306 if (sd->type == LinearGradient) fetchfunc = &fetch_linear_gradient;
@@ -312,11 +311,6 @@ _blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
312 Ector_Software_Buffer_Base_Data *mask = sd->mask; 311 Ector_Software_Buffer_Base_Data *mask = sd->mask;
313 uint32_t *mbuffer = mask->pixels.u32; 312 uint32_t *mbuffer = mask->pixels.u32;
314 313
315 //Temp buffer for intermediate processing
316 uint32_t *tbuffer = malloc(sizeof(uint32_t) * sd->raster_buffer->generic->w);
317
318 comp_func = efl_draw_func_span_get(sd->op, sd->mul_col, sd->gradient->alpha);
319
320 // move to the offset location 314 // move to the offset location
321 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx); 315 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx);
322 316
@@ -324,14 +318,13 @@ _blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
324 { 318 {
325 uint32_t *target = buffer + ((sd->raster_buffer->generic->w * spans->y) + spans->x); 319 uint32_t *target = buffer + ((sd->raster_buffer->generic->w * spans->y) + spans->x);
326 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x); 320 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
327 uint32_t *temp = tbuffer; 321 uint32_t *temp = gbuffer;
328 int length = spans->len; 322 int length = spans->len;
329 memset(temp, 0x00, sizeof(uint32_t) * spans->len); 323 memset(temp, 0x00, sizeof(uint32_t) * spans->len);
330 while (length) 324 while (length)
331 { 325 {
332 int l = MIN(length, BLEND_GRADIENT_BUFFER_SIZE); 326 int l = MIN(length, BLEND_GRADIENT_BUFFER_SIZE);
333 fetchfunc(gradientbuffer, sd, spans->y, spans->x, l); 327 fetchfunc(temp, sd, spans->y, spans->x, l);
334 comp_func(temp, gradientbuffer, l, sd->mul_col, spans->coverage);
335 328
336 for (int i = 0; i < l; i++) 329 for (int i = 0; i < l; i++)
337 { 330 {
@@ -346,18 +339,16 @@ _blend_gradient_alpha(int count, const SW_FT_Span *spans, void *user_data)
346 } 339 }
347 ++spans; 340 ++spans;
348 } 341 }
349 free(tbuffer);
350} 342}
351 343
352static void 344static void
353_blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data) 345_blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
354{ 346{
355 RGBA_Comp_Func comp_func;
356 Span_Data *sd = (Span_Data *)(user_data); 347 Span_Data *sd = (Span_Data *)(user_data);
357 src_fetch fetchfunc = NULL; 348 src_fetch fetchfunc = NULL;
358 uint32_t *buffer; 349 uint32_t *buffer;
359 const int pix_stride = sd->raster_buffer->stride / 4; 350 const int pix_stride = sd->raster_buffer->stride / 4;
360 uint32_t gradientbuffer[BLEND_GRADIENT_BUFFER_SIZE]; 351 uint32_t gbuffer[BLEND_GRADIENT_BUFFER_SIZE]; //gradient buffer
361 352
362 // FIXME: Get the proper composition function using ,color, ECTOR_OP etc. 353 // FIXME: Get the proper composition function using ,color, ECTOR_OP etc.
363 if (sd->type == LinearGradient) fetchfunc = &fetch_linear_gradient; 354 if (sd->type == LinearGradient) fetchfunc = &fetch_linear_gradient;
@@ -368,11 +359,6 @@ _blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
368 Ector_Software_Buffer_Base_Data *mask = sd->mask; 359 Ector_Software_Buffer_Base_Data *mask = sd->mask;
369 uint32_t *mbuffer = mask->pixels.u32; 360 uint32_t *mbuffer = mask->pixels.u32;
370 361
371 //Temp buffer for intermediate processing
372 uint32_t *tbuffer = malloc(sizeof(uint32_t) * sd->raster_buffer->generic->w);
373
374 comp_func = efl_draw_func_span_get(sd->op, sd->mul_col, sd->gradient->alpha);
375
376 // move to the offset location 362 // move to the offset location
377 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx); 363 buffer = sd->raster_buffer->pixels.u32 + ((pix_stride * sd->offy) + sd->offx);
378 364
@@ -380,14 +366,13 @@ _blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
380 { 366 {
381 uint32_t *target = buffer + ((sd->raster_buffer->generic->w * spans->y) + spans->x); 367 uint32_t *target = buffer + ((sd->raster_buffer->generic->w * spans->y) + spans->x);
382 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x); 368 uint32_t *mtarget = mbuffer + ((mask->generic->w * spans->y) + spans->x);
383 uint32_t *temp = tbuffer; 369 uint32_t *temp = gbuffer;
384 int length = spans->len; 370 int length = spans->len;
385 memset(temp, 0x00, sizeof(uint32_t) * spans->len); 371 memset(temp, 0x00, sizeof(uint32_t) * spans->len);
386 while (length) 372 while (length)
387 { 373 {
388 int l = MIN(length, BLEND_GRADIENT_BUFFER_SIZE); 374 int l = MIN(length, BLEND_GRADIENT_BUFFER_SIZE);
389 fetchfunc(gradientbuffer, sd, spans->y, spans->x, l); 375 fetchfunc(temp, sd, spans->y, spans->x, l);
390 comp_func(temp, gradientbuffer, l, sd->mul_col, spans->coverage);
391 376
392 for (int i = 0; i < l; i++) 377 for (int i = 0; i < l; i++)
393 { 378 {
@@ -403,7 +388,6 @@ _blend_gradient_alpha_inv(int count, const SW_FT_Span *spans, void *user_data)
403 } 388 }
404 ++spans; 389 ++spans;
405 } 390 }
406 free(tbuffer);
407} 391}
408/*! 392/*!
409 \internal 393 \internal