[cairo-commit] cairo/test Makefile.am, 1.34, 1.35 cairo-test.c, 1.18, 1.19 clip-twice.c, 1.3, 1.4 coverage.c, 1.6, 1.7 fill-rule.c, 1.4, 1.5 line-width.c, 1.3, 1.4 linear-gradient.c, 1.3, 1.4 pixman-rotate.c, 1.5, 1.6 set-source.c, 1.1, 1.2 text-rotate.c, 1.7, 1.8 trap-clip.c, 1.1, 1.2

Carl Worth commit at pdx.freedesktop.org
Thu Apr 14 14:42:29 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv4566/test

Modified Files:
	Makefile.am cairo-test.c clip-twice.c coverage.c fill-rule.c 
	line-width.c linear-gradient.c pixman-rotate.c set-source.c 
	text-rotate.c trap-clip.c 
Log Message:

        * src/cairo.h:
        * src/cairo.c: Rename, add, and delete:

                cairo_set_pattern       -> cairo_set_source
                cairo_get_pattern       -> cairo_get_source
                cairo_set_rgb_color     -> cairo_set_source_rgb
                                        -> cairo_set_source_rgba
                cairo_set_alpha         ->
                cairo_get_alpha         ->

        Note that we'll likely want to add cairo_set_source_surface.

        * src/cairo-color.c: Add _cairo_stock_color helper function.
        Improve some interfaces:

                _cairo_color_init          _cairo_color_init_rgb
                _cairo_color_set_rgb    -> _cairo_color_init_rgba
                _cairo_color_set_alpha     _cairo_color_multiply_alpha

                _cairo_color_get_rgb    -> _cairo_color_get_rbga
                                           _cairo_color_get_rgba_premultiplied

        * src/cairoint.h: Add cairo_stock_t and some helper macros:

                CAIRO_COLOR_WHITE
                CAIRO_COLOR_BLACK
                CAIRO_COLOR_TRANSPARENT

        Fix cairo_pattern_t by eliminating pattern->alpha.
        Fix cairo_solid_pattern_t to use cairo_color_t rather than three
        doubles.

        * src/cairo-glitz-surface.c:
        (_cairo_glitz_pattern_acquire_surface),
        (_cairo_glitz_pattern_acquire_surfaces),
        (_cairo_glitz_surface_composite_trapezoids): Track removal of
        pattern->alpha, simplifying the code considerably

        * src/cairo-gstate-private.h:

        * src/cairo-gstate.c: Track _cairo_color interface changes. Remove
        gstate->alpha. Propagate down set_source renamings.

        * src/cairo.h:
        * src/cairo-pattern.c: Rename:

                cairo_pattern_add_color_stop -> cairo_pattern_add_color_stop_rgba

        and add:

                cairo_pattern_add_color_stop_rgb

        Remove pattern->alpha, simplifying the code considerably.

        * src/cairo-pdf-surface.c:
        * src/cairo-ps-surface.c: Track pattern and color interface
        changes.

        * src/cairo-surface.c: Add const where appropriate on
        cairo_color_t*.

        * src/cairo-xlib-surface.c: (_cairo_surface_is_xlib): Add private
        type inspection predicate.
        (cairo_xlib_surface_set_size): Add check for surface type
        mismatch, (no useful error reporting yet, though).

        * test/Makefile.am: Note coverage as en expected failure.

        * test/cairo-test.c: (cairo_test_expect_failure): Improve line
        wrap on expected failure messages.

        * test/clip-twice.c:
        * test/coverage.c:
        * test/fill-rule.c:
        * test/line-width.c:
        * test/linear-gradient.c:
        * test/pixman-rotate.c:
        * test/set-source.c:
        * test/text-rotate.c:
        * test/trap-clip.c: Port all tests to new cairo_set_source
        interfaces.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/test/Makefile.am,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- Makefile.am	14 Apr 2005 17:02:58 -0000	1.34
+++ Makefile.am	14 Apr 2005 21:42:27 -0000	1.35
@@ -57,6 +57,7 @@
 # Also, any test listed here should call cairo_test_expect_failure and
 # provide an explanation for the expected failure.
 XFAIL_TESTS =		\
+coverage		\
 pixman-rotate		\
 text-rotate
 

Index: cairo-test.c
===================================================================
RCS file: /cvs/cairo/cairo/test/cairo-test.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cairo-test.c	14 Apr 2005 17:02:58 -0000	1.18
+++ cairo-test.c	14 Apr 2005 21:42:27 -0000	1.19
@@ -102,7 +102,7 @@
 			   cairo_test_draw_function_t  draw,
 			   const char		      *because)
 {
-    printf ("%s is expected to fail %s\n", test->name, because);
+    printf ("%s is expected to fail:\n\t%s\n", test->name, because);
     return cairo_test (test, draw);
 }
 

