[cairo-commit] cairo/src cairo-surface.c, 1.67, 1.68 cairo-win32-font.c, 1.16, 1.17 cairo-win32-surface.c, 1.20, 1.21

Owen Taylor commit at pdx.freedesktop.org
Wed May 11 16:01:58 PDT 2005


Committed by: otaylor

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv11410/src

Modified Files:
	cairo-surface.c cairo-win32-font.c cairo-win32-surface.c 
Log Message:
2005-05-11  T Rowley  <tim.rowley at gmail.com>

	* src/cairo-atsui-font.c:
	* src/cairo-atsui.h:
	* src/cairo-quartz-surface.c: Revive quartz backend.

2005-05-11  David Reveman  <davidr at novell.com>

	* src/cairo-glitz-surface.c (_cairo_glitz_surface_fill_rectangles): 
	Set fill type repeat on source surface.
	(_cairo_glitz_surface_show_glyphs): Add missing cairo operator to
	glitz operator conversion.
	(_cairo_glitz_surface_show_glyphs): Only render glyphs with non zero
	size. 

2005-05-11  Owen Taylor  <otaylor at redhat.com>

	* src/cairo-surface.c (_fallback_fill_rectangles):
	Fix bounding box computation.

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- cairo-surface.c	7 May 2005 04:19:50 -0000	1.67
+++ cairo-surface.c	11 May 2005 23:01:56 -0000	1.68
@@ -692,15 +692,15 @@
     y2 = rects[0].y + rects[0].height;
     
     for (i = 1; i < num_rects; i++) {
-	if (rects[0].x < x1)
-	    x1 = rects[0].x;
-	if (rects[0].y < y1)
-	    y1 = rects[0].y;
+	if (rects[i].x < x1)
+	    x1 = rects[i].x;
+	if (rects[i].y < y1)
+	    y1 = rects[i].y;
 
-	if (rects[0].x + rects[0].width > x2)
-	    x2 = rects[0].x + rects[0].width;
-	if (rects[0].y + rects[0].height > y2)
-	    y2 = rects[0].y + rects[0].height;
+	if (rects[i].x + rects[i].width > x2)
+	    x2 = rects[i].x + rects[i].width;
+	if (rects[i].y + rects[i].height > y2)
+	    y2 = rects[i].y + rects[i].height;
     }
 
     status = _fallback_init (&state, surface, x1, y1, x2 - x1, y2 - y1);

Index: cairo-win32-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32-font.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cairo-win32-font.c	8 Apr 2005 20:14:17 -0000	1.16
+++ cairo-win32-font.c	11 May 2005 23:01:56 -0000	1.17
@@ -199,9 +199,9 @@
 }
 
 static cairo_scaled_font_t *
