[cairo-commit] 5 commits - doc/public src/cairo-atsui-font.c src/cairo-quartz-surface.c

Brian Ewins brianewins at kemper.freedesktop.org
Tue Jun 12 17:32:56 PDT 2007


 doc/public/tmpl/cairo-atsui.sgml |    2 
 src/cairo-atsui-font.c           |   13 +++++
 src/cairo-quartz-surface.c       |   98 ++++++++++-----------------------------
 3 files changed, 41 insertions(+), 72 deletions(-)

New commits:
diff-tree 817d4b0c9a354526389290c6d5a7662713d67cd8 (from fd1edaa5d386f15edacfd5596b550593ed45d627)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Sat Jun 9 19:14:05 2007 +0100

    [atsui] Document ATSUI
    
    Add cairo_atsui_font_face_create_for_atsu_font_id
    and ATSUI to the documentation. Don't enable it yet,
    since this is still unsupported.

diff --git a/doc/public/tmpl/cairo-atsui.sgml b/doc/public/tmpl/cairo-atsui.sgml
index 4a8b35a..fb91793 100644
--- a/doc/public/tmpl/cairo-atsui.sgml
+++ b/doc/public/tmpl/cairo-atsui.sgml
@@ -2,7 +2,7 @@
 ATSUI Fonts
 
 <!-- ##### SECTION Short_Description ##### -->
-
+Font support for ATSUI on OS X
 
 <!-- ##### SECTION Long_Description ##### -->
 <para>
diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index 34560d2..361e787 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -129,6 +129,19 @@ static const cairo_font_face_backend_t _
     _cairo_atsui_font_face_scaled_font_create
 };
 