Index: clip-twice.c
===================================================================
RCS file: /cvs/cairo/cairo/test/clip-twice.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- clip-twice.c	29 Mar 2005 08:02:19 -0000	1.3
+++ clip-twice.c	14 Apr 2005 21:42:27 -0000	1.4
@@ -37,7 +37,6 @@
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-    cairo_set_alpha (cr, 1.0);
     cairo_new_path (cr);
     cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 3, 0, 2 * M_PI);
     cairo_clip (cr);
@@ -52,7 +51,7 @@
     cairo_close_path (cr);
     cairo_clip (cr);
 
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
+    cairo_set_source_rgb (cr, 0, 0, 0.6);
 
     cairo_new_path (cr);
     cairo_move_to (cr, 0, 0);

Index: coverage.c
===================================================================
RCS file: /cvs/cairo/cairo/test/coverage.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- coverage.c	13 Apr 2005 21:24:27 -0000	1.6
+++ coverage.c	14 Apr 2005 21:42:27 -0000	1.7
@@ -40,15 +40,13 @@
 static void
 set_solid_pattern (cairo_t *cr, int x, int y)
 {
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 1.0);
+    cairo_set_source_rgb (cr, 0, 0, 0.6);
 }
 
 static void
 set_translucent_pattern (cairo_t *cr, int x, int y)
 {
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 0.5);
+    cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
 }
 
 static void
@@ -58,10 +56,9 @@
 
     pattern =
 	cairo_pattern_create_linear (x, y, x + WIDTH, y + HEIGHT);
-    cairo_pattern_add_color_stop (pattern, 0, 1, 1, 1, 1);
-    cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.4, 1);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
+    cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 1, 1);
+    cairo_pattern_add_color_stop_rgb (pattern, 1, 0, 0, 0.4);
+    cairo_set_source (cr, pattern);
 }
 
 static void
@@ -70,8 +67,7 @@
     cairo_pattern_t *pattern;
 
     pattern = cairo_test_create_png_pattern (cr, png_filename);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
+    cairo_set_source (cr, pattern);
 }
 
 static void
@@ -80,8 +76,7 @@
     cairo_pattern_t *pattern;
 
     pattern = cairo_test_create_png_pattern (cr, png_filename);
-    cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 0.5);
+    cairo_set_source (cr, pattern);
 }
 
 #if WE_FIX_THE_TEST_SO_THAT_IT_DOES_NOT_DEPEND_ON_HOW_FREETPYE_IS_COMPILED
@@ -165,7 +160,6 @@
 
 	    cairo_save (cr);
 
-	    cairo_set_alpha (cr, 1.0);
 	    cairo_new_path (cr);
 	    cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
 		       WIDTH / 3, 0, 2 * M_PI);
@@ -186,5 +180,6 @@
 int
 main (void)
 {
-    return cairo_test (&test, draw);
+    return cairo_test_expect_failure (&test, draw,
+				      "missing API to replace cairo_show_surface with alpha");
 }

Index: fill-rule.c
===================================================================
RCS file: /cvs/cairo/cairo/test/fill-rule.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fill-rule.c	29 Mar 2005 08:02:19 -0000	1.4
+++ fill-rule.c	14 Apr 2005 21:42:27 -0000	1.5
@@ -100,7 +100,7 @@
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-    cairo_set_rgb_color (cr, 1, 0, 0);
+    cairo_set_source_rgb (cr, 1, 0, 0);
 
     cairo_translate (cr, 1, 1);
     little_star_path (cr);

