[cairo-commit] 2 commits - src/cairo-backend-private.h src/cairo-default-context.c src/cairo-gstate.c src/cairo-gstate-private.h src/cairo-path.c src/skia

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 10 07:12:38 PDT 2012


 src/cairo-backend-private.h     |   29 ++++++++++++++++++++++++++
 src/cairo-default-context.c     |   44 ++++++++++++++++++++++++++++++++++++++++
 src/cairo-gstate-private.h      |   10 +++++++++
 src/cairo-gstate.c              |    7 ++++++
 src/cairo-path.c                |   11 +++++-----
 src/skia/cairo-skia-context.cpp |    4 +++
 6 files changed, 100 insertions(+), 5 deletions(-)

New commits:
commit f34b87f6d76cbea93acd4a8c73c8c6a6b412a302
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 10 15:09:18 2012 +0100

    path: Convert from backend coordinates back into user coordinates
    
    Fixes regression from commit 83bfd85a1378e61b8bdc3f554f5e07900311f61f
    Author: Chris Wilson <chris at chris-wilson.co.uk>
    Date:   Fri Apr 23 19:45:26 2010 +0100
    
        Implement cairo_backend_t
    
    As there exists no public API to perform the operation we needed, and we
    failed to create one, the constructed path failed to correctly remove
    the device offset.
    
    Fixes copy-path under device translation.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54732
    Reported-by: Benjamin Berg <benjamin at sipsolutions.net>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-path.c b/src/cairo-path.c
index 5c48373..43cd175 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -37,6 +37,7 @@
 #include "cairoint.h"
 
 #include "cairo-private.h"
+#include "cairo-backend-private.h"
 #include "cairo-error-private.h"
 #include "cairo-path-private.h"
 #include "cairo-path-fixed-private.h"