-_win32_scaled_font_create (LOGFONTW           *logfont,
-			   cairo_matrix_t     *font_matrix,
-			   cairo_matrix_t     *ctm)
+_win32_scaled_font_create (LOGFONTW             *logfont,
+			   const cairo_matrix_t *font_matrix,
+			   const cairo_matrix_t *ctm)
 {
     cairo_win32_scaled_font_t *f;
     cairo_matrix_t scale;
@@ -385,12 +385,12 @@
 /* implement the font backend interface */
 
 static cairo_status_t
-_cairo_win32_scaled_font_create (const char           *family, 
-				 cairo_font_slant_t    slant, 
-				 cairo_font_weight_t   weight,
-				 cairo_matrix_t       *font_matrix,
-				 cairo_matrix_t       *ctm,
-				 cairo_scaled_font_t **scaled_font_out)
+_cairo_win32_scaled_font_create (const char            *family, 
+				 cairo_font_slant_t     slant, 
+				 cairo_font_weight_t    weight,
+				 const cairo_matrix_t  *font_matrix,
+				 const cairo_matrix_t  *ctm,
+				 cairo_scaled_font_t  **scaled_font_out)
 {
     LOGFONTW logfont;
     cairo_scaled_font_t *scaled_font;
@@ -1002,8 +1002,7 @@
     if (_cairo_surface_is_win32 (generic_surface) &&
 	surface->format == CAIRO_FORMAT_RGB24 &&
 	operator == CAIRO_OPERATOR_OVER &&
-	pattern->type == CAIRO_PATTERN_SOLID &&
-	_cairo_pattern_is_opaque (pattern)) {
+	_cairo_pattern_is_opaque_solid (pattern)) {
 
 	cairo_solid_pattern_t *solid_pattern = (cairo_solid_pattern_t *)pattern;
 
@@ -1012,9 +1011,10 @@
 	 */
 	COLORREF new_color;
 	
-	new_color = RGB (((int)(0xffff * solid_pattern->red)) >> 8,
-			 ((int)(0xffff * solid_pattern->green)) >> 8,
-			 ((int)(0xffff * solid_pattern->blue)) >> 8);
+	/* XXX Use the unpremultiplied or premultiplied color? */
+	new_color = RGB (((int)solid_pattern->color.red_short) >> 8,
+			 ((int)solid_pattern->color.green_short) >> 8,
+			 ((int)solid_pattern->color.blue_short) >> 8);
 
 	status = _draw_glyphs_on_surface (surface, scaled_font, new_color,
 					  0, 0,
@@ -1131,10 +1131,10 @@
 }
 
 static cairo_status_t
-_cairo_win32_font_face_create_font (void                 *abstract_face,
-				    cairo_matrix_t       *font_matrix,
-				    cairo_matrix_t       *ctm,
-				    cairo_scaled_font_t **font)
+_cairo_win32_font_face_create_font (void                  *abstract_face,
+				    const cairo_matrix_t  *font_matrix,
+				    const cairo_matrix_t  *ctm,
+				    cairo_scaled_font_t  **font)
 {
     cairo_win32_font_face_t *font_face = abstract_face;
 

Index: cairo-win32-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32-surface.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cairo-win32-surface.c	7 May 2005 04:19:50 -0000	1.20
+++ cairo-win32-surface.c	11 May 2005 23:01:56 -0000	1.21
@@ -1,6 +1,6 @@
 /* Cairo - a vector graphics library with display and print output
  *
- * Copyright © 2005 Red Hat, Inc.
+ * Copyright Â© 2005 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -194,7 +194,7 @@
 	*bits_out = bits;
 
     if (rowstride_out) {
-	/* Windows bitmaps are padded to 16-bit (word) boundaries */
+	/* Windows bitmaps are padded to 32-bit (dword) boundaries */
 	switch (format) {
 	case CAIRO_FORMAT_ARGB32:
 	case CAIRO_FORMAT_RGB24:
@@ -202,11 +202,11 @@
 	    break;
 	    
 	case CAIRO_FORMAT_A8:
-	    *rowstride_out = (width + 1) & -2;
+	    *rowstride_out = (width + 3) & ~3;
 	    break;
 	
 	case CAIRO_FORMAT_A1:
-	    *rowstride_out = ((width + 15) & -16) / 8;
+	    *rowstride_out = ((width + 31) & ~31) / 8;
 	    break;
 	}
     }
@@ -405,10 +405,6 @@
 						surface->clip_rect.width,
 						surface->clip_rect.height, &local);
     if (CAIRO_OK (status)) {
-	cairo_surface_set_filter (&local->base, surface->base.filter);
-	cairo_surface_set_matrix (&local->base, &surface->base.matrix);
-	cairo_surface_set_repeat (&local->base, surface->base.repeat);
-	
 	*image_out = (cairo_image_surface_t *)local->image;
 	*image_extra = local;
     }
@@ -548,9 +544,9 @@
 	if (mask_pattern->type != CAIRO_PATTERN_SOLID)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 
-	alpha = (int)(0xffff * pattern->alpha * mask_pattern->alpha) >> 8; 
+	alpha = ((cairo_solid_pattern_t *)mask_pattern)->color.alpha_short >> 8;
     } else {
-	alpha = (int)(0xffff * pattern->alpha) >> 8;
+        alpha = 255;
     }
 
     src_surface_pattern = (cairo_surface_pattern_t *)pattern;
@@ -606,6 +602,73 @@
     return CAIRO_INT_STATUS_UNSUPPORTED;
 }
 
