From e9b6d4bb13a32c224543a70fd5702d558cc516c3 Mon Sep 17 00:00:00 2001 From: keescook Date: Mon, 10 Dec 2007 00:48:29 +0000 Subject: [PATCH] always build cairo backend; add interface for setting cairo surface to renderer --- .../internal/cairo-render-context.cpp | 22 +++++++++++++++---- src/extension/internal/cairo-render-context.h | 7 +++--- src/extension/internal/cairo-renderer.cpp | 5 ----- src/extension/internal/cairo-renderer.h | 4 ---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 61d40ea4e..8f106f55f 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -16,8 +16,6 @@ # include "config.h" #endif -#ifdef HAVE_CAIRO_PDF - #ifndef PANGO_ENABLE_BACKEND #define PANGO_ENABLE_BACKEND #endif @@ -672,6 +670,24 @@ CairoRenderContext::setupSurface(double width, double height) break; } + return _finishSurfaceSetup (surface); +} + +bool +CairoRenderContext::setSurface(cairo_surface_t *surface) +{ + if (_is_valid || !surface) + return false; + + bool ret = _finishSurfaceSetup (surface); + if (ret) + cairo_surface_reference (surface); + return ret; +} + +bool +CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface) +{ _cr = cairo_create(surface); _surface = surface; @@ -1502,8 +1518,6 @@ _write_callback(void *closure, const unsigned char *data, unsigned int length) /* End of GNU GPL code */ -#endif /* HAVE_CAIRO_PDF */ - /* Local Variables: diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index dc1592a81..ff7ebec7f 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -17,8 +17,6 @@ # include "config.h" #endif -#ifdef HAVE_CAIRO_PDF - #include "extension/extension.h" #include #include @@ -90,6 +88,8 @@ public: given width, height and with the currently set target surface type. */ bool setupSurface(double width, double height); + /** Set the cairo_surface_t from an external source */ + bool setSurface(cairo_surface_t *surface); cairo_surface_t *getSurface(void); @@ -169,6 +169,7 @@ protected: unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector const &glyphtext, bool is_stroke); + bool _finishSurfaceSetup(cairo_surface_t *surface); void _setFillStyle(SPStyle const *style, NRRect const *pbox); void _setStrokeStyle(SPStyle const *style, NRRect const *pbox); @@ -183,8 +184,6 @@ protected: } /* namespace Extension */ } /* namespace Inkscape */ -#endif /* HAVE_CAIRO_PDF */ - #endif /* !EXTENSION_INTERNAL_CAIRO_RENDER_CONTEXT_H_SEEN */ /* diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5583fa63c..418e82b89 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -16,8 +16,6 @@ # include "config.h" #endif -#ifdef HAVE_CAIRO_PDF - #ifndef PANGO_ENABLE_BACKEND #define PANGO_ENABLE_BACKEND #endif @@ -598,9 +596,6 @@ calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip /* End of GNU GPL code */ -#endif /* HAVE_CAIRO_PDF */ - - /* Local Variables: mode:c++ diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index 6cb810bfe..4056a8697 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -17,8 +17,6 @@ # include "config.h" #endif -#ifdef HAVE_CAIRO_PDF - #include "extension/extension.h" #include #include @@ -69,8 +67,6 @@ void calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect } /* namespace Extension */ } /* namespace Inkscape */ -#endif /* HAVE_CAIRO_PDF */ - #endif /* !EXTENSION_INTERNAL_CAIRO_RENDERER_H_SEEN */ /* -- 2.30.2