From 998f8560869b474fdb2c33fa6bf8ab954fd2e06a Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 2 Jan 2020 13:05:18 +0100 Subject: [PATCH 1/2] Up cairo version to min required 1.14 --- src/display/sp-canvas.cpp | 10 ---------- src/display/sp-canvas.h | 2 -- .../internal/cairo-render-context.cpp | 8 +++----- .../internal/cairo-renderer-pdf-out.cpp | 2 -- src/object/sp-mesh-gradient.cpp | 20 ++----------------- 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 03e4de86e1..85770640a3 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -983,9 +983,7 @@ static void sp_canvas_init(SPCanvas *canvas) canvas->_drawing_disabled = false; canvas->_backing_store = nullptr; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) canvas->_surface_for_similar = nullptr; -#endif canvas->_clean_region = cairo_region_create(); canvas->_background = cairo_pattern_create_rgb(1, 1, 1); canvas->_background_is_checkerboard = false; @@ -1054,12 +1052,10 @@ void SPCanvas::dispose(GObject *object) cairo_surface_destroy(canvas->_backing_store); canvas->_backing_store = nullptr; } -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) if (canvas->_surface_for_similar) { cairo_surface_destroy(canvas->_surface_for_similar); canvas->_surface_for_similar = nullptr; } -#endif if (canvas->_clean_region) { cairo_region_destroy(canvas->_clean_region); canvas->_clean_region = nullptr; @@ -1184,7 +1180,6 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation // Resize backing store. cairo_surface_t *new_backing_store = nullptr; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) if (canvas->_surface_for_similar != nullptr) { // Size in device pixels. Does not set device scale. @@ -1194,7 +1189,6 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation allocation->width * canvas->_device_scale, allocation->height * canvas->_device_scale); } -#endif if (new_backing_store == nullptr) { // Size in device pixels. Does not set device scale. @@ -2261,7 +2255,6 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { SPCanvas *canvas = SP_CANVAS(widget); -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) if (canvas->_surface_for_similar == nullptr && canvas->_backing_store != nullptr) { // Device scale is copied but since this is only created one time, we'll @@ -2295,7 +2288,6 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { cairo_surface_destroy(canvas->_backing_store); canvas->_backing_store = new_backing_store; } -#endif // Blit from the backing store, without regard for the clean region. // This is necessary because GTK clears the widget for us, which causes @@ -2681,7 +2673,6 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol assert(_backing_store); // this cairo operation is slow, improvements welcome cairo_surface_t *new_backing_store = nullptr; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) if (_surface_for_similar != nullptr) // Size in device pixels. Does not set device scale. @@ -2690,7 +2681,6 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol CAIRO_FORMAT_ARGB32, allocation.width * _device_scale, allocation.height * _device_scale); -#endif if (new_backing_store == nullptr) // Size in device pixels. Does not set device scale. new_backing_store = diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 9c78794424..5349ec144a 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -215,10 +215,8 @@ public: /// Image surface storing the contents of the widget cairo_surface_t *_backing_store; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) /// This should be e.g. a cairo-xlib surface that is used to allocate _backing_store; might be NULL. cairo_surface_t *_surface_for_similar; -#endif /// Area of the widget that has up-to-date content cairo_region_t *_clean_region; /// Widget background, defaults to white diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4d02ec3e34..7b19d3eea3 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -830,11 +830,9 @@ CairoRenderContext::setupSurface(double width, double height) cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level); cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps); // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501 -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)) -// cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); -// cairo_ps_dsc_begin_page(surface); -// cairo_ps_dsc_comment(surface, os_pagebbox.str().c_str()); -#endif + // cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); + // cairo_ps_dsc_begin_page(surface); + // cairo_ps_dsc_comment(surface, os_pagebbox.str().c_str()); break; #endif default: diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index cd46a66dd6..7ad308ccdb 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -243,9 +243,7 @@ CairoRendererPdfOutput::init () "Portable Document Format\n" "org.inkscape.output.pdf.cairorenderer\n" "\n" -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)) "\n" -#endif "\n" "\n" "\n" diff --git a/src/object/sp-mesh-gradient.cpp b/src/object/sp-mesh-gradient.cpp index cf693f774d..89b5d08311 100644 --- a/src/object/sp-mesh-gradient.cpp +++ b/src/object/sp-mesh-gradient.cpp @@ -154,14 +154,8 @@ Inkscape::XML::Node* SPMeshGradient::write(Inkscape::XML::Document *xml_doc, Ink } cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t * /*ct*/, -#if defined(MESH_DEBUG) || (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 4)) - Geom::OptRect const &bbox, - double opacity -#else - Geom::OptRect const & /*bbox*/, - double /*opacity*/ -#endif - ) + Geom::OptRect const &bbox, + double opacity) { using Geom::X; using Geom::Y; @@ -174,7 +168,6 @@ cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t * /*ct*/, cairo_pattern_t *cp = nullptr; -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 4) SPMeshNodeArray* my_array = &array; if( type_set ) { @@ -266,15 +259,6 @@ cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t * /*ct*/, } ink_cairo_pattern_set_matrix(cp, gs2user.inverse()); -#else - static bool shown = false; - if( !shown ) { - std::cout << "sp_mesh_create_pattern: needs cairo >= 1.11.4, using " - << cairo_version_string() << std::endl; - shown = true; - } -#endif - /* cairo_pattern_t *cp = cairo_pattern_create_radial( rg->fx.computed, rg->fy.computed, 0, -- GitLab From 9ec1c35766aa0ab10ada5f554583acb7b71e053d Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 2 Jan 2020 16:02:29 +0100 Subject: [PATCH 2/2] Remove dead code pointed by Thomas --- src/extension/internal/cairo-render-context.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 7b19d3eea3..d0a18d639c 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -801,13 +801,6 @@ CairoRenderContext::setupSurface(double width, double height) _width = width; _height = height; - Inkscape::SVGOStringStream os_bbox; - Inkscape::SVGOStringStream os_pagebbox; - os_bbox.setf(std::ios::fixed); // don't use scientific notation - os_pagebbox.setf(std::ios::fixed); // don't use scientific notation - os_bbox << "%%BoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height); // apparently, the numbers should be integers. (see bug 380501) - os_pagebbox << "%%PageBoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height); - cairo_surface_t *surface = nullptr; cairo_matrix_t ctm; cairo_matrix_init_identity (&ctm); @@ -829,10 +822,6 @@ CairoRenderContext::setupSurface(double width, double height) } cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level); cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps); - // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501 - // cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); - // cairo_ps_dsc_begin_page(surface); - // cairo_ps_dsc_comment(surface, os_pagebbox.str().c_str()); break; #endif default: -- GitLab