From e25ab3e42106c3548a48aa4cb3225a2354b5956f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 28 Jul 2018 11:41:06 +0200 Subject: [PATCH] Fix getting extents of wxGraphicsPath (Cairo) Graphics path is actually a line with null width so its bounding box should be obtained with cairo_path_extents() function which assumes that line width is 0. --- src/common/cairo.cpp | 2 ++ src/generic/graphicc.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/cairo.cpp b/src/common/cairo.cpp index 940299dad0..3b86f79192 100644 --- a/src/common/cairo.cpp +++ b/src/common/cairo.cpp @@ -100,6 +100,8 @@ (cairo_t *cr, double alpha), (cr, alpha) ) \ m( cairo_path_destroy, \ (cairo_path_t *path), (path) ) \ + m( cairo_path_extents, \ + (cairo_t *cr, double *x1, double *y1, double *x2, double *y2), (cr, x1, y1, x2, y2) ) \ m( cairo_pattern_add_color_stop_rgba, \ (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha), (pattern, offset, red, green, blue, alpha) ) \ m( cairo_pattern_destroy, \ diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index ddf2f94c52..1f6b875613 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -1195,7 +1195,17 @@ void wxCairoPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) { double x1,y1,x2,y2; - cairo_stroke_extents( m_pathContext, &x1, &y1, &x2, &y2 ); +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0) + if ( cairo_version() >= CAIRO_VERSION_ENCODE(1, 6, 0) ) + { + cairo_path_extents(m_pathContext, &x1, &y1, &x2, &y2); + } + else +#endif + { + cairo_stroke_extents(m_pathContext, &x1, &y1, &x2, &y2); + } + if ( x2 < x1 ) { *x = x2;