+/**
+ * cairo_atsui_font_face_create_for_atsu_font_id
+ * @font_id: an ATSUFontID for the font.
+ *
+ * Creates a new font for the ATSUI font backend based on an
+ * #ATSUFontID. This font can then be used with
+ * cairo_set_font_face() or cairo_scaled_font_create().
+ *
+ * Return value: a newly created #cairo_font_face_t. Free with
+ *  cairo_font_face_destroy() when you are done using it.
+ *
+ * Since: 1.4
+ **/
 cairo_font_face_t *
 cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id)
 {
diff-tree fd1edaa5d386f15edacfd5596b550593ed45d627 (from d7a0816ec3d750939dd935f34b217980ee27af3f)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Wed Jun 13 01:27:36 2007 +0100

    [quartz] remove unused code
    
    clean up warnings about unused code: removing 
    _cairo_quartz_cairo_path_to_quartz_path and the functions
    it calls.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 3cb2520..06c8ba8 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -106,40 +106,6 @@ typedef struct _quartz_stroke {
     cairo_matrix_t *ctm_inverse;
 } quartz_stroke_t;
 
-/* cairo path -> mutable path */
-static cairo_status_t
-_cairo_path_to_quartz_path_move_to (void *closure, cairo_point_t *point)
-{
-    CGPathMoveToPoint ((CGMutablePathRef) closure, NULL,
-		       _cairo_fixed_to_double(point->x), _cairo_fixed_to_double(point->y));
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_path_to_quartz_path_line_to (void *closure, cairo_point_t *point)
-{
-    CGPathAddLineToPoint ((CGMutablePathRef) closure, NULL,
-			  _cairo_fixed_to_double(point->x), _cairo_fixed_to_double(point->y));
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_path_to_quartz_path_curve_to (void *closure, cairo_point_t *p0, cairo_point_t *p1, cairo_point_t *p2)
-{
-    CGPathAddCurveToPoint ((CGMutablePathRef) closure, NULL,
-			   _cairo_fixed_to_double(p0->x), _cairo_fixed_to_double(p0->y),
-			   _cairo_fixed_to_double(p1->x), _cairo_fixed_to_double(p1->y),
-			   _cairo_fixed_to_double(p2->x), _cairo_fixed_to_double(p2->y));
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_cairo_path_to_quartz_path_close_path (void *closure)
-{
-    CGPathCloseSubpath ((CGMutablePathRef) closure);
-    return CAIRO_STATUS_SUCCESS;
-}
-
 /* cairo path -> execute in context */
 static cairo_status_t
 _cairo_path_to_quartz_context_move_to (void *closure, cairo_point_t *point)
@@ -210,19 +176,6 @@ _cairo_path_to_quartz_context_close_path
 }
 
 static cairo_status_t
-_cairo_quartz_cairo_path_to_quartz_path (cairo_path_fixed_t *path,
-					  CGMutablePathRef cgPath)
-{
-    return _cairo_path_fixed_interpret (path,
-					CAIRO_DIRECTION_FORWARD,
-					_cairo_path_to_quartz_path_move_to,
-					_cairo_path_to_quartz_path_line_to,
-					_cairo_path_to_quartz_path_curve_to,
-					_cairo_path_to_quartz_path_close_path,
-					cgPath);
-}
-
-static cairo_status_t
 _cairo_quartz_cairo_path_to_quartz_context (cairo_path_fixed_t *path,
 					    quartz_stroke_t *stroke)
 {
diff-tree d7a0816ec3d750939dd935f34b217980ee27af3f (from bf39b28b77a83160e5aa037031d82f8c0843f387)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Wed Jun 13 01:27:36 2007 +0100

    [quartz] move glyph array declarations
    
    Move declarations causing a warning. A separate patch from
    the other warning cleanups because it moves where the allocation
    happens.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index f935f72..3cb2520 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1370,10 +1370,17 @@ _cairo_quartz_surface_show_glyphs (void 
     ATSFontRef atsfref;
     CGFontRef cgfref;
     CGAffineTransform cairoTextTransform, textTransform, ctm;
+    // XXXtodo/perf: stack storage for glyphs/sizes
+#define STATIC_BUF_SIZE 64
+    CGGlyph glyphs_static[STATIC_BUF_SIZE];
+    CGSize cg_advances_static[STATIC_BUF_SIZE];
+    CGGlyph *cg_glyphs = &glyphs_static[0];
+    CGSize *cg_advances = &cg_advances_static[0];
 
     cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
     cairo_int_status_t rv = CAIRO_STATUS_SUCCESS;
     cairo_quartz_action_t action;
+    float xprev, yprev;
     int i;
 
     if (num_glyphs <= 0)
@@ -1433,29 +1440,22 @@ _cairo_quartz_surface_show_glyphs (void 
     CGContextSetTextMatrix (surface->cgContext, textTransform);
     CGContextSetFontSize (surface->cgContext, 1.0);
 
-    // XXXtodo/perf: stack storage for glyphs/sizes
-#define STATIC_BUF_SIZE 64
-    CGGlyph glyphs_static[STATIC_BUF_SIZE];
-    CGSize cg_advances_static[STATIC_BUF_SIZE];
-    CGGlyph *cg_glyphs = &glyphs_static[0];
-    CGSize *cg_advances = &cg_advances_static[0];
-
     if (num_glyphs > STATIC_BUF_SIZE) {
 	cg_glyphs = (CGGlyph*) malloc(sizeof(CGGlyph) * num_glyphs);
 	cg_advances = (CGSize*) malloc(sizeof(CGSize) * num_glyphs);
     }
 
-    float xprev = glyphs[0].x;
-    float yprev = glyphs[0].y;
+    xprev = glyphs[0].x;
+    yprev = glyphs[0].y;
 
     cg_glyphs[0] = glyphs[0].index;
     cg_advances[0].width = 0;
     cg_advances[0].height = 0;
 
     for (i = 1; i < num_glyphs; i++) {
-	cg_glyphs[i] = glyphs[i].index;
 	float xf = glyphs[i].x;
 	float yf = glyphs[i].y;
+	cg_glyphs[i] = glyphs[i].index;
 	cg_advances[i-1].width = xf - xprev;
 	cg_advances[i-1].height = yf - yprev;
 	xprev = xf;
diff-tree bf39b28b77a83160e5aa037031d82f8c0843f387 (from 2034d1dbd5888c393c57f0feeb707b0411fa4480)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Wed Jun 13 01:04:54 2007 +0100

    commit 75be87b4093aaa7f477d587d5a68308cade1b29c
    
        [quartz] move glyph array declarations
    
        Move declarations causing a warning. A separate patch from
        the other warning cleanups because it moves where the allocation
        happens.
    

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 58276d9..f935f72 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -482,10 +482,10 @@ _cairo_quartz_surface_to_quartz (cairo_s
 	 */
 
 	cairo_surface_t *ref_type = target;
-	if (ref_type == NULL)
-	    ref_type = cairo_quartz_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
 	cairo_surface_t *new_surf = NULL;
 	cairo_rectangle_int16_t rect;
+	if (ref_type == NULL)
+	    ref_type = cairo_quartz_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
 
 	_cairo_surface_get_extents (pat_surf, &rect);
 
@@ -517,6 +517,7 @@ SurfacePatternDrawFunc (void *info, CGCo
 
     cairo_quartz_surface_t *quartz_surf = _cairo_quartz_surface_to_quartz (NULL, pat_surf);
     CGImageRef img = CGBitmapContextCreateImage (quartz_surf->cgContext);
+    CGRect imageBounds;
 
     if (!img) {
 	// ... give up.
@@ -535,7 +536,6 @@ SurfacePatternDrawFunc (void *info, CGCo
 	CGContextScaleCTM (context, 1, -1);
     }
 
-    CGRect imageBounds;
     imageBounds.size = CGSizeMake (CGImageGetWidth(img), CGImageGetHeight(img));
     imageBounds.origin.x = 0;
     imageBounds.origin.y = 0;
@@ -719,7 +719,7 @@ _cairo_quartz_setup_source (cairo_quartz
     {
 	    cairo_surface_pattern_t *spat = (cairo_surface_pattern_t *) source;
 	    cairo_surface_t *pat_surf = spat->surface;
-	    cairo_quartz_surface_t *quartz_surf = _cairo_quartz_surface_to_quartz (surface, pat_surf);
+	    cairo_quartz_surface_t *quartz_surf = _cairo_quartz_surface_to_quartz ((cairo_surface_t *) surface, pat_surf);
 	    CGImageRef img = CGBitmapContextCreateImage (quartz_surf->cgContext);
 	    cairo_matrix_t m = spat->base.matrix;
 	    cairo_rectangle_int16_t extents;
@@ -739,18 +739,18 @@ _cairo_quartz_setup_source (cairo_quartz
 
 	    return DO_IMAGE;
     } else if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
+	float patternAlpha = 1.0f;
+	CGColorSpaceRef patternSpace;
+
 	CGPatternRef pattern = _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (surface, source);
 	if (!pattern)
 	    return DO_UNSUPPORTED;
 
-	float patternAlpha = 1.0f;
-
 	// Save before we change the pattern, colorspace, etc. so that
 	// we can restore and make sure that quartz releases our
 	// pattern (which may be stack allocated)
 	CGContextSaveGState(surface->cgContext);
 
-	CGColorSpaceRef patternSpace;
 	patternSpace = CGColorSpaceCreatePattern(NULL);
 	CGContextSetFillColorSpace (surface->cgContext, patternSpace);
 	CGContextSetFillPattern (surface->cgContext, pattern, &patternAlpha);
@@ -1041,7 +1041,6 @@ _cairo_quartz_surface_clone_similar (voi
 				      int              height,
 				      cairo_surface_t **clone_out)
 {
-    cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
     cairo_quartz_surface_t *new_surface = NULL;
     cairo_format_t new_format;
 
@@ -1367,6 +1366,11 @@ _cairo_quartz_surface_show_glyphs (void 
 				    int num_glyphs,
 				    cairo_scaled_font_t *scaled_font)
 {
+    ATSUFontID fid;
+    ATSFontRef atsfref;
+    CGFontRef cgfref;
+    CGAffineTransform cairoTextTransform, textTransform, ctm;
+
     cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
     cairo_int_status_t rv = CAIRO_STATUS_SUCCESS;
     cairo_quartz_action_t action;
@@ -1396,9 +1400,9 @@ _cairo_quartz_surface_show_glyphs (void 
 
     CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz (op));
 
-    ATSUFontID fid = _cairo_atsui_scaled_font_get_atsu_font_id (scaled_font);
-    ATSFontRef atsfref = FMGetATSFontRefFromFont (fid);
-    CGFontRef cgfref = CGFontCreateWithPlatformFont (&atsfref);
+    fid = _cairo_atsui_scaled_font_get_atsu_font_id (scaled_font);
+    atsfref = FMGetATSFontRefFromFont (fid);
+    cgfref = CGFontCreateWithPlatformFont (&atsfref);
 
     CGContextSetFont (surface->cgContext, cgfref);
     CGFontRelease (cgfref);
@@ -1409,7 +1413,6 @@ _cairo_quartz_surface_show_glyphs (void 
      * text matrix?
      */
     //ND((stderr, "show_glyphs: glyph 0 at: %f, %f\n", glyphs[0].x, glyphs[0].y));
-    CGAffineTransform cairoTextTransform, textTransform, ctm;
     cairoTextTransform = CGAffineTransformMake (scaled_font->font_matrix.xx, 
 						scaled_font->font_matrix.yx,
 						scaled_font->font_matrix.xy, 
diff-tree 2034d1dbd5888c393c57f0feeb707b0411fa4480 (from 54bbe44b08b37041c8982634837dbc79b19e6c18)
Author: Brian Ewins <Brian.Ewins at gmail.com>
Date:   Wed Jun 13 01:27:36 2007 +0100

    [quartz] pass quartz_stroke_t not CGContextRef
    
    Fix a typo where an incompatible pointer was being passed.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index dc831c1..58276d9 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -224,7 +224,7 @@ _cairo_quartz_cairo_path_to_quartz_path 
 
 static cairo_status_t
 _cairo_quartz_cairo_path_to_quartz_context (cairo_path_fixed_t *path,
-					     CGContextRef cgc)
+					    quartz_stroke_t *stroke)
 {
     return _cairo_path_fixed_interpret (path,
 					CAIRO_DIRECTION_FORWARD,
@@ -232,7 +232,7 @@ _cairo_quartz_cairo_path_to_quartz_conte
 					_cairo_path_to_quartz_context_line_to,
 					_cairo_path_to_quartz_context_curve_to,
 					_cairo_path_to_quartz_context_close_path,
-					cgc);
+					stroke);
 }
 
 /*


More information about the cairo-commit mailing list