[cairo-commit] 2 commits - src/cairo.h src/cairo-mutex-type-private.h src/cairo-svg-surface.c src/cairo-types-private.h src/cairo-xlib-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed May 28 14:19:51 PDT 2008


 src/cairo-mutex-type-private.h |    8 +++----
 src/cairo-svg-surface.c        |    2 -
 src/cairo-types-private.h      |    4 +--
 src/cairo-xlib-surface.c       |   44 ++++++++++++++++++-----------------------
 src/cairo.h                    |   16 +++++++-------
 5 files changed, 35 insertions(+), 39 deletions(-)

New commits:
commit 4e1024114872a01fef01ec0b9136e09f4613e5d2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed May 28 17:12:51 2008 -0400

    Fix whitespace

diff --git a/src/cairo-mutex-type-private.h b/src/cairo-mutex-type-private.h
index 3dc5f49..0b258db 100644
--- a/src/cairo-mutex-type-private.h
+++ b/src/cairo-mutex-type-private.h
@@ -75,9 +75,9 @@
 #  define CAIRO_MUTEX_IMPL_INITIALIZE() do {	\
        if (!_cairo_mutex_initialized)	\
            _cairo_mutex_initialize ();	\
-   } while(0)
+    } while(0)
 
-   /* and make sure we implement the above */
+/* and make sure we implement the above */
 #  define _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER 1
 # endif /* CAIRO_MUTEX_IMPL_INITIALIZE */
 
@@ -105,9 +105,9 @@
 #  define CAIRO_MUTEX_IMPL_FINALIZE() do {	\
        if (_cairo_mutex_initialized)	\
            _cairo_mutex_finalize ();	\
-   } while(0)
+    } while(0)
 
