This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch fix/gl-filter-buffers
in repository efl.

View the commit online.

commit 690ca662d747bee061b84bc62fab1a1ca8083cc8
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 14:09:41 2026 -0600

    evas/filters: mask as documented with the software engine
    
    A stretched mask was still applied in tiles of its original width,
    repeating its left part over the whole buffer.
    
    Between alpha buffers, the render op was used as the mask operation:
    the mask was united with the source where it should have multiplied
    it, as the other variants and the GL engine do.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../software_generic/filters/evas_filter_mask.c    | 63 ++++++++++------------
 1 file changed, 28 insertions(+), 35 deletions(-)

diff --git a/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c b/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
index a3d5dd1677..da47f9196a 100644
--- a/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
+++ b/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
@@ -62,16 +62,16 @@ _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd)
    unsigned int src_len = 0, src_stride, msk_len = 0, msk_stride, dst_len = 0, dst_stride;
    Efl_Gfx_Render_Op render_op = cmd->draw.rop;
    Evas_Filter_Buffer *msk_fb;
-   Draw_Func_Alpha func;
-   uint8_t *src_map = NULL, *dst, *dst_map = NULL, *msk, *msk_map = NULL;
+   Draw_Func_Alpha func, multiply;
+   uint8_t *src_map = NULL, *dst, *dst_map = NULL, *msk, *msk_map = NULL, *span;
    int w, h, mw, mh, x, y, my;
    int stepsize, stepcount, step;
    Eina_Bool ret = EINA_FALSE;
 
    /* Mechanism:
     * 1. Stretch mask as requested in fillmode
-    * 2. Copy source to destination
-    * 3. Render mask into destination using alpha function
+    * 2. Multiply each row of the source by the mask
+    * 3. Draw that row into the destination with the render op
     *
     * FIXME: Could probably be optimized into a single op :)
     */
@@ -80,8 +80,6 @@ _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd)
    h = cmd->input->h;
    mw = cmd->mask->w;
    mh = cmd->mask->h;
-   stepsize  = MIN(mw, w);
-   stepcount = w / stepsize;
 
    // Stretch if necessary.
    if ((mw != w || mh != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
@@ -102,42 +100,34 @@ _mask_cpu_alpha_alpha_alpha(Evas_Filter_Command *cmd)
      }
    else msk_fb = cmd->mask;
 
+   stepsize  = MIN(mw, w);
+   stepcount = w / stepsize;
+
    msk_map = msk = _buffer_map_all(msk_fb->buffer, &msk_len, E_READ, E_ALPHA, &msk_stride);
    dst_map = dst = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, E_ALPHA, &dst_stride);
    EINA_SAFETY_ON_FALSE_GOTO(dst_map && msk_map, end);
 
-   // First pass: copy to dest
-   if (cmd->input->buffer != cmd->output->buffer)
-     {
-        src_map = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ALPHA, &src_stride);
-        EINA_SAFETY_ON_FALSE_GOTO(src_map, end);
-        if (dst_stride == src_stride)
-          memcpy(dst_map, src_map, dst_stride * h * sizeof(uint8_t));
-        else
-          {
-             for (y = 0; y < h; y++)
-               memcpy(dst_map + (y * dst_stride), src_map + (y * src_stride),
-                      MIN(dst_stride, src_stride) * h * sizeof(uint8_t));
-          }
-     }
+   src_map = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ALPHA, &src_stride);
+   EINA_SAFETY_ON_FALSE_GOTO(src_map, end);
 
-   // Second pass: apply render op
+   multiply = efl_draw_alpha_func_get(render_op, EINA_TRUE);
    func = efl_draw_alpha_func_get(render_op, EINA_FALSE);
+   span = alloca(w);
    for (y = 0, my = 0; y < h; y++, my++)
      {
         if (my >= mh) my = 0;
 
         msk = msk_map + (my * msk_stride);
         dst = dst_map + (y * dst_stride);
+        memcpy(span, src_map + (y * src_stride), w);
 
-        for (step = 0; step < stepcount; step++, dst += stepsize)
-          func(dst, msk, stepsize);
-
+        for (step = 0; step < stepcount; step++)
+          multiply(span + (step * stepsize), msk, stepsize);
         x = stepsize * stepcount;
         if (x < w)
-          {
-             func(dst, msk, w - x);
-          }
+          multiply(span + x, msk, w - x);
+
+        func(dst, span, w);
      }
 
    ret = EINA_TRUE;
@@ -202,9 +192,6 @@ _mask_cpu_alpha_rgba_rgba(Evas_Filter_Command *cmd)
    mw = cmd->mask->w;
    mh = cmd->mask->h;
    color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
-   stepsize  = MIN(mw, w);
-   stepcount = w / stepsize;
-   span = alloca(stepsize * sizeof(uint32_t));
 
    // Stretch if necessary.
    if ((mw != w || mh != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
@@ -225,6 +212,10 @@ _mask_cpu_alpha_rgba_rgba(Evas_Filter_Command *cmd)
      }
    else msk_fb = cmd->mask;
 
+   stepsize  = MIN(mw, w);
+   stepcount = w / stepsize;
+   span = alloca(stepsize * sizeof(uint32_t));
+
    src_map = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ALPHA, &src_stride);
    msk_map = _buffer_map_all(msk_fb->buffer, &msk_len, E_READ, E_ARGB, &msk_stride);
    dst_map = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, E_ARGB, &dst_stride);
@@ -300,9 +291,6 @@ _mask_cpu_alpha_alpha_rgba(Evas_Filter_Command *cmd)
    mw = cmd->mask->w;
    mh = cmd->mask->h;
    color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
-   stepsize  = MIN(mw, w);
-   stepcount = w / stepsize;
-   span = alloca(stepsize * sizeof(uint32_t));
 
    // Stretch if necessary.
    if ((mw != w || mh != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
@@ -323,6 +311,10 @@ _mask_cpu_alpha_alpha_rgba(Evas_Filter_Command *cmd)
      }
    else msk_fb = cmd->mask;
 
+   stepsize  = MIN(mw, w);
+   stepcount = w / stepsize;
+   span = alloca(stepsize * sizeof(uint32_t));
+
    src_map = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ALPHA, &src_stride);
    msk_map = _buffer_map_all(msk_fb->buffer, &msk_len, E_READ, E_ALPHA, &msk_stride);
    dst_map = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, E_ARGB, &dst_stride);
@@ -392,8 +384,6 @@ _mask_cpu_rgba_rgba_rgba(Evas_Filter_Command *cmd)
    mw = cmd->mask->w;
    mh = cmd->mask->h;
    color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
-   stepsize  = MIN(mw, w);
-   stepcount = w / stepsize;
 
    // Stretch if necessary.
    if ((mw != w || mh != h) && (cmd->draw.fillmode & EVAS_FILTER_FILL_MODE_STRETCH_XY))
@@ -414,6 +404,9 @@ _mask_cpu_rgba_rgba_rgba(Evas_Filter_Command *cmd)
      }
    else msk_fb = cmd->mask;
 
+   stepsize  = MIN(mw, w);
+   stepcount = w / stepsize;
+
    src_map = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ARGB, &src_stride);
    msk_map = _buffer_map_all(msk_fb->buffer, &msk_len, E_READ, E_ARGB, &msk_stride);
    dst_map = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, E_ARGB, &dst_stride);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to