[cairo-commit] 5 commits - doc/public Makefile.am src/cairo-image-surface.c src/check-doc-syntax.sh

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Jan 28 21:43:18 PST 2008


 Makefile.am                    |    4 +---
 doc/public/Makefile.am         |    4 ++--
 doc/public/check-doc-syntax.sh |   11 +++++++++++
 src/cairo-image-surface.c      |   20 +++++++++++---------
 src/check-doc-syntax.sh        |   40 ++++++++++++++++++++++++++++++----------
 5 files changed, 55 insertions(+), 24 deletions(-)

New commits:
commit 013781137ff4940d0b9e04b656c20af37bbd5333
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 29 00:42:51 2008 -0500

    [cairo-image-surface.c] Cleanup stride checking and improve docs

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 4bd7d9d..60c0592 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -394,6 +394,9 @@ _cairo_image_surface_create_with_content (cairo_content_t	content,
 				       width, height);
 }
 
+/* pixman required stride alignment in bytes.  should be power of two. */
+#define STRIDE_ALIGNMENT (sizeof (uint32_t))
+
 /**
  * cairo_format_stride_for_width:
  * @format: A #cairo_format_t value
@@ -425,10 +428,7 @@ cairo_format_stride_for_width (cairo_format_t	format,
 {
     int bpp = _cairo_format_bits_per_pixel (format);
 
-    /* Convert from bits-per-row to bytes-per-row with rounding to the
-     * next 4-byte boundary. This satisifies the current alignment
-     * requirements of pixman. */
-    return (((bpp * width) + 31) >> 5) << 2;
+    return ((bpp*width+7)/8 + STRIDE_ALIGNMENT-1) & ~(STRIDE_ALIGNMENT-1);
 }
 
 /**
@@ -451,9 +451,9 @@ cairo_format_stride_for_width (cairo_format_t	format,
  * must explicitly clear the buffer, using, for example,
  * cairo_rectangle() and cairo_fill() if you want it cleared.
  *
- * Note that the stride will often be larger than
- * width*bytes_per_pixel to provide proper alignment for each
- * row. This alignment is required to allow high-performance rendering
+ * Note that the stride may be larger than
+ * width*bytes_per_pixel to provide proper alignment for each pixel
+ * and row. This alignment is required to allow high-performance rendering
  * within cairo. The correct way to obtain a legal stride value is to
  * call cairo_format_stride_for_width() with the desired format and
  * maximum image width value, and the use the resulting stride value
@@ -486,7 +486,7 @@ cairo_image_surface_create_for_data (unsigned char     *data,
     if (! CAIRO_FORMAT_VALID (format))
 	return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_INVALID_FORMAT));
 
-    if (stride % sizeof (uint32_t) != 0)
+    if ((stride & (STRIDE_ALIGNMENT-1)) != 0)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
 
     pixman_format = _cairo_format_to_pixman_format_code (format);
commit 8e3250b8564a346c61e926a6aa61f18ae3f60c93
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 29 00:36:38 2008 -0500

    [Makefile.am] Remove ROADMAP and TODO from dist files

diff --git a/Makefile.am b/Makefile.am
index f112368..2be43dd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,9 +67,7 @@ EXTRA_DIST = \
 	NEWS \
 	PORTING_GUIDE \
 	README \
-	RELEASING \
-	ROADMAP \
-	TODO
+	RELEASING
 DISTCLEANFILES = config.cache
 distclean-local: lcov-clean
 
commit 81e4cc3bd7d1fec659a19f8b37253aaebe12c99b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 29 00:36:16 2008 -0500

    [cairo_image_surface_create_for_data] Document stride error status

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 59ea6f2..4bd7d9d 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -466,7 +466,9 @@ cairo_format_stride_for_width (cairo_format_t	format,
  *
  * This function always returns a valid pointer, but it will return a
  * pointer to a "nil" surface in the case of an error such as out of
- * memory or an invalid stride value. You can use
+ * memory or an invalid stride value. In case of invalid stride value
+ * the error status of the returned surface will be
+ * %CAIRO_STATUS_INVALID_STRIDE.  You can use
  * cairo_surface_status() to check for this.
  *
  * See cairo_surface_set_user_data() for a means of attaching a
commit 6153a3b620641b1fb7b64a050a168482d2a42f2c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jan 29 00:34:00 2008 -0500

    [doc] Run check-doc-syntax.sh for SGML docs too

diff --git a/doc/public/Makefile.am b/doc/public/Makefile.am
index b4dd16c..bf80aac 100644
--- a/doc/public/Makefile.am
+++ b/doc/public/Makefile.am
@@ -72,5 +72,5 @@ EXTRA_DIST += version.xml.in
 
 check: doc
 
-TESTS_ENVIRONMENT = srcdir="$(srcdir)" MAKE="$(MAKE)"
-TESTS = check-doc-coverage.sh
+TESTS_ENVIRONMENT = srcdir="$(srcdir)" top_srcdir="$(top_srcdir)" MAKE="$(MAKE)"
+TESTS = check-doc-coverage.sh check-doc-syntax.sh
diff --git a/doc/public/check-doc-syntax.sh b/doc/public/check-doc-syntax.sh
new file mode 100755
index 0000000..d59d3eb
--- /dev/null
+++ b/doc/public/check-doc-syntax.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+LANG=C
+
+test -z "$srcdir" && srcdir=.
+test -z "$top_srcdir" && top_srcdir=$srcdir/../..
+
+SGML_DOCS=true
+FILES=$srcdir/tmpl/*.sgml
+
+. "$top_srcdir/src/check-doc-syntax.sh"
diff --git a/src/check-doc-syntax.sh b/src/check-doc-syntax.sh
index 210ca4f..eeb96b2 100755
--- a/src/check-doc-syntax.sh
+++ b/src/check-doc-syntax.sh
@@ -12,18 +12,30 @@ status=0
 
 echo Checking documentation for incorrect syntax
 
-FILES=`find "$srcdir" -name '*.h' -or -name '*.c' -or -name '*.cpp'`
+# Note: this test is also run from doc/public/ to check the SGML files
 
-enum_regexp='^\([/ ][*] .*[^%@]\)\<\(FALSE\|TRUE\|NULL\|CAIRO_[0-9A-Z_]*[^(0-9A-Z_]\)'
-if grep "$enum_regexp" $FILES; then
+if test "x$SGML_DOCS" = x; then
+	FILES=`find "$srcdir" -name '*.h' -or -name '*.c' -or -name '*.cpp'`
+fi
+
+enum_regexp='\([^%@]\|^\)\<\(FALSE\|TRUE\|NULL\|CAIRO_[0-9A-Z_]*[^(0-9A-Z_]\)'
+if test "x$SGML_DOCS" = x; then
+	enum_regexp='^[/ ][*] .*'$enum_regexp
+fi
+if grep "$enum_regexp" $FILES | grep -v '#####'; then
 	status=1
 	echo Error: some macros in the docs are not prefixed by percent sign.
-	echo Fix this by running the following sed command as many times as needed:
-	echo "	sed -i 's@$enum_regexp@\\1%\\2@' *.h *.c *.cpp"
+	echo Fix this by searching for the following regexp in the above files:
+	echo "	'$enum_regexp'"
 fi
 
-type_regexp='^[/ ][*]\( .*[^#]\| \)\<\(cairo[0-9a-z_]*_t\>\($\|[^:]$\|[^:].\)\)'
-if grep "$type_regexp" $FILES; then
+type_regexp='\( .*[^#]\| \|^\)\<cairo[0-9a-z_]*_t\>\($\|[^:]$\|[^:].\)'
+if test "x$SGML_DOCS" = x; then
+	type_regexp='^[/ ][*]'$type_regexp
+else
+	type_regexp='\(.'$type_regexp'\)\|\('$type_regexp'.\)'
+fi
+if grep "$type_regexp" $FILES | grep -v '#####'; then
 	status=1
 	echo Error: some type names in the docs are not prefixed by hash sign,
 	echo neither are the only token in the doc line followed by collon.
@@ -31,8 +43,11 @@ if grep "$type_regexp" $FILES; then
 	echo "	'$type_regexp'"
 fi
 
-func_regexp='^\([/ ][*] .*[^#]\)\<\(cairo_[][<>/0-9a-z_]*\> \?[^][ <>(]\)'
-if grep "$func_regexp" $FILES; then
+func_regexp='\([^#]\|^\)\<\(cairo_[][<>/0-9a-z_]*\> \?[^][ <>(]\)'
+if test "x$SGML_DOCS" = x; then
+	func_regexp='^[/ ][*] .*'$func_regexp
+fi
+if grep "$func_regexp" $FILES | grep -v '#####'; then
 	status=1
 	echo Error: some function names in the docs are not followed by parantheses.
 	echo Fix this by searching for the following regexp in the above files:
commit 3f7d301786ce345cc4221f434bda6751e9b97ad1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Jan 28 23:56:23 2008 -0500

    [src/check-doc-syntax.sh] Skip test if GNU grep is not available

diff --git a/src/check-doc-syntax.sh b/src/check-doc-syntax.sh
index 7b0908f..210ca4f 100755
--- a/src/check-doc-syntax.sh
+++ b/src/check-doc-syntax.sh
@@ -2,10 +2,15 @@
 
 LANG=C
 
+if ! grep --version 2>/dev/null | grep GNU >/dev/null; then
+	echo "GNU grep not found; skipping test"
+	exit 0
+fi
+
 test -z "$srcdir" && srcdir=.
 status=0
 
-echo Checking documentation blocks for missing decorators
+echo Checking documentation for incorrect syntax
 
 FILES=`find "$srcdir" -name '*.h' -or -name '*.c' -or -name '*.cpp'`
 


More information about the cairo-commit mailing list