[cairo-commit] 3 commits - perf/micro src/cairo-script-surface.c test/inverse-text.c test/inverse-text.image16.ref.png test/inverse-text.ps.ref.png test/inverse-text.ref.png test/Makefile.am test/Makefile.sources

Chris Wilson ickle at kemper.freedesktop.org
Fri Apr 2 00:55:33 PDT 2010


 perf/micro/paint-with-alpha.c     |    9 ++++-
 perf/micro/paint.c                |    8 +++-
 src/cairo-script-surface.c        |    9 ++++-
 test/Makefile.am                  |    1 
 test/Makefile.sources             |    1 
 test/inverse-text.c               |   67 ++++++++++++++++++++++++++++++++++++++
 test/inverse-text.image16.ref.png |binary
 test/inverse-text.ps.ref.png      |binary
 test/inverse-text.ref.png         |binary
 9 files changed, 92 insertions(+), 3 deletions(-)

New commits:
commit 24fc36c10f5c1c34e3059a8334178743052d7ad2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Apr 2 08:44:45 2010 +0100

    script: Fix endian encoding of '<|' length.
    
    Andrea found and fixed (and updated all the traces!) an endian bug where
    we were encoding a 32bit length inside the compressed string stream.
    However, this one inside the script backed escaped his notice.

diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index eb8a29d..9b37ca9 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -59,6 +59,12 @@
 
 #include <ctype.h>
 
+#ifdef WORDS_BIGENDIAN
+#define to_be32(x) x
+#else
+#define to_be32(x) bswap_32(x)
+#endif
+
 #define _cairo_output_stream_puts(S, STR) \
     _cairo_output_stream_write ((S), (STR), strlen (STR))
 
@@ -1267,6 +1273,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
 
 	    base85_stream = _cairo_base85_stream_create (ctx->stream);
 
+	    len = to_be32 (len);
 	    _cairo_output_stream_write (base85_stream, &len, sizeof (len));
 
 	    zlib_stream = _cairo_deflate_stream_create (base85_stream);
@@ -2585,7 +2592,7 @@ _emit_type42_font (cairo_script_surface_t *surface,
 				 load_flags);
 
     base85_stream = _cairo_base85_stream_create (ctx->stream);
-    len = size;
+    len = to_be32 (size);
     _cairo_output_stream_write (base85_stream, &len, sizeof (len));
 
     zlib_stream = _cairo_deflate_stream_create (base85_stream);
commit 697094488c652ad351301696bba9a384cc70002c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Apr 2 08:40:28 2010 +0100

    test: Add inverse text
    
    This is exercising a bug that I have introduced either in the xcb
    backend or in the driver in my experimental branches. So simple, yet so
    wrong.

diff --git a/test/Makefile.am b/test/Makefile.am
index 62c36ba..e7143a9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -568,6 +568,7 @@ REFERENCE_IMAGES = \
 	infinite-join.ps2.ref.png \
 	infinite-join.ps3.ref.png \
 	infinite-join.ref.png \
+	inverse-text.ref.png \
 	joins.ps.ref.png \
 	joins.ref.png \
 	large-clip.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 2397824..860e05f 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -118,6 +118,7 @@ test_sources = \
 	in-fill-empty-trapezoid.c			\
 	in-fill-trapezoid.c				\
 	invalid-matrix.c				\
+	inverse-text.c					\
 	joins.c						\
 	large-clip.c					\
 	large-font.c					\
diff --git a/test/inverse-text.c b/test/inverse-text.c
new file mode 100644
index 0000000..5551220
--- /dev/null
+++ b/test/inverse-text.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ *         Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+#define TEXT_SIZE 12
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    /* This is just the inverse of select-font-face.c */
+    cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+    cairo_paint (cr);
+
+    cairo_set_source_rgb (cr, 1, 1, 1);
+
+    cairo_set_font_size (cr, TEXT_SIZE);
+    cairo_move_to (cr, 0, TEXT_SIZE);
+
+    cairo_select_font_face (cr, "Bitstream Vera Serif",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_show_text (cr, "i-am-serif");
+
+    cairo_select_font_face (cr, "Bitstream Vera Sans",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_show_text (cr, " i-am-sans");
+
+    cairo_select_font_face (cr, "Bitstream Vera Sans Mono",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_show_text (cr, " i-am-mono");
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (inverse_text,
+	    "Tests rendering of inverse text (white-on-black)",
+	    "font, text", /* keywords */
+	    NULL, /* requirements */
+	    192, TEXT_SIZE + 4,
+	    NULL, draw)
diff --git a/test/inverse-text.image16.ref.png b/test/inverse-text.image16.ref.png
new file mode 100644
index 0000000..a24266d
Binary files /dev/null and b/test/inverse-text.image16.ref.png differ
diff --git a/test/inverse-text.ps.ref.png b/test/inverse-text.ps.ref.png
new file mode 100644
index 0000000..6043684
Binary files /dev/null and b/test/inverse-text.ps.ref.png differ
diff --git a/test/inverse-text.ref.png b/test/inverse-text.ref.png
new file mode 100644
index 0000000..014e70b
Binary files /dev/null and b/test/inverse-text.ref.png differ
commit fe610d559c70ab67f782b122437908ac80788611
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Mar 31 09:33:30 2010 +0100

    perf/micro: Show megapixel fill rate during paint.

diff --git a/perf/micro/paint-with-alpha.c b/perf/micro/paint-with-alpha.c
index 048cdb0..051d653 100644
--- a/perf/micro/paint-with-alpha.c
+++ b/perf/micro/paint-with-alpha.c
@@ -38,6 +38,12 @@ do_paint_with_alpha (cairo_t *cr, int width, int height, int loops)
     return cairo_perf_timer_elapsed ();
 }
 
+static double
+count_paint_with_alpha (cairo_t *cr, int width, int height)
+{
+    return width * height / 1e6; /* Mpix/s */
+}
+
 void
 paint_with_alpha (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 {
@@ -45,5 +51,6 @@ paint_with_alpha (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 	return;
 
     cairo_perf_cover_sources_and_operators (perf, "paint-with-alpha",
-					    do_paint_with_alpha, NULL);
+					    do_paint_with_alpha,
+					    count_paint_with_alpha);
 }
diff --git a/perf/micro/paint.c b/perf/micro/paint.c
index ce8cfd3..1ba108f 100644
--- a/perf/micro/paint.c
+++ b/perf/micro/paint.c
@@ -38,11 +38,17 @@ do_paint (cairo_t *cr, int width, int height, int loops)
     return cairo_perf_timer_elapsed ();
 }
 
+static double
+count_paint (cairo_t *cr, int width, int height)
+{
+    return width * height / 1e6; /* Mpix/s */
+}
+
 void
 paint (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 {
     if (! cairo_perf_can_run (perf, "paint", NULL))
 	return;
 
-    cairo_perf_cover_sources_and_operators (perf, "paint", do_paint, NULL);
+    cairo_perf_cover_sources_and_operators (perf, "paint", do_paint, count_paint);
 }


More information about the cairo-commit mailing list