@@ -152,7 +153,7 @@ _cpp_move_to (void *closure,
     x = _cairo_fixed_to_double (point->x);
     y = _cairo_fixed_to_double (point->y);
 
-    cairo_device_to_user (cpp->cr, &x, &y);
+    _cairo_backend_to_user (cpp->cr, &x, &y);
 
     data->header.type = CAIRO_PATH_MOVE_TO;
     data->header.length = 2;
@@ -177,7 +178,7 @@ _cpp_line_to (void *closure,
     x = _cairo_fixed_to_double (point->x);
     y = _cairo_fixed_to_double (point->y);
 
-    cairo_device_to_user (cpp->cr, &x, &y);
+    _cairo_backend_to_user (cpp->cr, &x, &y);
 
     data->header.type = CAIRO_PATH_LINE_TO;
     data->header.length = 2;
@@ -205,15 +206,15 @@ _cpp_curve_to (void			*closure,
 
     x1 = _cairo_fixed_to_double (p1->x);
     y1 = _cairo_fixed_to_double (p1->y);
-    cairo_device_to_user (cpp->cr, &x1, &y1);
+    _cairo_backend_to_user (cpp->cr, &x1, &y1);
 
     x2 = _cairo_fixed_to_double (p2->x);
     y2 = _cairo_fixed_to_double (p2->y);
-    cairo_device_to_user (cpp->cr, &x2, &y2);
+    _cairo_backend_to_user (cpp->cr, &x2, &y2);
 
     x3 = _cairo_fixed_to_double (p3->x);
     y3 = _cairo_fixed_to_double (p3->y);
-    cairo_device_to_user (cpp->cr, &x3, &y3);
+    _cairo_backend_to_user (cpp->cr, &x3, &y3);
 
     data->header.type = CAIRO_PATH_CURVE_TO;
     data->header.length = 4;
commit df6780442feba5c0c9404353177f24913b58bd32
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 10 15:03:47 2012 +0100

    context: Add missing functions to transform between user and backend coordinates
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-backend-private.h b/src/cairo-backend-private.h
index 1dd5ea0..cd626b8 100644
--- a/src/cairo-backend-private.h
+++ b/src/cairo-backend-private.h
@@ -96,6 +96,11 @@ struct _cairo_backend {
     void (*device_to_user) (void *cr, double *x, double *y);
     void (*device_to_user_distance) (void *cr, double *x, double *y);
 
+    void (*user_to_backend) (void *cr, double *x, double *y);
+    void (*user_to_backend_distance) (void *cr, double *x, double *y);
+    void (*backend_to_user) (void *cr, double *x, double *y);
+    void (*backend_to_user_distance) (void *cr, double *x, double *y);
+
     cairo_status_t (*new_path) (void *cr);
     cairo_status_t (*new_sub_path) (void *cr);
     cairo_status_t (*move_to) (void *cr, double x, double y);
@@ -168,4 +173,28 @@ struct _cairo_backend {
     cairo_status_t (*show_page) (void *cr);
 };
 
+static inline void
+_cairo_backend_to_user (cairo_t *cr, double *x, double *y)
+{
+    cr->backend->backend_to_user (cr, x, y);
+}
+
+static inline void
+_cairo_backend_to_user_distance (cairo_t *cr, double *x, double *y)
+{
+    cr->backend->backend_to_user_distance (cr, x, y);
+}
+
+static inline void
+_cairo_user_to_backend (cairo_t *cr, double *x, double *y)
+{
+    cr->backend->user_to_backend (cr, x, y);
+}
+
+static inline void
+_cairo_user_to_backend_distance (cairo_t *cr, double *x, double *y)
+{
+    cr->backend->user_to_backend_distance (cr, x, y);
+}
+
 #endif /* CAIRO_BACKEND_PRIVATE_H */
diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index c020fcb..3d828ef 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -621,6 +621,44 @@ _cairo_default_context_device_to_user_distance (void *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
@@ -1321,11 +1359,17 @@ static const cairo_backend_t _cairo_default_context_backend = {
     _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,
diff --git a/src/cairo-gstate-private.h b/src/cairo-gstate-private.h
index c95d94a..b2ccc76 100644
--- a/src/cairo-gstate-private.h
+++ b/src/cairo-gstate-private.h
@@ -229,6 +229,16 @@ _cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y)
 }
 
 cairo_private void
+_do_cairo_gstate_backend_to_user_distance (cairo_gstate_t *gstate, double *x, double *y);
+
+static inline void
+_cairo_gstate_backend_to_user_distance (cairo_gstate_t *gstate, double *x, double *y)
+{
+    if (! gstate->is_identity)
+	_do_cairo_gstate_backend_to_user_distance (gstate, x, y);
+}
+
+cairo_private void
 _cairo_gstate_backend_to_user_rectangle (cairo_gstate_t *gstate,
                                          double *x1, double *y1,
                                          double *x2, double *y2,
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index d62f0a4..c90f2f6 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -828,6 +828,13 @@ _do_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y)
 }
 
 void
+_do_cairo_gstate_backend_to_user_distance (cairo_gstate_t *gstate, double *x, double *y)
+{
+    cairo_matrix_transform_distance (&gstate->target->device_transform_inverse, x, y);
+    cairo_matrix_transform_distance (&gstate->ctm_inverse, x, y);
+}
+
+void
 _cairo_gstate_backend_to_user_rectangle (cairo_gstate_t *gstate,
                                          double *x1, double *y1,
                                          double *x2, double *y2,
diff --git a/src/skia/cairo-skia-context.cpp b/src/skia/cairo-skia-context.cpp
index a08b3fb..bbe5507 100644
--- a/src/skia/cairo-skia-context.cpp
+++ b/src/skia/cairo-skia-context.cpp
@@ -1635,6 +1635,10 @@ static const cairo_backend_t _cairo_skia_context_backend = {
     _cairo_skia_context_user_to_device_distance,
     _cairo_skia_context_device_to_user,
     _cairo_skia_context_device_to_user_distance,
+    _cairo_skia_context_user_to_device, /* XXX backend */
+    _cairo_skia_context_user_to_device_distance, /* XXX backend */
+    _cairo_skia_context_device_to_user, /* XXX backend */
+    _cairo_skia_context_device_to_user_distance, /* XXX backend */
 
     _cairo_skia_context_new_path,
     _cairo_skia_context_new_sub_path,


More information about the cairo-commit mailing list