[cairo-commit] 2 commits - src/cairo-surface.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 11 19:48:27 UTC 2021


 src/cairo-surface.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 974791b4eede7f2ff774b56dd90234ed2cd70311
Merge: e45875142 a7c49ec86
Author: Heiko Lewin <hlewin at gmx.de>
Date:   Mon Jan 11 19:48:26 2021 +0000

    Merge branch 'fix-clear-nothing-to-do' into 'master'
    
    Fix _cairo_surface_paint not setting is_clear
    
    Closes #283
    
    See merge request cairo/cairo!104

commit a7c49ec86117bdf1702f9118add187af2582455f
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Jan 11 18:37:52 2021 +0100

    Fix _cairo_surface_paint not setting is_clear
    
    In commit 10e58a4a I changed the code in cairo-surface.c to avoid
    setting surface->is_clear = FALSE; in some situations where it was not
    necessary, because the operation did not actually modify anything (it
    returned CAIRO_INT_STATUS_NOTHING_TO_DO). However, that change
    accidentally also caused _cairo_surface_paint() not to set
    surface->is_clear = TRUE; in similar cases. That was unintended.
    
    This commit fixes that by always setting is_clear = TRUE when necessary,
    but keeps the optimisation of not setting is_clear = FALSE when not
    necessary.
    
    The connection to the below issue is that the issue happened with
    surfaces with width=0. Clearing such a surface with CAIRO_OPERATOR_CLEAR
    causes CAIRO_INT_STATUS_NOTHING_TO_DO and thus is_clear = TRUE was not
    set. This error was later caught by a failed assertion.
    
    Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/283
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 86df1272e..0a95047f3 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2174,6 +2174,7 @@ _cairo_surface_paint (cairo_surface_t		*surface,
 		      const cairo_clip_t	*clip)
 {
     cairo_int_status_t status;
+    cairo_bool_t is_clear;
 
     TRACE ((stderr, "%s\n", __FUNCTION__));
     if (unlikely (surface->status))
@@ -2196,8 +2197,9 @@ _cairo_surface_paint (cairo_surface_t		*surface,
 	return status;
 
     status = surface->backend->paint (surface, op, source, clip);
-    if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) {
-	surface->is_clear = op == CAIRO_OPERATOR_CLEAR && clip == NULL;
+    is_clear = op == CAIRO_OPERATOR_CLEAR && clip == NULL;
+    if (status != CAIRO_INT_STATUS_NOTHING_TO_DO || is_clear) {
+	surface->is_clear = is_clear;
 	surface->serial++;
     }
 


More information about the cairo-commit mailing list