[cairo-commit] 4 commits - src/cairo-glitz-surface.c

罗晶华 Jinghua Luo jinghua at kemper.freedesktop.org
Sat Oct 21 02:29:35 PDT 2006


 src/cairo-glitz-surface.c |   84 ++++++++++++++++++++++------------------------
 1 files changed, 41 insertions(+), 43 deletions(-)

New commits:
diff-tree 343d9ef030a6a15f779f12e13a03a9451d2fff8b (from 3b1d0d3519a7d0328f897927d3534f10750d30db)
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Sat Oct 21 17:27:28 2006 +0800

    glitz: don't go fackback path for bitmap glyphs.
    
    Test case bitmap font still passes with changes and improves performance
     a lot.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index f123b7c..e14ef4a 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1683,10 +1683,14 @@ _cairo_glitz_surface_font_init (cairo_gl
     drawable = glitz_surface_get_drawable (surface->surface);
 
     switch (format) {
+    case CAIRO_FORMAT_A1:
     case CAIRO_FORMAT_A8:
 	surface_format =
 	    glitz_find_standard_format (drawable, GLITZ_STANDARD_A8);
 	break;
+    case CAIRO_FORMAT_RGB24:
+	ASSERT_NOT_REACHED;
+	break;
     case CAIRO_FORMAT_ARGB32:
 	surface_format =
 	    glitz_find_standard_format (drawable, GLITZ_STANDARD_ARGB32);
diff-tree 3b1d0d3519a7d0328f897927d3534f10750d30db (from f3c58350713b46c6e0e26a40898dc4da85e10279)
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Sat Oct 21 17:23:11 2006 +0800

    glitz: fix test case glyph-cache-pressure.
    
    Glitz backend need freeze glyph cache as xlib backend otherwise it'll
    crash, let's fix it now.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index e9f3ad2..f123b7c 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1959,6 +1959,8 @@ _cairo_glitz_surface_old_show_glyphs (ca
     if (!buffer)
 	goto FAIL2;
 
+    _cairo_scaled_font_freeze_cache (scaled_font);
+
     for (i = 0; i < num_glyphs; i++)
     {
 	status = _cairo_scaled_glyph_lookup (scaled_font,
@@ -1972,6 +1974,17 @@ _cairo_glitz_surface_old_show_glyphs (ca
 	}
 
 	glyph_private = scaled_glyphs[i]->surface_private;
+	if (!glyph_private || !glyph_private->area)
+	{
+	    status = _cairo_glitz_surface_add_glyph (dst,
+						     scaled_font,
+						     scaled_glyphs[i]);
+	    if (status != CAIRO_STATUS_SUCCESS) {
+		num_glyphs = i;
+		goto UNLOCK;
+	    }
+	}
+	glyph_private = scaled_glyphs[i]->surface_private;
 	if (glyph_private && glyph_private->area)
 	{
 	    remaining_glyps--;
@@ -2006,38 +2019,6 @@ _cairo_glitz_surface_old_show_glyphs (ca
 	    glyph_private = scaled_glyphs[i]->surface_private;
 	    if (!glyph_private || !glyph_private->area)
 	    {
-		status = _cairo_glitz_surface_add_glyph (dst,
-							 scaled_font,
-							 scaled_glyphs[i]);
-		if (status)
-		    goto UNLOCK;
-
-		glyph_private = scaled_glyphs[i]->surface_private;
-	    }
-
-	    x_offset = scaled_glyphs[i]->surface->base.device_transform.x0;
-	    y_offset = scaled_glyphs[i]->surface->base.device_transform.y0;
-
-	    x1 = floor (glyphs[i].x + 0.5) + x_offset;
-	    y1 = floor (glyphs[i].y + 0.5) + y_offset;
-
-	    if (glyph_private->area)
-	    {
-		if (glyph_private->area->width)
-		{
-		    x2 = x1 + glyph_private->area->width;
-		    y2 = y1 + glyph_private->area->height;
-
-		    WRITE_BOX (vertices, x1, y1, x2, y2,
-			       &glyph_private->p1, &glyph_private->p2);
-
-		    glyph_private->locked = TRUE;
-
-		    cached_glyphs++;
-		}
-	    }
-	    else
-	    {
 		int glyph_width, glyph_height;
 
 		image = &scaled_glyphs[i]->surface->base;
@@ -2107,6 +2088,8 @@ _cairo_glitz_surface_old_show_glyphs (ca
     }
 
 UNLOCK:
+    _cairo_scaled_font_thaw_cache (scaled_font);
+
     if (cached_glyphs)
     {
 	for (i = 0; i < num_glyphs; i++)
diff-tree f3c58350713b46c6e0e26a40898dc4da85e10279 (from 2ef9c7d9e8fcd0bda138f2b1965b3b06491cae00)
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Sat Oct 21 17:18:51 2006 +0800

    glitz: fix for clone similar.
    
    This corrects mosts of changes in clone similar commit. But it's
    still a problem in _cairo_glitz_surface_set_image, it'll crash if
    source region is outside image extents.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 52272ca..e9f3ad2 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -402,7 +402,7 @@ _cairo_glitz_surface_clone_similar (void
 	    return CAIRO_STATUS_NO_MEMORY;
 
 	_cairo_glitz_surface_set_image (clone, image_src, src_x, src_y,
-					width, height, src_x, src_y);
+					width, height, 0, 0);
 
 	*clone_out = &clone->base;
 
@@ -1201,7 +1201,7 @@ _cairo_glitz_surface_composite_trapezoid
 	    return CAIRO_STATUS_NO_MEMORY;
 	}
 
-	_cairo_glitz_surface_set_image (mask, image, src_x, src_y, width, height, 0, 0);
+	_cairo_glitz_surface_set_image (mask, image, 0, 0, width, height, 0, 0);
     }
 
     _cairo_glitz_surface_set_attributes (src, &attributes);
@@ -2038,14 +2038,18 @@ _cairo_glitz_surface_old_show_glyphs (ca
 	    }
 	    else
 	    {
+		int glyph_width, glyph_height;
+
 		image = &scaled_glyphs[i]->surface->base;
+		glyph_width = scaled_glyphs[i]->surface->width;
+		glyph_height = scaled_glyphs[i]->surface->height;
 		status =
 		    _cairo_glitz_surface_clone_similar (abstract_surface,
 							image,
-							src_x,
-							src_y,
-							width,
-							height,
+							0,
+							0,
+							glyph_width,
+							glyph_height,
 							(cairo_surface_t **)
 							&clone);
 		if (status)
@@ -2059,8 +2063,8 @@ _cairo_glitz_surface_old_show_glyphs (ca
 				 src_y + attributes.base.y_offset + y1,
 				 0, 0,
 				 x1, y1,
-				 scaled_glyphs[i]->surface->width,
-				 scaled_glyphs[i]->surface->height);
+				 glyph_width,
+				 glyph_height);
 
 		cairo_surface_destroy (&clone->base);
 
diff-tree 2ef9c7d9e8fcd0bda138f2b1965b3b06491cae00 (from a34a4a2bd745c07f0d6034acf066252ae55fbb81)
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Sat Oct 21 17:07:19 2006 +0800

    glitz: fix a crash in _cairo_glitz_surface_get_image.
    
    The previous changes in _cairo_glitz_surface_get_image causes test
    clip-fill-rule-pixel-aligned and clip-fill-rule fail with a pretty
    crash, this fix that.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 5310e22..52272ca 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -208,8 +208,9 @@ _cairo_glitz_surface_get_image (cairo_gl
     }
 
     /* clear out the glitz clip; the clip affects glitz_get_pixels */
-    glitz_surface_set_clip_region (surface->surface,
-				   0, 0, NULL, 0);
+    if (surface->clip)
+	glitz_surface_set_clip_region (surface->surface,
+				       0, 0, NULL, 0);
 
     glitz_get_pixels (surface->surface,
 		      x1, y1,
@@ -220,8 +221,14 @@ _cairo_glitz_surface_get_image (cairo_gl
     glitz_buffer_destroy (buffer);
 
     /* restore the clip, if any */
-    surface->base.current_clip_serial = 0;
-    _cairo_surface_set_clip (&surface->base, surface->base.clip);
+    if (surface->clip) {
+	glitz_box_t *box;
+	int	    n;
+
+	box = (glitz_box_t *) pixman_region_rects (surface->clip);
+	n = pixman_region_num_rects (surface->clip);
+	glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
+    }
 
     image = (cairo_image_surface_t *)
 	_cairo_image_surface_create_with_masks (pixels,


More information about the cairo-commit mailing list