third_party/cairo/src/cairo-cogl-surface.c
static cairo_int_status_t
_cairo_cogl_get_untransformed_path (cairo_path_fixed_t       *copy,
                                    const cairo_path_fixed_t *orig,
                                    cairo_matrix_t           *transform_out)
{
    cairo_matrix_t transform;
    cairo_int_status_t status;

    if (orig->buf.base.num_points < 1)
        return CAIRO_INT_STATUS_NOTHING_TO_DO;

    status = _cairo_path_fixed_init_copy (copy, orig);
    if (unlikely (status))
        return status;

    /* First the path is translated so that its first point lies on the
     * origin. */
    cairo_matrix_init_translate (&transform,
                                 -_cairo_fixed_to_double(orig->buf.points[0].x),
                                 -_cairo_fixed_to_double(orig->buf.points[0].y));

    /* Then the path is rotated so that its second point lies on the
     * x axis. */
    if (orig->buf.base.num_points > 1) {
        double x = _cairo_fixed_to_double(orig->buf.points[1].x) -
                   _cairo_fixed_to_double(orig->buf.points[0].x);
        double y = _cairo_fixed_to_double(orig->buf.points[1].y) -
                   _cairo_fixed_to_double(orig->buf.points[0].y);
        double hyp = sqrt (x * x + y * y);

        transform.xx = x / hyp;
        transform.yy = x / hyp;
        transform.xy = -y / hyp;
        transform.yx = y / hyp;
    }

    _cairo_path_fixed_transform (copy, &transform);

    *transform_out = transform;
    status = cairo_matrix_invert (transform_out);
    if (unlikely (status)) {
        _cairo_path_fixed_fini (copy);
        return status;
    }

    return CAIRO_INT_STATUS_SUCCESS;
}
/* In order to facilitate path caching, we transform the input path
 * into a form that will make all translations and rotations of a given
 * path identical, thereby allowing them to be identified with
 * conventional path hashing and equivalence functions. A
 * transformation matrix is also output so that the path can be
 * transformed back into its original form during rendering. */
In order to facilitate path caching, we transform the input path
into a form that will make all translations and rotations of a given
path identical, thereby allowing them to be identified with
conventional path hashing and equivalence functions. A
transformation matrix is also output so that the path can be
transformed back into its original form during rendering.
In order to facilitate path caching we transform the input path into a form that will make all translations and rotations of a given path identical thereby allowing them to be identified with conventional path hashing and equivalence functions . A transformation matrix is also output so that the path can be transformed back into its original form during rendering .
static cairo_int_status_t
_cairo_cogl_get_untransformed_path (cairo_path_fixed_t       *copy,
                                    const cairo_path_fixed_t *orig,
                                    cairo_matrix_t           *transform_out)
{
    cairo_matrix_t transform;
    cairo_int_status_t status;
    if (orig->buf.base.num_points < 1)
        return CAIRO_INT_STATUS_NOTHING_TO_DO;
    status = _cairo_path_fixed_init_copy (copy, orig);
    if (unlikely (status))
        return status;
    cairo_matrix_init_translate (&transform,
                                 -_cairo_fixed_to_double(orig->buf.points[0].x),
                                 -_cairo_fixed_to_double(orig->buf.points[0].y));
    if (orig->buf.base.num_points > 1) {
        double x = _cairo_fixed_to_double(orig->buf.points[1].x) -
                   _cairo_fixed_to_double(orig->buf.points[0].x);
        double y = _cairo_fixed_to_double(orig->buf.points[1].y) -
                   _cairo_fixed_to_double(orig->buf.points[0].y);
        double hyp = sqrt (x * x + y * y);
        transform.xx = x / hyp;
        transform.yy = x / hyp;
        transform.xy = -y / hyp;
        transform.yx = y / hyp;
    }
    _cairo_path_fixed_transform (copy, &transform);
    *transform_out = transform;
    status = cairo_matrix_invert (transform_out);
    if (unlikely (status)) {
        _cairo_path_fixed_fini (copy);
        return status;
    }
    return CAIRO_INT_STATUS_SUCCESS;
}
static cairo_int_status_t _cairo_cogl_get_untransformed_path ( cairo_path_fixed_t * copy , const cairo_path_fixed_t * orig , cairo_matrix_t * transform_out ) { cairo_matrix_t transform ; cairo_int_status_t status ; if ( orig -> buf . base . num_points < 1 ) return CAIRO_INT_STATUS_NOTHING_TO_DO ; status = _cairo_path_fixed_init_copy ( copy , orig ) ; if ( unlikely ( status ) ) return status ; cairo_matrix_init_translate ( & transform , - _cairo_fixed_to_double ( orig -> buf . points [ 0 ] . x ) , - _cairo_fixed_to_double ( orig -> buf . points [ 0 ] . y ) ) ; if ( orig -> buf . base . num_points > 1 ) { double x = _cairo_fixed_to_double ( orig -> buf . points [ 1 ] . x ) - _cairo_fixed_to_double ( orig -> buf . points [ 0 ] . x ) ; double y = _cairo_fixed_to_double ( orig -> buf . points [ 1 ] . y ) - _cairo_fixed_to_double ( orig -> buf . points [ 0 ] . y ) ; double hyp = sqrt ( x * x + y * y ) ; transform . xx = x / hyp ; transform . yy = x / hyp ; transform . xy = - y / hyp ; transform . yx = y / hyp ; } _cairo_path_fixed_transform ( copy , & transform ) ; * transform_out = transform ; status = cairo_matrix_invert ( transform_out ) ; if ( unlikely ( status ) ) { _cairo_path_fixed_fini ( copy ) ; return status ; } return CAIRO_INT_STATUS_SUCCESS ; }
In order to facilitate path caching, we transform the input path
 into a form that will make all translations and rotations of a given
 path identical, thereby allowing them to be identified with
 conventional path hashing and equivalence functions.
In order to facilitate path caching we transform the input path into a form that will make all translations and rotations of a given path identical thereby allowing them to be identified with conventional path hashing and equivalence functions .
/* First the path is translated so that its first point lies on the
     * origin. */ /* Then the path is rotated so that its second point lies on the
     * x axis. */