Index: line-width.c
===================================================================
RCS file: /cvs/cairo/cairo/test/line-width.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- line-width.c	29 Mar 2005 08:02:19 -0000	1.3
+++ line-width.c	14 Apr 2005 21:42:27 -0000	1.4
@@ -41,7 +41,7 @@
 {
     int i;
 
-    cairo_set_rgb_color (cr, 0, 0, 0);
+    cairo_set_source_rgb (cr, 0, 0, 0);
     cairo_translate (cr, 2, 2);
 
     for (i=0; i < LINES; i++) {

Index: linear-gradient.c
===================================================================
RCS file: /cvs/cairo/cairo/test/linear-gradient.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- linear-gradient.c	29 Mar 2005 08:02:19 -0000	1.3
+++ linear-gradient.c	14 Apr 2005 21:42:27 -0000	1.4
@@ -72,7 +72,7 @@
     cairo_clip (cr);
     cairo_new_path(cr);
     
-    cairo_set_rgb_color (cr, 0.0, 0.0, 0.0);
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
     cairo_rectangle (cr, 0, 0, 1, 1);
     cairo_fill (cr);
     
@@ -84,25 +84,20 @@
  					    0.5 * cos (gradient_angle),   0.5 * sin (gradient_angle));
 
     if (n_stops == 2) {
-	cairo_pattern_add_color_stop (pattern, 0.,
-				      0.3, 0.3, 0.3,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 1.,
-				      1.0, 1.0, 1.0,
-				      1.0);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.,
+					  0.3, 0.3, 0.3);
+	cairo_pattern_add_color_stop_rgb (pattern, 1.,
+					  1.0, 1.0, 1.0);
     } else {
-	cairo_pattern_add_color_stop (pattern, 0.,
-				      1.0, 0.0, 0.0,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 0.5,
-				      1.0, 1.0, 1.0,
-				      1.0);
-	cairo_pattern_add_color_stop (pattern, 1.,
-				      0.0, 0.0, 1.0,
-				      1.0);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.,
+					  1.0, 0.0, 0.0);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.5,
+					  1.0, 1.0, 1.0);
+	cairo_pattern_add_color_stop_rgb (pattern, 1.,
+					  0.0, 0.0, 1.0);
     }
 
-    cairo_set_pattern (cr, pattern);
+    cairo_set_source (cr, pattern);
     cairo_pattern_destroy (pattern);
     cairo_rectangle (cr, -0.5, -0.5, 1, 1);
     cairo_fill (cr);
@@ -113,7 +108,7 @@
 {
     int i, j, k;
 
-    cairo_set_rgb_color (cr, 0.5, 0.5, 0.5);
+    cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
     cairo_rectangle (cr, 0, 0, width, height);
     cairo_fill (cr);
 

Index: pixman-rotate.c
===================================================================
RCS file: /cvs/cairo/cairo/test/pixman-rotate.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pixman-rotate.c	14 Apr 2005 17:02:58 -0000	1.5
+++ pixman-rotate.c	14 Apr 2005 21:42:27 -0000	1.6
@@ -35,14 +35,12 @@
     cairo_set_target_surface (cr, stamp);
     cairo_new_path (cr);
     cairo_rectangle (cr, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2);
-    cairo_set_rgb_color (cr, 1, 0, 0);
-    cairo_set_alpha (cr, 0.8);
+    cairo_set_source_rgba (cr, 1, 0, 0, 0.8);
     cairo_fill (cr);
 
     cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
     cairo_set_line_width (cr, 2);
-    cairo_set_rgb_color (cr, 0, 0, 0);
-    cairo_set_alpha (cr, 1);
+    cairo_set_source_rgb (cr, 0, 0, 0);
     cairo_stroke (cr);
 
     cairo_set_target_surface (cr, target);
@@ -51,8 +49,7 @@
      * image should be. */
     cairo_new_path (cr);
     cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT);
-    cairo_set_rgb_color (cr, 1, 1, 0);
-    cairo_set_alpha (cr, 0.3);
+    cairo_set_source_rgba (cr, 1, 1, 0, 0.3);
     cairo_fill (cr);
 
 #if 1 /* Set to 0 to generate reference image */
@@ -62,7 +59,6 @@
     cairo_translate (cr, WIDTH, HEIGHT);
 #endif
 
-    cairo_set_alpha (cr, 1);
     cairo_show_surface (cr, stamp, WIDTH + 2, HEIGHT + 2);
 
     cairo_show_page (cr);
@@ -77,6 +73,5 @@
 main (void)
 {
     return cairo_test_expect_failure (&test, draw,
-				      "because of a known off-by-one bug "
-				      "when rotating a pixman image");
+				      "known off-by-one bug when rotating a pixman image");
 }

