Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: cairo-1.17.8-new/src/cairo-default-context.c
===================================================================
--- cairo-1.17.8-new/src/cairo-default-context.c	(nonexistent)
+++ cairo-1.17.8-new/src/cairo-default-context.c	(revision 5)
@@ -0,0 +1,1517 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2002 University of Southern California
+ * Copyright © 2005 Red Hat, Inc.
+ * Copyright © 2011 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Carl D. Worth <cworth@cworth.org>
+ *	Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+#include "cairoint.h"
+
+#include "cairo-private.h"
+#include "cairo-arc-private.h"
+#include "cairo-backend-private.h"
+#include "cairo-clip-inline.h"
+#include "cairo-default-context-private.h"
+#include "cairo-error-private.h"
+#include "cairo-freed-pool-private.h"
+#include "cairo-path-private.h"
+#include "cairo-pattern-private.h"
+
+#define CAIRO_TOLERANCE_MINIMUM	_cairo_fixed_to_double(1)
+
+#if !defined(INFINITY)
+#define INFINITY HUGE_VAL
+#endif
+
+static freed_pool_t context_pool;
+
+void
+_cairo_default_context_reset_static_data (void)
+{
+    _freed_pool_reset (&context_pool);
+}
+
+void
+_cairo_default_context_fini (cairo_default_context_t *cr)
+{
+    while (cr->gstate != &cr->gstate_tail[0]) {
+	if (_cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist))
+	    break;
+    }
+
+    _cairo_gstate_fini (cr->gstate);
+    cr->gstate_freelist = cr->gstate_freelist->next; /* skip over tail[1] */
+    while (cr->gstate_freelist != NULL) {
+	cairo_gstate_t *gstate = cr->gstate_freelist;
+	cr->gstate_freelist = gstate->next;
+	free (gstate);
+    }
+
+    _cairo_path_fixed_fini (cr->path);
+
+    _cairo_fini (&cr->base);
+}
+
+static void
+_cairo_default_context_destroy (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_default_context_fini (cr);
+
+    /* mark the context as invalid to protect against misuse */
+    cr->base.status = CAIRO_STATUS_NULL_POINTER;
+    _freed_pool_put (&context_pool, cr);
+}
+
+static cairo_surface_t *
+_cairo_default_context_get_original_target (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_original_target (cr->gstate);
+}
+
+static cairo_surface_t *
+_cairo_default_context_get_current_target (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_target (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_save (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_save (&cr->gstate, &cr->gstate_freelist);
+}
+
+static cairo_status_t
+_cairo_default_context_restore (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    if (unlikely (_cairo_gstate_is_group (cr->gstate)))
+	return _cairo_error (CAIRO_STATUS_INVALID_RESTORE);
+
+    return _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist);
+}
+
+static cairo_status_t
+_cairo_default_context_push_group (void *abstract_cr, cairo_content_t content)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_surface_t *group_surface;
+    cairo_clip_t *clip;
+    cairo_status_t status;
+
+    clip = _cairo_gstate_get_clip (cr->gstate);
+    if (_cairo_clip_is_all_clipped (clip)) {
+	group_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
+	status = group_surface->status;
+	if (unlikely (status))
+	    goto bail;
+    } else {
+	cairo_surface_t *parent_surface;
+	cairo_rectangle_int_t extents;
+	cairo_bool_t bounded, is_empty;
+
+	parent_surface = _cairo_gstate_get_target (cr->gstate);
+
+	if (unlikely (parent_surface->status))
+	    return parent_surface->status;
+	if (unlikely (parent_surface->finished))
+	    return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
+
+	/* Get the extents that we'll use in creating our new group surface */
+	bounded = _cairo_surface_get_extents (parent_surface, &extents);
+	if (clip)
+	    /* XXX: This assignment just fixes a compiler warning? */
+	    is_empty = _cairo_rectangle_intersect (&extents,
+						   _cairo_clip_get_extents (clip));
+
+	if (!bounded) {
+	    /* XXX: Generic solution? */
+	    group_surface = cairo_recording_surface_create (content, NULL);
+	    extents.x = extents.y = 0;
+	} else {
+	    group_surface = _cairo_surface_create_scratch (parent_surface,
+							   content,
+							   extents.width,
+							   extents.height,
+							   CAIRO_COLOR_TRANSPARENT);
+	}
+	status = group_surface->status;
+	if (unlikely (status))
+	    goto bail;
+
+	/* Set device offsets on the new surface so that logically it appears at
+	 * the same location on the parent surface -- when we pop_group this,
+	 * the source pattern will get fixed up for the appropriate target surface
+	 * device offsets, so we want to set our own surface offsets from /that/,
+	 * and not from the device origin. */
+	cairo_surface_set_device_offset (group_surface,
+					 parent_surface->device_transform.x0 - extents.x,
+					 parent_surface->device_transform.y0 - extents.y);
+
+	cairo_surface_set_device_scale (group_surface,
+					parent_surface->device_transform.xx,
+					parent_surface->device_transform.yy);
+
+	/* If we have a current path, we need to adjust it to compensate for
+	 * the device offset just applied. */
+	_cairo_path_fixed_translate (cr->path,
+				     _cairo_fixed_from_int (-extents.x),
+				     _cairo_fixed_from_int (-extents.y));
+    }
+
+    /* create a new gstate for the redirect */
+    status = _cairo_gstate_save (&cr->gstate, &cr->gstate_freelist);
+    if (unlikely (status))
+	goto bail;
+
+    status = _cairo_gstate_redirect_target (cr->gstate, group_surface);
+
+bail:
+    cairo_surface_destroy (group_surface);
+    return status;
+}
+
+static cairo_pattern_t *
+_cairo_default_context_pop_group (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_surface_t *group_surface;
+    cairo_pattern_t *group_pattern;
+    cairo_surface_t *parent_surface;
+    cairo_matrix_t group_matrix;
+    cairo_status_t status;
+
+    /* Verify that we are at the right nesting level */
+    if (unlikely (! _cairo_gstate_is_group (cr->gstate)))
+	return _cairo_pattern_create_in_error (CAIRO_STATUS_INVALID_POP_GROUP);
+
+    /* Get a reference to the active surface before restoring */
+    group_surface = _cairo_gstate_get_target (cr->gstate);
+    group_surface = cairo_surface_reference (group_surface);
+
+    status = _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist);
+    assert (status == CAIRO_STATUS_SUCCESS);
+
+    parent_surface = _cairo_gstate_get_target (cr->gstate);
+
+    group_pattern = cairo_pattern_create_for_surface (group_surface);
+    status = group_pattern->status;
+    if (unlikely (status))
+        goto done;
+
+    _cairo_gstate_get_matrix (cr->gstate, &group_matrix);
+    cairo_pattern_set_matrix (group_pattern, &group_matrix);
+
+    /* If we have a current path, we need to adjust it to compensate for
+     * the device offset just removed. */
+    _cairo_path_fixed_translate (cr->path,
+				 _cairo_fixed_from_int (parent_surface->device_transform.x0 - group_surface->device_transform.x0),
+				 _cairo_fixed_from_int (parent_surface->device_transform.y0 - group_surface->device_transform.y0));
+
+done:
+    cairo_surface_destroy (group_surface);
+
+    return group_pattern;
+}
+
+static cairo_status_t
+_cairo_default_context_set_source (void *abstract_cr,
+				   cairo_pattern_t *source)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_source (cr->gstate, source);
+}
+
+static cairo_bool_t
+_current_source_matches_solid (const cairo_pattern_t *pattern,
+			       double red,
+			       double green,
+			       double blue,
+			       double alpha)
+{
+    cairo_color_t color;
+
+    if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
+	return FALSE;
+
+    red   = _cairo_restrict_value (red,   0.0, 1.0);
+    green = _cairo_restrict_value (green, 0.0, 1.0);
+    blue  = _cairo_restrict_value (blue,  0.0, 1.0);
+    alpha = _cairo_restrict_value (alpha, 0.0, 1.0);
+
+    _cairo_color_init_rgba (&color, red, green, blue, alpha);
+    return _cairo_color_equal (&color,
+			       &((cairo_solid_pattern_t *) pattern)->color);
+}
+
+static cairo_status_t
+_cairo_default_context_set_source_rgba (void *abstract_cr, double red, double green, double blue, double alpha)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_pattern_t *pattern;
+    cairo_status_t status;
+
+    if (_current_source_matches_solid (cr->gstate->source,
+				       red, green, blue, alpha))
+	return CAIRO_STATUS_SUCCESS;
+
+    /* push the current pattern to the freed lists */
+    _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black);
+
+    pattern = cairo_pattern_create_rgba (red, green, blue, alpha);
+    if (unlikely (pattern->status))
+	return pattern->status;
+
+    status = _cairo_default_context_set_source (cr, pattern);
+    cairo_pattern_destroy (pattern);
+
+    return status;
+}
+
+static cairo_status_t
+_cairo_default_context_set_source_surface (void *abstract_cr,
+					   cairo_surface_t *surface,
+					   double	   x,
+					   double	   y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_pattern_t *pattern;
+    cairo_matrix_t matrix;
+    cairo_status_t status;
+
+    /* push the current pattern to the freed lists */
+    _cairo_default_context_set_source (cr, (cairo_pattern_t *) &_cairo_pattern_black);
+
+    pattern = cairo_pattern_create_for_surface (surface);
+    if (unlikely (pattern->status)) {
+        status = pattern->status;
+        cairo_pattern_destroy (pattern);
+        return status;
+    }
+
+    cairo_matrix_init_translate (&matrix, -x, -y);
+    cairo_pattern_set_matrix (pattern, &matrix);
+
+    status = _cairo_default_context_set_source (cr, pattern);
+    cairo_pattern_destroy (pattern);
+
+    return status;
+}
+
+static cairo_pattern_t *
+_cairo_default_context_get_source (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_source (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_set_tolerance (void *abstract_cr,
+				      double tolerance)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    if (tolerance < CAIRO_TOLERANCE_MINIMUM)
+	tolerance = CAIRO_TOLERANCE_MINIMUM;
+
+    return _cairo_gstate_set_tolerance (cr->gstate, tolerance);
+}
+
+static cairo_status_t
+_cairo_default_context_set_operator (void *abstract_cr, cairo_operator_t op)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_operator (cr->gstate, op);
+}
+
+static cairo_status_t
+_cairo_default_context_set_opacity (void *abstract_cr, double opacity)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_opacity (cr->gstate, opacity);
+}
+
+static cairo_status_t
+_cairo_default_context_set_antialias (void *abstract_cr,
+				      cairo_antialias_t antialias)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_antialias (cr->gstate, antialias);
+}
+
+static cairo_status_t
+_cairo_default_context_set_fill_rule (void *abstract_cr,
+				      cairo_fill_rule_t fill_rule)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_fill_rule (cr->gstate, fill_rule);
+}
+
+static cairo_status_t
+_cairo_default_context_set_line_width (void *abstract_cr,
+				       double line_width)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_line_width (cr->gstate, line_width);
+}
+
+static cairo_status_t
+_cairo_default_context_set_hairline (void *abstract_cr, cairo_bool_t set_hairline)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_hairline (cr->gstate, set_hairline);
+}
+
+static cairo_status_t
+_cairo_default_context_set_line_cap (void *abstract_cr,
+				     cairo_line_cap_t line_cap)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_line_cap (cr->gstate, line_cap);
+}
+
+static cairo_status_t
+_cairo_default_context_set_line_join (void *abstract_cr,
+				      cairo_line_join_t line_join)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_line_join (cr->gstate, line_join);
+}
+
+static cairo_status_t
+_cairo_default_context_set_dash (void *abstract_cr,
+				 const double *dashes,
+				 int	      num_dashes,
+				 double	      offset)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_dash (cr->gstate,
+				   dashes, num_dashes, offset);
+}
+
+static cairo_status_t
+_cairo_default_context_set_miter_limit (void *abstract_cr,
+					double limit)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_miter_limit (cr->gstate, limit);
+}
+
+static cairo_antialias_t
+_cairo_default_context_get_antialias (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_antialias (cr->gstate);
+}
+
+static void
+_cairo_default_context_get_dash (void *abstract_cr,
+				 double *dashes,
+				 int *num_dashes,
+				 double *offset)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_get_dash (cr->gstate, dashes, num_dashes, offset);
+}
+
+static cairo_fill_rule_t
+_cairo_default_context_get_fill_rule (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_fill_rule (cr->gstate);
+}
+
+static double
+_cairo_default_context_get_line_width (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_line_width (cr->gstate);
+}
+
+static cairo_bool_t
+_cairo_default_context_get_hairline (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_hairline (cr->gstate);
+}
+
+static cairo_line_cap_t
+_cairo_default_context_get_line_cap (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_line_cap (cr->gstate);
+}
+
+static cairo_line_join_t
+_cairo_default_context_get_line_join (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_line_join (cr->gstate);
+}
+
+static double
+_cairo_default_context_get_miter_limit (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_miter_limit (cr->gstate);
+}
+
+static cairo_operator_t
+_cairo_default_context_get_operator (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_operator (cr->gstate);
+}
+
+static double
+_cairo_default_context_get_opacity (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_opacity (cr->gstate);
+}
+
+static double
+_cairo_default_context_get_tolerance (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_tolerance (cr->gstate);
+}
+
+
+/* Current transformation matrix */
+
+static cairo_status_t
+_cairo_default_context_translate (void *abstract_cr,
+				  double tx,
+				  double ty)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_translate (cr->gstate, tx, ty);
+}
+
+static cairo_status_t
+_cairo_default_context_scale (void *abstract_cr,
+			      double sx,
+			      double sy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_scale (cr->gstate, sx, sy);
+}
+
+static cairo_status_t
+_cairo_default_context_rotate (void *abstract_cr,
+			       double theta)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_rotate (cr->gstate, theta);
+}
+
+static cairo_status_t
+_cairo_default_context_transform (void *abstract_cr,
+				  const cairo_matrix_t *matrix)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_transform (cr->gstate, matrix);
+}
+
+static cairo_status_t
+_cairo_default_context_set_matrix (void *abstract_cr,
+				   const cairo_matrix_t *matrix)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_matrix (cr->gstate, matrix);
+}
+
+static cairo_status_t
+_cairo_default_context_set_identity_matrix (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_identity_matrix (cr->gstate);
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static void
+_cairo_default_context_get_matrix (void *abstract_cr,
+				   cairo_matrix_t *matrix)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_get_matrix (cr->gstate, matrix);
+}
+
+static void
+_cairo_default_context_user_to_device (void *abstract_cr,
+				       double *x,
+				       double *y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_user_to_device (cr->gstate, x, y);
+}
+
+static void
+_cairo_default_context_user_to_device_distance (void *abstract_cr, double *dx, double *dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy);
+}
+
+static void
+_cairo_default_context_device_to_user (void *abstract_cr,
+				       double *x,
+				       double *y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_device_to_user (cr->gstate, x, y);
+}
+
+static void
+_cairo_default_context_device_to_user_distance (void *abstract_cr,
+						double *dx,
+						double *dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy);
+}
+
+static void
+_cairo_default_context_backend_to_user (void *abstract_cr,
+					double *x,
+					double *y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_backend_to_user (cr->gstate, x, y);
+}
+
+static void
+_cairo_default_context_backend_to_user_distance (void *abstract_cr, double *dx, double *dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_backend_to_user_distance (cr->gstate, dx, dy);
+}
+
+static void
+_cairo_default_context_user_to_backend (void *abstract_cr,
+					double *x,
+					double *y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_user_to_backend (cr->gstate, x, y);
+}
+
+static void
+_cairo_default_context_user_to_backend_distance (void *abstract_cr,
+						 double *dx,
+						 double *dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_user_to_backend_distance (cr->gstate, dx, dy);
+}
+
+/* Path constructor */
+
+static cairo_status_t
+_cairo_default_context_new_path (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_path_fixed_fini (cr->path);
+    _cairo_path_fixed_init (cr->path);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_default_context_new_sub_path (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_path_fixed_new_sub_path (cr->path);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_default_context_move_to (void *abstract_cr, double x, double y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t x_fixed, y_fixed;
+
+    _cairo_gstate_user_to_backend (cr->gstate, &x, &y);
+    x_fixed = _cairo_fixed_from_double (x);
+    y_fixed = _cairo_fixed_from_double (y);
+
+    return _cairo_path_fixed_move_to (cr->path, x_fixed, y_fixed);
+}
+
+static cairo_status_t
+_cairo_default_context_line_to (void *abstract_cr, double x, double y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t x_fixed, y_fixed;
+
+    _cairo_gstate_user_to_backend (cr->gstate, &x, &y);
+    x_fixed = _cairo_fixed_from_double (x);
+    y_fixed = _cairo_fixed_from_double (y);
+
+    return _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed);
+}
+
+static cairo_status_t
+_cairo_default_context_curve_to (void *abstract_cr,
+				 double x1, double y1,
+				 double x2, double y2,
+				 double x3, double y3)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t x1_fixed, y1_fixed;
+    cairo_fixed_t x2_fixed, y2_fixed;
+    cairo_fixed_t x3_fixed, y3_fixed;
+
+    _cairo_gstate_user_to_backend (cr->gstate, &x1, &y1);
+    _cairo_gstate_user_to_backend (cr->gstate, &x2, &y2);
+    _cairo_gstate_user_to_backend (cr->gstate, &x3, &y3);
+
+    x1_fixed = _cairo_fixed_from_double (x1);
+    y1_fixed = _cairo_fixed_from_double (y1);
+
+    x2_fixed = _cairo_fixed_from_double (x2);
+    y2_fixed = _cairo_fixed_from_double (y2);
+
+    x3_fixed = _cairo_fixed_from_double (x3);
+    y3_fixed = _cairo_fixed_from_double (y3);
+
+    return _cairo_path_fixed_curve_to (cr->path,
+				       x1_fixed, y1_fixed,
+				       x2_fixed, y2_fixed,
+				       x3_fixed, y3_fixed);
+}
+
+static cairo_status_t
+_cairo_default_context_arc (void *abstract_cr,
+			    double xc, double yc, double radius,
+			    double angle1, double angle2,
+			    cairo_bool_t forward)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_status_t status;
+
+    /* Do nothing, successfully, if radius is <= 0 */
+    if (radius <= 0.0) {
+	cairo_fixed_t x_fixed, y_fixed;
+
+	_cairo_gstate_user_to_backend (cr->gstate, &xc, &yc);
+	x_fixed = _cairo_fixed_from_double (xc);
+	y_fixed = _cairo_fixed_from_double (yc);
+	status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed);
+	if (unlikely (status))
+	    return status;
+
+	status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed);
+	if (unlikely (status))
+	    return status;
+
+	return CAIRO_STATUS_SUCCESS;
+    }
+
+    status = _cairo_default_context_line_to (cr,
+					     xc + radius * cos (angle1),
+					     yc + radius * sin (angle1));
+
+    if (unlikely (status))
+	return status;
+
+    if (forward)
+	_cairo_arc_path (&cr->base, xc, yc, radius, angle1, angle2);
+    else
+	_cairo_arc_path_negative (&cr->base, xc, yc, radius, angle1, angle2);
+
+    return CAIRO_STATUS_SUCCESS; /* any error will have already been set on cr */
+}
+
+static cairo_status_t
+_cairo_default_context_rel_move_to (void *abstract_cr, double dx, double dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t dx_fixed, dy_fixed;
+
+    _cairo_gstate_user_to_backend_distance (cr->gstate, &dx, &dy);
+
+    dx_fixed = _cairo_fixed_from_double (dx);
+    dy_fixed = _cairo_fixed_from_double (dy);
+
+    return _cairo_path_fixed_rel_move_to (cr->path, dx_fixed, dy_fixed);
+}
+
+static cairo_status_t
+_cairo_default_context_rel_line_to (void *abstract_cr, double dx, double dy)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t dx_fixed, dy_fixed;
+
+    _cairo_gstate_user_to_backend_distance (cr->gstate, &dx, &dy);
+
+    dx_fixed = _cairo_fixed_from_double (dx);
+    dy_fixed = _cairo_fixed_from_double (dy);
+
+    return _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed);
+}
+
+
+static cairo_status_t
+_cairo_default_context_rel_curve_to (void *abstract_cr,
+				     double dx1, double dy1,
+				     double dx2, double dy2,
+				     double dx3, double dy3)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t dx1_fixed, dy1_fixed;
+    cairo_fixed_t dx2_fixed, dy2_fixed;
+    cairo_fixed_t dx3_fixed, dy3_fixed;
+
+    _cairo_gstate_user_to_backend_distance (cr->gstate, &dx1, &dy1);
+    _cairo_gstate_user_to_backend_distance (cr->gstate, &dx2, &dy2);
+    _cairo_gstate_user_to_backend_distance (cr->gstate, &dx3, &dy3);
+
+    dx1_fixed = _cairo_fixed_from_double (dx1);
+    dy1_fixed = _cairo_fixed_from_double (dy1);
+
+    dx2_fixed = _cairo_fixed_from_double (dx2);
+    dy2_fixed = _cairo_fixed_from_double (dy2);
+
+    dx3_fixed = _cairo_fixed_from_double (dx3);
+    dy3_fixed = _cairo_fixed_from_double (dy3);
+
+    return _cairo_path_fixed_rel_curve_to (cr->path,
+					   dx1_fixed, dy1_fixed,
+					   dx2_fixed, dy2_fixed,
+					   dx3_fixed, dy3_fixed);
+}
+
+static cairo_status_t
+_cairo_default_context_close_path (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_path_fixed_close_path (cr->path);
+}
+
+static cairo_status_t
+_cairo_default_context_rectangle (void *abstract_cr,
+				  double x, double y,
+				  double width, double height)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_status_t status;
+
+    status = _cairo_default_context_move_to (cr, x, y);
+    if (unlikely (status))
+	return status;
+
+    status = _cairo_default_context_rel_line_to (cr, width, 0);
+    if (unlikely (status))
+	return status;
+
+    status = _cairo_default_context_rel_line_to (cr, 0, height);
+    if (unlikely (status))
+	return status;
+
+    status = _cairo_default_context_rel_line_to (cr, -width, 0);
+    if (unlikely (status))
+	return status;
+
+    return _cairo_default_context_close_path (cr);
+}
+
+static void
+_cairo_default_context_path_extents (void *abstract_cr,
+				     double *x1,
+				     double *y1,
+				     double *x2,
+				     double *y2)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_path_extents (cr->gstate,
+				cr->path,
+				x1, y1, x2, y2);
+}
+
+static cairo_bool_t
+_cairo_default_context_has_current_point (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return cr->path->has_current_point;
+}
+
+static cairo_bool_t
+_cairo_default_context_get_current_point (void *abstract_cr,
+					  double *x,
+					  double *y)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t x_fixed, y_fixed;
+
+    if (_cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed))
+    {
+	*x = _cairo_fixed_to_double (x_fixed);
+	*y = _cairo_fixed_to_double (y_fixed);
+	_cairo_gstate_backend_to_user (cr->gstate, x, y);
+
+	return TRUE;
+    }
+    else
+    {
+	return FALSE;
+    }
+}
+
+static cairo_path_t *
+_cairo_default_context_copy_path (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_path_create (cr->path, &cr->base);
+}
+
+static cairo_path_t *
+_cairo_default_context_copy_path_flat (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_path_create_flat (cr->path, &cr->base);
+}
+
+static cairo_status_t
+_cairo_default_context_append_path (void *abstract_cr,
+				    const cairo_path_t *path)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_path_append_to_context (path, &cr->base);
+}
+
+static cairo_status_t
+_cairo_default_context_paint (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_paint (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_paint_with_alpha (void *abstract_cr,
+					 double alpha)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_solid_pattern_t pattern;
+    cairo_status_t status;
+    cairo_color_t color;
+
+    if (CAIRO_ALPHA_IS_OPAQUE (alpha))
+	return _cairo_gstate_paint (cr->gstate);
+
+    if (CAIRO_ALPHA_IS_ZERO (alpha) &&
+        _cairo_operator_bounded_by_mask (cr->gstate->op)) {
+	return CAIRO_STATUS_SUCCESS;
+    }
+
+    _cairo_color_init_rgba (&color, 0., 0., 0., alpha);
+    _cairo_pattern_init_solid (&pattern, &color);
+
+    status = _cairo_gstate_mask (cr->gstate, &pattern.base);
+    _cairo_pattern_fini (&pattern.base);
+
+    return status;
+}
+
+static cairo_status_t
+_cairo_default_context_mask (void *abstract_cr,
+			     cairo_pattern_t *mask)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_mask (cr->gstate, mask);
+}
+
+static cairo_status_t
+_cairo_default_context_stroke_preserve (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_stroke (cr->gstate, cr->path);
+}
+
+static cairo_status_t
+_cairo_default_context_stroke (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_status_t status;
+
+    status = _cairo_gstate_stroke (cr->gstate, cr->path);
+    if (unlikely (status))
+	return status;
+
+    return _cairo_default_context_new_path (cr);
+}
+
+static cairo_status_t
+_cairo_default_context_in_stroke (void *abstract_cr,
+				  double x, double y,
+				  cairo_bool_t *inside)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_in_stroke (cr->gstate,
+				    cr->path,
+				    x, y,
+				    inside);
+}
+
+static cairo_status_t
+_cairo_default_context_stroke_extents (void *abstract_cr,
+				       double *x1, double *y1, double *x2, double *y2)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_stroke_extents (cr->gstate,
+					 cr->path,
+					 x1, y1, x2, y2);
+}
+
+static cairo_status_t
+_cairo_default_context_fill_preserve (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_fill (cr->gstate, cr->path);
+}
+
+static cairo_status_t
+_cairo_default_context_fill (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_status_t status;
+
+    status = _cairo_gstate_fill (cr->gstate, cr->path);
+    if (unlikely (status))
+	return status;
+
+    return _cairo_default_context_new_path (cr);
+}
+
+static cairo_status_t
+_cairo_default_context_in_fill (void *abstract_cr,
+				double x, double y,
+				cairo_bool_t *inside)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    *inside = _cairo_gstate_in_fill (cr->gstate,
+				     cr->path,
+				     x, y);
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_default_context_fill_extents (void *abstract_cr,
+				     double *x1, double *y1, double *x2, double *y2)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_fill_extents (cr->gstate,
+				       cr->path,
+				       x1, y1, x2, y2);
+}
+
+static cairo_status_t
+_cairo_default_context_clip_preserve (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_clip (cr->gstate, cr->path);
+}
+
+static cairo_status_t
+_cairo_default_context_clip (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_status_t status;
+
+    status = _cairo_gstate_clip (cr->gstate, cr->path);
+    if (unlikely (status))
+	return status;
+
+    return _cairo_default_context_new_path (cr);
+}
+
+static cairo_status_t
+_cairo_default_context_in_clip (void *abstract_cr,
+				double x, double y,
+				cairo_bool_t *inside)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    *inside = _cairo_gstate_in_clip (cr->gstate, x, y);
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_default_context_reset_clip (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_reset_clip (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_clip_extents (void *abstract_cr,
+				     double *x1, double *y1, double *x2, double *y2)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    if (! _cairo_gstate_clip_extents (cr->gstate, x1, y1, x2, y2)) {
+	*x1 = -INFINITY;
+	*y1 = -INFINITY;
+	*x2 = +INFINITY;
+	*y2 = +INFINITY;
+    }
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_rectangle_list_t *
+_cairo_default_context_copy_clip_rectangle_list (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_copy_clip_rectangle_list (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_copy_page (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_copy_page (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_tag_begin (void *abstract_cr,
+				  const char *tag_name, const char *attributes)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_tag_begin (cr->gstate, tag_name, attributes);
+}
+
+static cairo_status_t
+_cairo_default_context_tag_end (void *abstract_cr,
+				const char *tag_name)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_tag_end (cr->gstate, tag_name);
+}
+
+static cairo_status_t
+_cairo_default_context_show_page (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_show_page (cr->gstate);
+}
+
+static cairo_status_t
+_cairo_default_context_set_font_face (void *abstract_cr,
+				      cairo_font_face_t *font_face)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_font_face (cr->gstate, font_face);
+}
+
+static cairo_font_face_t *
+_cairo_default_context_get_font_face (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_font_face_t *font_face;
+    cairo_status_t status;
+
+    status = _cairo_gstate_get_font_face (cr->gstate, &font_face);
+    if (unlikely (status)) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+	return (cairo_font_face_t *) &_cairo_font_face_nil;
+    }
+
+    return font_face;
+}
+
+static cairo_status_t
+_cairo_default_context_font_extents (void *abstract_cr,
+				     cairo_font_extents_t *extents)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_get_font_extents (cr->gstate, extents);
+}
+
+static cairo_status_t
+_cairo_default_context_set_font_size (void *abstract_cr,
+				      double size)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_font_size (cr->gstate, size);
+}
+
+static cairo_status_t
+_cairo_default_context_set_font_matrix (void *abstract_cr,
+					const cairo_matrix_t *matrix)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_set_font_matrix (cr->gstate, matrix);
+}
+
+static void
+_cairo_default_context_get_font_matrix (void *abstract_cr,
+					cairo_matrix_t *matrix)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_get_font_matrix (cr->gstate, matrix);
+}
+
+static cairo_status_t
+_cairo_default_context_set_font_options (void *abstract_cr,
+					 const cairo_font_options_t *options)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_set_font_options (cr->gstate, options);
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static void
+_cairo_default_context_get_font_options (void *abstract_cr,
+					 cairo_font_options_t *options)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    _cairo_gstate_get_font_options (cr->gstate, options);
+}
+
+static cairo_status_t
+_cairo_default_context_set_scaled_font (void *abstract_cr,
+					cairo_scaled_font_t *scaled_font)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_bool_t was_previous;
+    cairo_status_t status;
+
+    if (scaled_font == cr->gstate->scaled_font)
+	return CAIRO_STATUS_SUCCESS;
+
+    was_previous = scaled_font == cr->gstate->previous_scaled_font;
+
+    status = _cairo_gstate_set_font_face (cr->gstate, scaled_font->font_face);
+    if (unlikely (status))
+	return status;
+
+    status = _cairo_gstate_set_font_matrix (cr->gstate, &scaled_font->font_matrix);
+    if (unlikely (status))
+	return status;
+
+    _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options);
+
+    if (was_previous)
+	cr->gstate->scaled_font = cairo_scaled_font_reference (scaled_font);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_scaled_font_t *
+_cairo_default_context_get_scaled_font (void *abstract_cr)
+{
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_scaled_font_t *scaled_font;
+    cairo_status_t status;
+
+    status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font);
+    if (unlikely (status))
+	return _cairo_scaled_font_create_in_error (status);
+
+    return scaled_font;
+}
+
+static cairo_status_t
+_cairo_default_context_glyphs (void *abstract_cr,
+			       const cairo_glyph_t *glyphs,
+			       int num_glyphs,
+			       cairo_glyph_text_info_t *info)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_show_text_glyphs (cr->gstate, glyphs, num_glyphs, info);
+}
+
+static cairo_status_t
+_cairo_default_context_glyph_path (void *abstract_cr,
+				   const cairo_glyph_t *glyphs,
+				   int num_glyphs)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_glyph_path (cr->gstate,
+				     glyphs, num_glyphs,
+				     cr->path);
+}
+
+static cairo_status_t
+_cairo_default_context_glyph_extents (void                *abstract_cr,
+				      const cairo_glyph_t    *glyphs,
+				      int                    num_glyphs,
+				      cairo_text_extents_t   *extents)
+{
+    cairo_default_context_t *cr = abstract_cr;
+
+    return _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, extents);
+}
+
+static const cairo_backend_t _cairo_default_context_backend = {
+    CAIRO_TYPE_DEFAULT,
+    _cairo_default_context_destroy,
+
+    _cairo_default_context_get_original_target,
+    _cairo_default_context_get_current_target,
+
+    _cairo_default_context_save,
+    _cairo_default_context_restore,
+
+    _cairo_default_context_push_group,
+    _cairo_default_context_pop_group,
+
+    _cairo_default_context_set_source_rgba,
+    _cairo_default_context_set_source_surface,
+    _cairo_default_context_set_source,
+    _cairo_default_context_get_source,
+
+    _cairo_default_context_set_antialias,
+    _cairo_default_context_set_dash,
+    _cairo_default_context_set_fill_rule,
+    _cairo_default_context_set_line_cap,
+    _cairo_default_context_set_line_join,
+    _cairo_default_context_set_line_width,
+    _cairo_default_context_set_hairline,
+    _cairo_default_context_set_miter_limit,
+    _cairo_default_context_set_opacity,
+    _cairo_default_context_set_operator,
+    _cairo_default_context_set_tolerance,
+    _cairo_default_context_get_antialias,
+    _cairo_default_context_get_dash,
+    _cairo_default_context_get_fill_rule,
+    _cairo_default_context_get_line_cap,
+    _cairo_default_context_get_line_join,
+    _cairo_default_context_get_line_width,
+    _cairo_default_context_get_hairline,
+    _cairo_default_context_get_miter_limit,
+    _cairo_default_context_get_opacity,
+    _cairo_default_context_get_operator,
+    _cairo_default_context_get_tolerance,
+
+    _cairo_default_context_translate,
+    _cairo_default_context_scale,
+    _cairo_default_context_rotate,
+    _cairo_default_context_transform,
+    _cairo_default_context_set_matrix,
+    _cairo_default_context_set_identity_matrix,
+    _cairo_default_context_get_matrix,
+
+    _cairo_default_context_user_to_device,
+    _cairo_default_context_user_to_device_distance,
+    _cairo_default_context_device_to_user,
+    _cairo_default_context_device_to_user_distance,
+
+    _cairo_default_context_user_to_backend,
+    _cairo_default_context_user_to_backend_distance,
+    _cairo_default_context_backend_to_user,
+    _cairo_default_context_backend_to_user_distance,
+
+    _cairo_default_context_new_path,
+    _cairo_default_context_new_sub_path,
+    _cairo_default_context_move_to,
+    _cairo_default_context_rel_move_to,
+    _cairo_default_context_line_to,
+    _cairo_default_context_rel_line_to,
+    _cairo_default_context_curve_to,
+    _cairo_default_context_rel_curve_to,
+    NULL, /* arc-to */
+    NULL, /* rel-arc-to */
+    _cairo_default_context_close_path,
+    _cairo_default_context_arc,
+    _cairo_default_context_rectangle,
+    _cairo_default_context_path_extents,
+    _cairo_default_context_has_current_point,
+    _cairo_default_context_get_current_point,
+    _cairo_default_context_copy_path,
+    _cairo_default_context_copy_path_flat,
+    _cairo_default_context_append_path,
+
+    NULL, /* stroke-to-path */
+
+    _cairo_default_context_clip,
+    _cairo_default_context_clip_preserve,
+    _cairo_default_context_in_clip,
+    _cairo_default_context_clip_extents,
+    _cairo_default_context_reset_clip,
+    _cairo_default_context_copy_clip_rectangle_list,
+
+    _cairo_default_context_paint,
+    _cairo_default_context_paint_with_alpha,
+    _cairo_default_context_mask,
+
+    _cairo_default_context_stroke,
+    _cairo_default_context_stroke_preserve,
+    _cairo_default_context_in_stroke,
+    _cairo_default_context_stroke_extents,
+
+    _cairo_default_context_fill,
+    _cairo_default_context_fill_preserve,
+    _cairo_default_context_in_fill,
+    _cairo_default_context_fill_extents,
+
+    _cairo_default_context_set_font_face,
+    _cairo_default_context_get_font_face,
+    _cairo_default_context_set_font_size,
+    _cairo_default_context_set_font_matrix,
+    _cairo_default_context_get_font_matrix,
+    _cairo_default_context_set_font_options,
+    _cairo_default_context_get_font_options,
+    _cairo_default_context_set_scaled_font,
+    _cairo_default_context_get_scaled_font,
+    _cairo_default_context_font_extents,
+
+    _cairo_default_context_glyphs,
+    _cairo_default_context_glyph_path,
+    _cairo_default_context_glyph_extents,
+
+    _cairo_default_context_copy_page,
+    _cairo_default_context_show_page,
+
+    _cairo_default_context_tag_begin,
+    _cairo_default_context_tag_end,
+};
+
+cairo_status_t
+_cairo_default_context_init (cairo_default_context_t *cr, void *target)
+{
+    _cairo_init (&cr->base, &_cairo_default_context_backend);
+    _cairo_path_fixed_init (cr->path);
+
+    cr->gstate = &cr->gstate_tail[0];
+    cr->gstate_freelist = &cr->gstate_tail[1];
+    cr->gstate_tail[1].next = NULL;
+
+    return _cairo_gstate_init (cr->gstate, target);
+}
+
+cairo_t *
+_cairo_default_context_create (void *target)
+{
+    cairo_default_context_t *cr;
+    cairo_status_t status;
+
+    cr = _freed_pool_get (&context_pool);
+    if (unlikely (cr == NULL)) {
+	cr = _cairo_malloc (sizeof (cairo_default_context_t));
+	if (unlikely (cr == NULL))
+	    return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
+    }
+
+    status = _cairo_default_context_init (cr, target);
+    if (unlikely (status)) {
+	_freed_pool_put (&context_pool, cr);
+	return _cairo_create_in_error (status);
+    }
+
+    return &cr->base;
+}
Index: cairo-1.17.8-new/src/cairo-fixed-private.h
===================================================================
--- cairo-1.17.8-new/src/cairo-fixed-private.h	(nonexistent)
+++ cairo-1.17.8-new/src/cairo-fixed-private.h	(revision 5)
@@ -0,0 +1,395 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
+/* Cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2007 Mozilla Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation
+ *
+ * Contributor(s):
+ *	Vladimir Vukicevic <vladimir@pobox.com>
+ */
+
+#ifndef CAIRO_FIXED_PRIVATE_H
+#define CAIRO_FIXED_PRIVATE_H
+
+#include "cairo-fixed-type-private.h"
+
+#include "cairo-wideint-private.h"
+#include "cairoint.h"
+
+/* Implementation */
+
+#if (CAIRO_FIXED_BITS != 32)
+# error CAIRO_FIXED_BITS must be 32, and the type must be a 32-bit type.
+# error To remove this limitation, you will have to fix the tessellator.
+#endif
+
+#define CAIRO_FIXED_ONE        ((cairo_fixed_t)(1 << CAIRO_FIXED_FRAC_BITS))
+#define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
+#define CAIRO_FIXED_EPSILON    ((cairo_fixed_t)(1))
+
+#define CAIRO_FIXED_ERROR_DOUBLE (1. / (2 * CAIRO_FIXED_ONE_DOUBLE))
+
+#define CAIRO_FIXED_FRAC_MASK  ((cairo_fixed_t)(((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)))
+#define CAIRO_FIXED_WHOLE_MASK (~CAIRO_FIXED_FRAC_MASK)
+
+static inline cairo_fixed_t
+_cairo_fixed_from_int (int i)
+{
+    return i << CAIRO_FIXED_FRAC_BITS;
+}
+
+/* This is the "magic number" approach to converting a double into fixed
+ * point as described here:
+ *
+ * http://www.stereopsis.com/sree/fpu2006.html (an overview)
+ * http://www.d6.com/users/checker/pdfs/gdmfp.pdf (in detail)
+ *
+ * The basic idea is to add a large enough number to the double that the
+ * literal floating point is moved up to the extent that it forces the
+ * double's value to be shifted down to the bottom of the mantissa (to make
+ * room for the large number being added in). Since the mantissa is, at a
+ * given moment in time, a fixed point integer itself, one can convert a
+ * float to various fixed point representations by moving around the point
+ * of a floating point number through arithmetic operations. This behavior
+ * is reliable on most modern platforms as it is mandated by the IEEE-754
+ * standard for floating point arithmetic.
+ *
+ * For our purposes, a "magic number" must be carefully selected that is
+ * both large enough to produce the desired point-shifting effect, and also
+ * has no lower bits in its representation that would interfere with our
+ * value at the bottom of the mantissa. The magic number is calculated as
+ * follows:
+ *
+ *          (2 ^ (MANTISSA_SIZE - FRACTIONAL_SIZE)) * 1.5
+ *
+ * where in our case:
+ *  - MANTISSA_SIZE for 64-bit doubles is 52
+ *  - FRACTIONAL_SIZE for 16.16 fixed point is 16
+ *
+ * Although this approach provides a very large speedup of this function
+ * on a wide-array of systems, it does come with two caveats:
+ *
+ * 1) It uses banker's rounding as opposed to arithmetic rounding.
+ * 2) It doesn't function properly if the FPU is in single-precision
+ *    mode.
+ */
+
+/* The 16.16 number must always be available */
+#define CAIRO_MAGIC_NUMBER_FIXED_16_16 (103079215104.0)
+
+#if CAIRO_FIXED_BITS <= 32
+#define CAIRO_MAGIC_NUMBER_FIXED ((1LL << (52 - CAIRO_FIXED_FRAC_BITS)) * 1.5)
+
+/* For 32-bit fixed point numbers */
+static inline cairo_fixed_t
+_cairo_fixed_from_double (double d)
+{
+    union {
+        double d;
+        int32_t i[2];
+    } u;
+
+    u.d = d + CAIRO_MAGIC_NUMBER_FIXED;
+#ifdef FLOAT_WORDS_BIGENDIAN
+    return u.i[1];
+#else
+    return u.i[0];
+#endif
+}
+
+#else
+# error Please define a magic number for your fixed point type!
+# error See cairo-fixed-private.h for details.
+#endif
+
+static inline cairo_fixed_t
+_cairo_fixed_from_26_6 (uint32_t i)
+{
+#if CAIRO_FIXED_FRAC_BITS > 6
+    return i << (CAIRO_FIXED_FRAC_BITS - 6);
+#else
+    return i >> (6 - CAIRO_FIXED_FRAC_BITS);
+#endif
+}
+
+static inline cairo_fixed_t
+_cairo_fixed_from_16_16 (uint32_t i)
+{
+#if CAIRO_FIXED_FRAC_BITS > 16
+    return i << (CAIRO_FIXED_FRAC_BITS - 16);
+#else
+    return i >> (16 - CAIRO_FIXED_FRAC_BITS);
+#endif
+}
+
+static inline double
+_cairo_fixed_to_double (cairo_fixed_t f)
+{
+    return ((double) f) / CAIRO_FIXED_ONE_DOUBLE;
+}
+
+static inline int
+_cairo_fixed_is_integer (cairo_fixed_t f)
+{
+    return (f & CAIRO_FIXED_FRAC_MASK) == 0;
+}
+
+static inline cairo_fixed_t
+_cairo_fixed_floor (cairo_fixed_t f)
+{
+    return f & ~CAIRO_FIXED_FRAC_MASK;
+}
+
+static inline cairo_fixed_t
+_cairo_fixed_ceil (cairo_fixed_t f)
+{
+    return _cairo_fixed_floor (f + CAIRO_FIXED_FRAC_MASK);
+}
+
+static inline cairo_fixed_t
+_cairo_fixed_round (cairo_fixed_t f)
+{
+    return _cairo_fixed_floor (f + (CAIRO_FIXED_FRAC_MASK+1)/2);
+}
+
+static inline cairo_fixed_t
+_cairo_fixed_round_down (cairo_fixed_t f)
+{
+    return _cairo_fixed_floor (f + CAIRO_FIXED_FRAC_MASK/2);
+}
+
+static inline int
+_cairo_fixed_integer_part (cairo_fixed_t f)
+{
+    return f >> CAIRO_FIXED_FRAC_BITS;
+}
+
+static inline int
+_cairo_fixed_integer_round (cairo_fixed_t f)
+{
+    return _cairo_fixed_integer_part (f + (CAIRO_FIXED_FRAC_MASK+1)/2);
+}
+
+static inline int
+_cairo_fixed_integer_round_down (cairo_fixed_t f)
+{
+    return _cairo_fixed_integer_part (f + CAIRO_FIXED_FRAC_MASK/2);
+}
+
+static inline int
+_cairo_fixed_fractional_part (cairo_fixed_t f)
+{
+    return f & CAIRO_FIXED_FRAC_MASK;
+}
+
+static inline int
+_cairo_fixed_integer_floor (cairo_fixed_t f)
+{
+    if (f >= 0)
+        return f >> CAIRO_FIXED_FRAC_BITS;
+    else
+        return -((-f - 1) >> CAIRO_FIXED_FRAC_BITS) - 1;
+}
+
+static inline int
+_cairo_fixed_integer_ceil (cairo_fixed_t f)
+{
+    if (f > 0)
+	return ((f - 1)>>CAIRO_FIXED_FRAC_BITS) + 1;
+    else
+	return - ((cairo_fixed_t)(-(cairo_fixed_unsigned_t)f) >> CAIRO_FIXED_FRAC_BITS);
+}
+
+/* A bunch of explicit 16.16 operators; we need these
+ * to interface with pixman and other backends that require
+ * 16.16 fixed point types.
+ */
+static inline cairo_fixed_16_16_t
+_cairo_fixed_to_16_16 (cairo_fixed_t f)
+{
+#if (CAIRO_FIXED_FRAC_BITS == 16) && (CAIRO_FIXED_BITS == 32)
+    return f;
+#elif CAIRO_FIXED_FRAC_BITS > 16
+    /* We're just dropping the low bits, so we won't ever got over/underflow here */
+    return f >> (CAIRO_FIXED_FRAC_BITS - 16);
+#else
+    cairo_fixed_16_16_t x;
+
+    /* Handle overflow/underflow by clamping to the lowest/highest
+     * value representable as 16.16
+     */
+    if ((f >> CAIRO_FIXED_FRAC_BITS) < INT16_MIN) {
+	x = INT32_MIN;
+    } else if ((f >> CAIRO_FIXED_FRAC_BITS) > INT16_MAX) {
+	x = INT32_MAX;
+    } else {
+	x = f << (16 - CAIRO_FIXED_FRAC_BITS);
+    }
+
+    return x;
+#endif
+}
+
+static inline cairo_fixed_16_16_t
+_cairo_fixed_16_16_from_double (double d)
+{
+    union {
+        double d;
+        int32_t i[2];
+    } u;
+
+    u.d = d + CAIRO_MAGIC_NUMBER_FIXED_16_16;
+#ifdef FLOAT_WORDS_BIGENDIAN
+    return u.i[1];
+#else
+    return u.i[0];
+#endif
+}
+
+static inline int
+_cairo_fixed_16_16_floor (cairo_fixed_16_16_t f)
+{
+    if (f >= 0)
+	return f >> 16;
+    else
+	return -((-f - 1) >> 16) - 1;
+}
+
+static inline double
+_cairo_fixed_16_16_to_double (cairo_fixed_16_16_t f)
+{
+    return ((double) f) / (double) (1 << 16);
+}
+
+#if CAIRO_FIXED_BITS == 32
+
+static inline cairo_fixed_t
+_cairo_fixed_mul (cairo_fixed_t a, cairo_fixed_t b)
+{
+    cairo_int64_t temp = _cairo_int32x32_64_mul (a, b);
+    return _cairo_int64_to_int32(_cairo_int64_rsl (temp, CAIRO_FIXED_FRAC_BITS));
+}
+
+/* computes round (a * b / c) */
+static inline cairo_fixed_t
+_cairo_fixed_mul_div (cairo_fixed_t a, cairo_fixed_t b, cairo_fixed_t c)
+{
+    cairo_int64_t ab  = _cairo_int32x32_64_mul (a, b);
+    cairo_int64_t c64 = _cairo_int32_to_int64 (c);
+    return _cairo_int64_to_int32 (_cairo_int64_divrem (ab, c64).quo);
+}
+
+/* computes floor (a * b / c) */
+static inline cairo_fixed_t
+_cairo_fixed_mul_div_floor (cairo_fixed_t a, cairo_fixed_t b, cairo_fixed_t c)
+{
+    return _cairo_int64_32_div (_cairo_int32x32_64_mul (a, b), c);
+}
+
+/* compute y from x so that (x,y), p1, and p2 are collinear */
+static inline cairo_fixed_t
+_cairo_edge_compute_intersection_y_for_x (const cairo_point_t *p1,
+					  const cairo_point_t *p2,
+					  cairo_fixed_t x)
+{
+    cairo_fixed_t y, dx;
+
+    if (x == p1->x)
+	return p1->y;
+    if (x == p2->x)
+	return p2->y;
+
+    y = p1->y;
+    dx = p2->x - p1->x;
+    if (dx != 0)
+	y += _cairo_fixed_mul_div_floor (x - p1->x, p2->y - p1->y, dx);
+
+    return y;
+}
+
+/* compute x from y so that (x,y), p1, and p2 are collinear */
+static inline cairo_fixed_t
+_cairo_edge_compute_intersection_x_for_y (const cairo_point_t *p1,
+					  const cairo_point_t *p2,
+					  cairo_fixed_t y)
+{
+    cairo_fixed_t x, dy;
+
+    if (y == p1->y)
+	return p1->x;
+    if (y == p2->y)
+	return p2->x;
+
+    x = p1->x;
+    dy = p2->y - p1->y;
+    if (dy != 0)
+	x += _cairo_fixed_mul_div_floor (y - p1->y, p2->x - p1->x, dy);
+
+    return x;
+}
+
+/* Intersect two segments based on the algorithm described at
+ * http://paulbourke.net/geometry/pointlineplane/. This implementation
+ * uses floating point math. */
+static inline cairo_bool_t
+_slow_segment_intersection (const cairo_point_t *seg1_p1,
+			    const cairo_point_t *seg1_p2,
+			    const cairo_point_t *seg2_p1,
+			    const cairo_point_t *seg2_p2,
+			    cairo_point_t *intersection)
+{
+    double denominator, u_a, u_b;
+    double seg1_dx, seg1_dy, seg2_dx, seg2_dy, seg_start_dx, seg_start_dy;
+
+    seg1_dx = _cairo_fixed_to_double (seg1_p2->x - seg1_p1->x);
+    seg1_dy = _cairo_fixed_to_double (seg1_p2->y - seg1_p1->y);
+    seg2_dx = _cairo_fixed_to_double (seg2_p2->x - seg2_p1->x);
+    seg2_dy = _cairo_fixed_to_double (seg2_p2->y - seg2_p1->y);
+    denominator = (seg2_dy * seg1_dx) - (seg2_dx * seg1_dy);
+    if (denominator == 0)
+	return FALSE;
+
+    seg_start_dx = _cairo_fixed_to_double (seg1_p1->x - seg2_p1->x);
+    seg_start_dy = _cairo_fixed_to_double (seg1_p1->y - seg2_p1->y);
+    u_a = ((seg2_dx * seg_start_dy) - (seg2_dy * seg_start_dx)) / denominator;
+    u_b = ((seg1_dx * seg_start_dy) - (seg1_dy * seg_start_dx)) / denominator;
+
+    if (u_a <= 0 || u_a >= 1 || u_b <= 0 || u_b >= 1)
+	return FALSE;
+
+    intersection->x = seg1_p1->x + _cairo_fixed_from_double ((u_a * seg1_dx));
+    intersection->y = seg1_p1->y + _cairo_fixed_from_double ((u_a * seg1_dy));
+    return TRUE;
+}
+
+#else
+# error Please define multiplication and other operands for your fixed-point type size
+#endif
+
+#endif /* CAIRO_FIXED_PRIVATE_H */
Index: cairo-1.17.8-new/src
===================================================================
--- cairo-1.17.8-new/src	(nonexistent)
+++ cairo-1.17.8-new/src	(revision 5)

Property changes on: cairo-1.17.8-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: cairo-1.17.8-new
===================================================================
--- cairo-1.17.8-new	(nonexistent)
+++ cairo-1.17.8-new	(revision 5)

Property changes on: cairo-1.17.8-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create.patch.sh
===================================================================
--- create.patch.sh	(nonexistent)
+++ create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=1.17.8
+
+tar --files-from=file.list -xJvf ../cairo-$VERSION.tar.xz
+mv cairo-$VERSION cairo-$VERSION-orig
+
+cp -rf ./cairo-$VERSION-new ./cairo-$VERSION
+
+diff --unified -Nr  cairo-$VERSION-orig  cairo-$VERSION > cairo-$VERSION-coordinates.patch
+
+mv cairo-$VERSION-coordinates.patch ../patches
+
+rm -rf ./cairo-$VERSION
+rm -rf ./cairo-$VERSION-orig

Property changes on: create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: file.list
===================================================================
--- file.list	(nonexistent)
+++ file.list	(revision 5)
@@ -0,0 +1,2 @@
+cairo-1.17.8/src/cairo-default-context.c
+cairo-1.17.8/src/cairo-fixed-private.h
Index: .
===================================================================
--- .	(nonexistent)
+++ .	(revision 5)

Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~