-   /* and make sure we implement the above */
+/* and make sure we implement the above */
 #  define _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER 1
 # endif /* CAIRO_MUTEX_IMPL_FINALIZE */
 
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index e5e691b..93e82bc 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -2202,7 +2202,7 @@ _cairo_svg_surface_show_glyphs (void			*abstract_surface,
     return CAIRO_STATUS_SUCCESS;
 
 FALLBACK:
-   _cairo_path_fixed_init (&path);
+    _cairo_path_fixed_init (&path);
 
     status = _cairo_scaled_font_glyph_path (scaled_font,(cairo_glyph_t *) glyphs, num_glyphs, &path);
 
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index 45c158b..1b75790 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -130,8 +130,8 @@ typedef enum _cairo_paginated_mode {
 } cairo_paginated_mode_t;
 
 /* Sure wish C had a real enum type so that this would be distinct
-   from cairo_status_t. Oh well, without that, I'll use this bogus 1000
-   offset */
+ * from cairo_status_t. Oh well, without that, I'll use this bogus 1000
+ * offset */
 typedef enum _cairo_int_status {
     CAIRO_INT_STATUS_DEGENERATE = 1000,
     CAIRO_INT_STATUS_UNSUPPORTED,
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 766102c..b106952 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2727,10 +2727,10 @@ cairo_xlib_surface_get_height (cairo_surface_t *abstract_surface)
 }
 
 enum {
-  GLYPHSET_INDEX_ARGB32,
-  GLYPHSET_INDEX_A8,
-  GLYPHSET_INDEX_A1,
-  NUM_GLYPHSETS
+    GLYPHSET_INDEX_ARGB32,
+    GLYPHSET_INDEX_A8,
+    GLYPHSET_INDEX_A1,
+    NUM_GLYPHSETS
 };
 
 typedef struct _cairo_xlib_font_glyphset_free_glyphs {
@@ -2870,14 +2870,14 @@ _cairo_xlib_render_free_glyphs (Display *dpy,
 static cairo_xlib_font_glyphset_info_t *
 _cairo_xlib_scaled_glyph_get_glyphset_info (cairo_scaled_glyph_t            *scaled_glyph)
 {
-  return scaled_glyph->surface_private;
+    return scaled_glyph->surface_private;
 }
 
 static void
 _cairo_xlib_scaled_glyph_set_glyphset_info (cairo_scaled_glyph_t            *scaled_glyph,
 					    cairo_xlib_font_glyphset_info_t *glyphset_info)
 {
-  scaled_glyph->surface_private = glyphset_info;
+    scaled_glyph->surface_private = glyphset_info;
 }
 
 static void
@@ -3208,13 +3208,13 @@ typedef void (*cairo_xrender_composite_text_func_t)
  * an input glyph with double coordinates, and as "working" glyph with
  * integer from-current-point offsets. */
 typedef union {
-  cairo_glyph_t d;
-  unsigned long index;
-  struct {
+    cairo_glyph_t d;
     unsigned long index;
-    int x;
-    int y;
-  } i;
+    struct {
+        unsigned long index;
+        int x;
+        int y;
+    } i;
 } cairo_xlib_glyph_t;
 
 /* compile-time assert that #cairo_xlib_glyph_t is the same size as #cairo_glyph_t */
diff --git a/src/cairo.h b/src/cairo.h
index 179c45f..3e21e27 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -817,9 +817,9 @@ typedef struct _cairo_font_face cairo_font_face_t;
  * with respect to the overall origin
  **/
 typedef struct {
-  unsigned long        index;
-  double               x;
-  double               y;
+    unsigned long        index;
+    double               x;
+    double               y;
 } cairo_glyph_t;
 
 /**
@@ -916,9 +916,9 @@ typedef struct {
  * Specifies variants of a font face based on their slant.
  **/
 typedef enum _cairo_font_slant {
-  CAIRO_FONT_SLANT_NORMAL,
-  CAIRO_FONT_SLANT_ITALIC,
-  CAIRO_FONT_SLANT_OBLIQUE
+    CAIRO_FONT_SLANT_NORMAL,
+    CAIRO_FONT_SLANT_ITALIC,
+    CAIRO_FONT_SLANT_OBLIQUE
 } cairo_font_slant_t;
 
 /**
@@ -929,8 +929,8 @@ typedef enum _cairo_font_slant {
  * Specifies variants of a font face based on their weight.
  **/
 typedef enum _cairo_font_weight {
-  CAIRO_FONT_WEIGHT_NORMAL,
-  CAIRO_FONT_WEIGHT_BOLD
+    CAIRO_FONT_WEIGHT_NORMAL,
+    CAIRO_FONT_WEIGHT_BOLD
 } cairo_font_weight_t;
 
 /**
commit 78b9e2917857714bc1a712ea9d1a18af77000f78
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed May 28 17:04:09 2008 -0400

    [cairo-xlib] Rewrite cairo_xlib_glyph_t as a union of cairo_glyph_t
    
    Someone reported on cairo list that on some system with gcc, he had the
    compile-time assertion failing, meaning that the following struct:
    
    typedef struct {
      unsigned long index;
      union {
        struct {
          double x;
          double y;
        } d;
        struct {
          int x;
          int y;
        } i;
      } p;
    } cairo_xlib_glyph_t;
    
    had a different size from:
    
    typedef struct {
      unsigned long        index;
      double               x;
      double               y;
    } cairo_glyph_t;
    
    That looks quite a weird thing for a compiler to do.  Anyway, rewriting
    our struct like this may help in those weird situations:
    
    typedef union {
      cairo_glyph_t d;
      unsigned long index;
      struct {
        unsigned long index;
        int x;
        int y;
      } i;
    } cairo_xlib_glyph_t;
    
    That's what we do now.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 42d6ac2..766102c 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3207,18 +3207,14 @@ typedef void (*cairo_xrender_composite_text_func_t)
 /* Build a struct of the same size of #cairo_glyph_t that can be used both as
  * an input glyph with double coordinates, and as "working" glyph with
  * integer from-current-point offsets. */
-typedef struct {
+typedef union {
+  cairo_glyph_t d;
   unsigned long index;
-  union {
-    struct {
-      double x;
-      double y;
-    } d;
-    struct {
-      int x;
-      int y;
-    } i;
-  } p;
+  struct {
+    unsigned long index;
+    int x;
+    int y;
+  } i;
 } cairo_xlib_glyph_t;
 
 /* compile-time assert that #cairo_xlib_glyph_t is the same size as #cairo_glyph_t */
@@ -3288,7 +3284,7 @@ _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst,
 
       /* Start a new element for first output glyph, and for glyphs with
        * unexpected position */
-      if (!j || glyphs[i].p.i.x || glyphs[i].p.i.y) {
+      if (!j || glyphs[i].i.x || glyphs[i].i.y) {
 	  if (j) {
 	    elts[nelt].nchars = n;
 	    nelt++;
@@ -3296,8 +3292,8 @@ _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst,
 	  }
 	  elts[nelt].chars = char8 + size * j;
 	  elts[nelt].glyphset = glyphset_info->glyphset;
-	  elts[nelt].xOff = glyphs[i].p.i.x;
-	  elts[nelt].yOff = glyphs[i].p.i.y;
+	  elts[nelt].xOff = glyphs[i].i.x;
+	  elts[nelt].yOff = glyphs[i].i.y;
       }
 
       switch (width) {
@@ -3374,8 +3370,8 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 	if (status != CAIRO_STATUS_SUCCESS)
 	    return status;
 
-	this_x = _cairo_lround (glyphs[i].p.d.x);
-	this_y = _cairo_lround (glyphs[i].p.d.y);
+	this_x = _cairo_lround (glyphs[i].d.x);
+	this_y = _cairo_lround (glyphs[i].d.y);
 
 	/* Glyph skipping:
 	 *
@@ -3464,12 +3460,12 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 
 	/* Convert absolute glyph position to relative-to-current-point
 	 * position */
-	glyphs[i].p.i.x = this_x - x;
-	glyphs[i].p.i.y = this_y - y;
+	glyphs[i].i.x = this_x - x;
+	glyphs[i].i.y = this_y - y;
 
 	/* Start a new element for the first glyph, or for any glyph that
 	 * has unexpected position */
-	if (!num_out_glyphs || glyphs[i].p.i.x || glyphs[i].p.i.y) {
+	if (!num_out_glyphs || glyphs[i].i.x || glyphs[i].i.y) {
 	    num_elts++;
 	    request_size += sz_xGlyphElt;
 	}


More information about the cairo-commit mailing list