+/* This big function tells us how to optimize operators for the
+ * case of solid destination and constant-alpha source
+ */
+static enum { DO_CLEAR, DO_SOURCE, DO_NOTHING, DO_UNSUPPORTED }
+categorize_solid_dest_operator (cairo_operator_t operator,
+				unsigned short   alpha)
+{
+    enum { SOURCE_TRANSPARENT, SOURCE_SOLID, SOURCE_OTHER } source;
+
+    if (alpha >= 0xff00)
+	source = SOURCE_SOLID;
+    else if (alpha < 0x100)
+	source = SOURCE_TRANSPARENT;
+    else
+	source = SOURCE_OTHER;
+    
+    switch (operator) {
+    case CAIRO_OPERATOR_CLEAR:    /* 0                 0 */
+    case CAIRO_OPERATOR_OUT:      /* 1 - Ab            0 */
+	return DO_CLEAR;
+	break;
+	
+    case CAIRO_OPERATOR_SOURCE:   /* 1                 0 */
+    case CAIRO_OPERATOR_IN:       /* Ab                0 */
+	return DO_SOURCE;
+	break;
+
+    case CAIRO_OPERATOR_OVER:     /* 1            1 - Aa */
+    case CAIRO_OPERATOR_ATOP:     /* Ab           1 - Aa */
+	if (source == SOURCE_SOLID)
+	    return DO_SOURCE;
+	else
+	    return DO_UNSUPPORTED;
+	break;
+	
+    case CAIRO_OPERATOR_DEST_OUT: /* 0            1 - Aa */
+    case CAIRO_OPERATOR_XOR:      /* 1 - Ab       1 - Aa */
+	if (source == SOURCE_SOLID)
+	    return DO_CLEAR;
+	else if (source == SOURCE_TRANSPARENT)
+	    return DO_NOTHING;
+	else
+	    return DO_UNSUPPORTED;
+    	break;
+	
+    case CAIRO_OPERATOR_DEST:     /* 0                 1 */
+    case CAIRO_OPERATOR_DEST_OVER:/* 1 - Ab            1 */
+    case CAIRO_OPERATOR_SATURATE: /* min(1,(1-Ab)/Aa)  1 */
+	return DO_NOTHING;
+	break;
+
+    case CAIRO_OPERATOR_DEST_IN:  /* 0                Aa */
+    case CAIRO_OPERATOR_DEST_ATOP:/* 1 - Ab           Aa */
+	if (source == SOURCE_SOLID)
+	    return DO_NOTHING;
+	else if (source == SOURCE_TRANSPARENT)
+	    return DO_CLEAR;
+	else
+	    return DO_UNSUPPORTED;
+	break;
+	
+    case CAIRO_OPERATOR_ADD:	  /* 1                1 */
+	return DO_UNSUPPORTED;
+	break;
+    }	
+}
+
 static cairo_int_status_t
 _cairo_win32_surface_fill_rectangles (void			*abstract_surface,
 				      cairo_operator_t		operator,
@@ -624,17 +687,24 @@
      */
     if (surface->image)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
-    
-    /* We could support possibly support more operators for color->alpha = 0xffff.
-     * for CAIRO_OPERATOR_SOURCE, alpha doesn't matter since we know the destination
-     * image doesn't have alpha. (surface->pixman_image is non-NULL for all
+
+    /* Optimize for no destination alpha (surface->pixman_image is non-NULL for all
      * surfaces with alpha.)
      */
-    if (operator != CAIRO_OPERATOR_SOURCE)
+    switch (categorize_solid_dest_operator (operator, color->alpha_short)) {
+    case DO_CLEAR:
+	new_color = RGB (0, 0, 0);
+	break;	
+    case DO_SOURCE:
+	new_color = RGB (color->red_short >> 8, color->blue_short >> 8, color->green_short >> 8);
+	break;
+    case DO_NOTHING:
+	return CAIRO_STATUS_SUCCESS;
+    case DO_UNSUPPORTED:
+    default:
 	return CAIRO_INT_STATUS_UNSUPPORTED;
-
-    new_color = RGB (color->red_short >> 8, color->green_short >> 8, color->blue_short >> 8);
-
+    }
+    
     new_brush = CreateSolidBrush (new_color);
     if (!new_brush)
 	return _cairo_win32_print_gdi_error ("_cairo_win32_surface_fill_rectangles");
@@ -781,9 +851,10 @@
 }
 
 static cairo_int_status_t
-_cairo_win32_get_extents (void		    *abstract_surface,
-			  cairo_rectangle_t *rectangle)
+_cairo_win32_surface_get_extents (void		    *abstract_surface,
+				  cairo_rectangle_t *rectangle)
 {
+    cairo_win32_surface_t *surface = abstract_surface;
     RECT clip_box;
 
     if (GetClipBox (surface->dc, &clip_box) == ERROR)




More information about the cairo-commit mailing list