[patch] gl: do not force flush everytime uploading a glyph image to glyph cache

"Henry (Yu) Song - SISA" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <3955FA337689574EB32F94B12A7E6E9E434AC819@sisaex01sj>
From fc3c82cf6a2dd706a97aea2b34c4ddd23eb6e939 Mon Sep 17 00:00:00 2001
From: Henry Song <[email protected]>
Date: Wed, 23 Jan 2013 11:55:44 -0800
Subject: [PATCH] gl: add a force_flush flag in _cairo_gl_surface_draw_image.
 In normal cases, we want to flush everytime we call this
 function. But during uploading glyph to glyph cache, we
 don't want to flush it everytime it uploads glyph images.

---
 src/cairo-gl-glyphs.c           |    2 +-
 src/cairo-gl-private.h          |    3 ++-
 src/cairo-gl-spans-compositor.c |    2 +-
 src/cairo-gl-surface-legacy.c   |    7 ++++---
 src/cairo-gl-surface.c          |   16 ++++++++++------
 src/cairo-gl-traps-compositor.c |    9 ++++++---
 6 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 3f65248..34b5d72 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -134,7 +134,7 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
     status = _cairo_gl_surface_draw_image (cache->surface, glyph_surface,
                                            0, 0,
                                            glyph_surface->width, glyph_surface->height,
-                                           node->x, node->y);
+                                           node->x, node->y, FALSE);
     if (unlikely (status))
 	return status;
 
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index a75afa7..a8f1db6 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -434,7 +434,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 			      cairo_image_surface_t *src,
 			      int src_x, int src_y,
 			      int width, int height,
-			      int dst_x, int dst_y);
+			      int dst_x, int dst_y,
+			      cairo_bool_t force_flush);
 
 static cairo_always_inline cairo_bool_t
 _cairo_gl_device_has_glsl (cairo_device_t *device)
diff --git a/src/cairo-gl-spans-compositor.c b/src/cairo-gl-spans-compositor.c
index 98efd46..fbad8f3 100644
--- a/src/cairo-gl-spans-compositor.c
+++ b/src/cairo-gl-spans-compositor.c
@@ -311,7 +311,7 @@ draw_image_boxes (void *_dst,
 	    status = _cairo_gl_surface_draw_image (dst, image,
 						   x + dx, y + dy,
 						   w, h,
-						   x, y);
+						   x, y, TRUE);
 	    if (unlikely (status))
 		return status;
 	}
diff --git a/src/cairo-gl-surface-legacy.c b/src/cairo-gl-surface-legacy.c
index 61bdd1f..92b27c9 100644
--- a/src/cairo-gl-surface-legacy.c
+++ b/src/cairo-gl-surface-legacy.c
@@ -77,7 +77,8 @@ _cairo_gl_surface_release_dest_image (void		      *abstract_surface,
     status = _cairo_gl_surface_draw_image (abstract_surface, image,
 					   0, 0,
 					   image->width, image->height,
-					   image_rect->x, image_rect->y);
+					   image_rect->x, image_rect->y,
+					   TRUE);
     /* as we created the image, its format should be directly applicable */
     assert (status == CAIRO_STATUS_SUCCESS);
 
@@ -126,7 +127,7 @@ _cairo_gl_surface_clone_similar (void		     *abstract_surface,
 	status = _cairo_gl_surface_draw_image (clone, image_src,
 					       src_x, src_y,
 					       width, height,
-					       0, 0);
+					       0, 0, TRUE);
 	if (status) {
 	    cairo_surface_destroy (&clone->base);
 	    return status;
@@ -236,7 +237,7 @@ _cairo_gl_surface_composite (cairo_operator_t		  op,
             status = _cairo_gl_surface_draw_image (dst, image,
                                                    dx, dy,
                                                    width, height,
-                                                   dst_x, dst_y);
+                                                   dst_x, dst_y, TRUE);
             if (status != CAIRO_INT_STATUS_UNSUPPORTED)
                 return status;
         }
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 922f234..1d7515a 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -840,7 +840,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 			      cairo_image_surface_t *src,
 			      int src_x, int src_y,
 			      int width, int height,
-			      int dst_x, int dst_y)
+			      int dst_x, int dst_y,
+			      cairo_bool_t force_flush)
 {
     GLenum internal_format, format, type;
     cairo_bool_t has_alpha, needs_swap;
@@ -882,9 +883,11 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 
     cpp = PIXMAN_FORMAT_BPP (src->pixman_format) / 8;
 
-    status = _cairo_gl_surface_flush (&dst->base, 0);
-    if (unlikely (status))
-	goto FAIL;
+    if (force_flush) {
+	status = _cairo_gl_surface_flush (&dst->base, 0);
+	if (unlikely (status))
+	    goto FAIL;
+    }
 
     if (_cairo_gl_surface_is_texture (dst)) {
 	void *data_start = src->data + src_y * src->stride + src_x * cpp;
@@ -951,7 +954,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
                                                src,
                                                src_x, src_y,
                                                width, height,
-                                               0, 0);
+                                               0, 0, force_flush);
         if (status == CAIRO_INT_STATUS_SUCCESS) {
             cairo_surface_pattern_t tmp_pattern;
 	    cairo_rectangle_int_t r;
@@ -1231,7 +1234,8 @@ _cairo_gl_surface_unmap_image (void		      *abstract_surface,
 					   0, 0,
 					   image->width, image->height,
 					   image->base.device_transform_inverse.x0,
-					   image->base.device_transform_inverse.y0);
+					   image->base.device_transform_inverse.y0,
+					   TRUE);
 
     cairo_surface_finish (&image->base);
     cairo_surface_destroy (&image->base);
diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index b6c2333..52e624c 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -96,7 +96,8 @@ draw_image_boxes (void *_dst,
 	    status = _cairo_gl_surface_draw_image (dst, image,
 						   x + dx, y + dy,
 						   w, h,
-						   x, y);
+						   x, y,
+						   TRUE);
 	    if (unlikely (status))
 		return status;
 	}
@@ -345,7 +346,8 @@ traps_to_operand (void *_dst,
 					   (cairo_image_surface_t *)image,
 					   0, 0,
 					   extents->width, extents->height,
-					   0, 0);
+					   0, 0,
+					   TRUE);
     cairo_surface_destroy (image);
 
     if (unlikely (status))
@@ -455,7 +457,8 @@ tristrip_to_surface (void *_dst,
 					   (cairo_image_surface_t *)image,
 					   0, 0,
 					   extents->width, extents->height,
-					   0, 0);
+					   0, 0,
+					   TRUE);
     cairo_surface_destroy (image);
     if (unlikely (status)) {
 	cairo_surface_destroy (mask);
-- 
1.7.9.5
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.