Index: set-source.c
===================================================================
RCS file: /cvs/cairo/cairo/test/set-source.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- set-source.c	14 Apr 2005 16:13:48 -0000	1.1
+++ set-source.c	14 Apr 2005 21:42:27 -0000	1.2
@@ -52,23 +52,21 @@
     for (i=0; i < width; i++) {
 	switch (i) {
 	case 0:
-	    cairo_set_rgb_color (cr, .6, .7, .8);
+	    cairo_set_source_rgb (cr, .6, .7, .8);
 	    break;
 	case 1:
-	    cairo_set_rgb_color (cr, .2, .4, .6);
-	    cairo_set_alpha (cr, 0.5);
+	    cairo_set_source_rgba (cr, .2, .4, .6, 0.5);
 	    break;
 	case 2:
-	    /* XXX: When ported, this should become:
+#if WE_HAD_SUPPORT_FOR_PREMULTIPLIED
 	    cairo_set_source_rgba_premultiplied (cr, .1, .2, .3, 0.5);
-	    */
-	    cairo_set_rgb_color (cr, .2, .4, .6);
-	    cairo_set_alpha (cr, 0.5);
+#else
+	    cairo_set_source_rgba (cr, .2, .4, .6, 0.5);
+#endif
 	    break;
 	case 3:
 	default:
-	    cairo_set_alpha (cr, 1.0);
-	    cairo_set_pattern (cr, pattern);
+	    cairo_set_source (cr, pattern);
 	    break;
 	}
 

Index: text-rotate.c
===================================================================
RCS file: /cvs/cairo/cairo/test/text-rotate.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- text-rotate.c	14 Apr 2005 17:02:58 -0000	1.7
+++ text-rotate.c	14 Apr 2005 21:42:27 -0000	1.8
@@ -83,7 +83,7 @@
 		       CAIRO_FONT_WEIGHT_NORMAL);
     cairo_set_font_size (cr, TEXT_SIZE);
 
-    cairo_set_rgb_color (cr, 0,0,0);
+    cairo_set_source_rgb (cr, 0, 0, 0);
 
     cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0);
 
@@ -101,10 +101,10 @@
 	cairo_rotate (cr, 2*M_PI*i/NUM_TEXT);
 	cairo_set_line_width (cr, 1.0);
 	cairo_rectangle (cr, x_off - 0.5, y_off - 0.5, extents.width + 1, extents.height + 1);
-	cairo_set_rgb_color (cr, 1, 0, 0);
+	cairo_set_source_rgb (cr, 1, 0, 0);
 	cairo_stroke (cr);
 	cairo_move_to (cr, x_off - extents.x_bearing, y_off - extents.y_bearing);
-	cairo_set_rgb_color (cr, 0, 0, 0);
+	cairo_set_source_rgb (cr, 0, 0, 0);
 	cairo_show_text (cr, "cairo");
 	cairo_restore (cr);
     }
@@ -116,6 +116,5 @@
 main (void)
 {
     return cairo_test_expect_failure (&test, draw,
-				      "because of known glyph positioning bugs "
-				      "with rotated text");
+				      "known bugs in positioning rotated glyphs");
 }

Index: trap-clip.c
===================================================================
RCS file: /cvs/cairo/cairo/test/trap-clip.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- trap-clip.c	13 Apr 2005 18:23:43 -0000	1.1
+++ trap-clip.c	14 Apr 2005 21:42:27 -0000	1.2
@@ -36,15 +36,13 @@
 static void
 set_solid_pattern (cairo_t *cr, int x, int y)
 {
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 1.0);
+    cairo_set_source_rgb (cr, 0, 0, 0.6);
 }
 
 static void
 set_translucent_pattern (cairo_t *cr, int x, int y)
 {
-    cairo_set_rgb_color (cr, 0, 0, 0.6);
-    cairo_set_alpha (cr, 0.5);
+    cairo_set_source_rgba (cr, 0, 0, 0.6, 0.5);
 }
 
 static void
@@ -57,7 +55,6 @@
     cairo_pattern_add_color_stop (pattern, 0, 1, 1, 1, 1);
     cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.4, 1);
     cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
 }
 
 static void
@@ -67,7 +64,6 @@
 
     pattern = cairo_test_create_png_pattern (cr, png_filename);
     cairo_set_pattern (cr, pattern);
-    cairo_set_alpha (cr, 1);
 }
 
 static void
@@ -113,7 +109,6 @@
 static void
 clip_rect (cairo_t *cr, int x, int y)
 {
-    cairo_set_alpha (cr, 1.0);
     cairo_new_path (cr);
     cairo_rectangle (cr, x + (int)WIDTH / 6, y + (int)HEIGHT / 6,
 		     4 * ((int)WIDTH  / 6), 4 * ((int)WIDTH / 6));
@@ -126,7 +121,6 @@
 {
     int height = HEIGHT / 3;
   
-    cairo_set_alpha (cr, 1.0);
     cairo_new_path (cr);
     cairo_rectangle (cr, x, y, WIDTH, height);
     cairo_rectangle (cr, x, y + 2 * height, WIDTH, height);
@@ -137,7 +131,6 @@
 static void
 clip_circle (cairo_t *cr, int x, int y)
 {
-    cairo_set_alpha (cr, 1.0);
     cairo_new_path (cr);
     cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
 	       WIDTH / 3, 0, 2 * M_PI);




More information about the cairo-commit mailing list