hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=562ae738ccafbe1d876cc1a90de79fe97ad3ba79

commit 562ae738ccafbe1d876cc1a90de79fe97ad3ba79
Author: JunsuChoi <[email protected]>
Date:   Fri Dec 6 10:37:31 2019 +0900

    ector_software_rasterizer: use dynamic array by span size.
    
    Summary:
    When use with intersect mask, if span_count over span array size, 
composition is to be wrong.
    So, In this case, we use dynamic array by span_count.
    
    Test Plan: N/A
    
    Reviewers: Hermet, smohanty, kimcinoo
    
    Reviewed By: Hermet
    
    Subscribers: vtorri, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D10748
---
 src/lib/ector/software/ector_software_rasterizer.c | 44 ++++++++++++++++++++--
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/src/lib/ector/software/ector_software_rasterizer.c 
b/src/lib/ector/software/ector_software_rasterizer.c
index fd59686131..bbaba4802d 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -522,12 +522,29 @@ _span_fill_clipRect(int span_count, const SW_FT_Span 
*spans, void *user_data)
 {
    const int NSPANS = 256;
    int clip_count, i;
-   SW_FT_Span cspans[NSPANS];
    Span_Data *fill_data = (Span_Data *) user_data;
    Clip_Data clip = fill_data->clip;
    SW_FT_Span *clipped;
    Eina_Rectangle *rect;
    Eina_Rectangle tmp_rect;
+   SW_FT_Span *cspans = NULL;
+   Eina_Bool intersect = EINA_FALSE;
+
+   //Note: Uses same span_count sized heap memory in intersect mask case.
+   if (fill_data->comp_method == EFL_GFX_VG_COMPOSITE_METHOD_MASK_INTERSECT)
+     {
+        intersect = EINA_TRUE;
+        cspans = malloc(sizeof(SW_FT_Span) * (span_count));
+        if (!cspans)
+          {
+             ERR("OOM: Failed malloc()");
+             return ;
+          }
+     }
+   else
+     {
+        cspans = alloca(sizeof(SW_FT_Span) * (NSPANS));
+     }
 
    clip_count = eina_array_count(clip.clips);
 
@@ -545,11 +562,12 @@ _span_fill_clipRect(int span_count, const SW_FT_Span 
*spans, void *user_data)
         while (spans < end)
           {
              clipped = cspans;
-             spans = _intersect_spans_rect(&tmp_rect, spans, end, &clipped, 
NSPANS);
+             spans = _intersect_spans_rect(&tmp_rect, spans, end, &clipped, 
intersect ? span_count : NSPANS);
              if (clipped - cspans)
                fill_data->unclipped_blend(clipped - cspans, cspans, fill_data);
           }
      }
+   if (intersect && cspans) free(cspans);
 }
 
 static void
@@ -557,20 +575,38 @@ _span_fill_clipPath(int span_count, const SW_FT_Span 
*spans, void *user_data)
 {
    const int NSPANS = 256;
    int current_clip = 0;
-   SW_FT_Span cspans[NSPANS];
    Span_Data *fill_data = (Span_Data *) user_data;
    Clip_Data clip = fill_data->clip;
    SW_FT_Span *clipped;
+   SW_FT_Span *cspans = NULL;
+   Eina_Bool intersect = EINA_FALSE;
+
+   //Note: Uses same span_count sized heap memory in intersect mask case.
+   if (fill_data->comp_method == EFL_GFX_VG_COMPOSITE_METHOD_MASK_INTERSECT)
+     {
+        intersect = EINA_TRUE;
+        cspans = malloc(sizeof(SW_FT_Span) * (span_count));
+        if (!cspans)
+          {
+             ERR("OOM: Failed malloc()");
+             return ;
+          }
+     }
+   else
+     {
+        cspans = alloca(sizeof(SW_FT_Span) * (NSPANS));
+     }
 
    // FIXME: Take clip path offset into account.
    const SW_FT_Span *end = spans + span_count;
    while (spans < end)
      {
         clipped = cspans;
-        spans = _intersect_spans_region(clip.path, &current_clip, spans, end, 
&clipped, NSPANS);
+        spans = _intersect_spans_region(clip.path, &current_clip, spans, end, 
&clipped, intersect ? span_count : NSPANS);
         if (clipped - cspans)
           fill_data->unclipped_blend(clipped - cspans, cspans, fill_data);
      }
+   if (intersect && cspans) free(cspans);
 }
 
 static void

-- 


Reply via email to