diff options
-rw-r--r-- | canvas/source/cairo/cairo_xlib_cairo.cxx | 98 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_xlib_cairo.hxx | 22 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 2 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 5 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 5 | ||||
-rw-r--r-- | vcl/inc/generic/genpspgraphics.h | 1 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 1 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/salgdi.h | 1 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 1 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 4 |
16 files changed, 150 insertions, 13 deletions
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx index a4665e14aa04..24063a47b24e 100644 --- a/canvas/source/cairo/cairo_xlib_cairo.cxx +++ b/canvas/source/cairo/cairo_xlib_cairo.cxx @@ -324,17 +324,99 @@ namespace cairo return X11SysData( rVirDev.GetSystemGfxData() ); } + /** + * Surface::Surface: Create Canvas surface from Window reference. + * @param x horizontal location of the new surface + * @param y vertical location of the new surface + * @param width width of the new surface + * @param height height of the new surface + * + * Set the mpSurface to the new surface or NULL + **/ + Gtk3Surface::Gtk3Surface(const OutputDevice& rRefDevice, int x, int y, int width, int height) + : mpSurface(cairo_get_target(rRefDevice.GetCairoContext()), &cairo_surface_flush) + , mnWidth(width) + , mnHeight(height) + { + cairo_surface_set_device_offset(mpSurface.get(), x, y ); + } + + /** + * Surface::Surface: Create generic Canvas surface using given Cairo Surface + * + * @param pSurface Cairo Surface + * + * This constructor only stores data, it does no processing. + * It is used with e.g. cairo_image_surface_create_for_data() + * + * Set the mpSurface as pSurface + **/ + Gtk3Surface::Gtk3Surface(const CairoSurfaceSharedPtr& pSurface, int width, int height) + : mpSurface(pSurface) + , mnWidth(width) + , mnHeight(height) + { + } + + /** + * Surface::getCairo: Create Cairo (drawing object) for the Canvas surface + * + * @return new Cairo or NULL + **/ + CairoSharedPtr Gtk3Surface::getCairo() const + { + return CairoSharedPtr(cairo_create(mpSurface.get()), + &cairo_destroy); + } + + /** + * Surface::getSimilar: Create new similar Canvas surface + * @param aContent format of the new surface (cairo_content_t from cairo/src/cairo.h) + * @param width width of the new surface + * @param height height of the new surface + * + * Creates a new Canvas surface. + * + * Cairo surface from aContent (cairo_content_t) + * + * @return new surface or NULL + **/ + SurfaceSharedPtr Gtk3Surface::getSimilar( Content aContent, int width, int height ) const + { + return SurfaceSharedPtr( + new Gtk3Surface(CairoSurfaceSharedPtr( + cairo_surface_create_similar( mpSurface.get(), aContent, width, height ), + &cairo_surface_destroy ), width, height)); + } + + /** + * Surface::Resize: Resizes the Canvas surface. + * @param width new width of the surface + * @param height new height of the surface + * + * Only used on X11. + * + * @return The new surface or NULL + **/ + void Gtk3Surface::Resize( int /*width*/, int /*height*/ ) + { + assert(false && "not supposed to be called!"); + } + + void Gtk3Surface::flush() const + { + cairo_surface_flush(mpSurface.get()); + } + + boost::shared_ptr<VirtualDevice> Gtk3Surface::createVirtualDevice() const + { + return boost::shared_ptr<VirtualDevice>(new VirtualDevice(NULL, Size(mnWidth, mnHeight), 0)); + } + SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice, int x, int y, int width, int height ) { - if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW ) - return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const vcl::Window&>(rRefDevice)), - x,y,width,height)); - else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV ) - return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const VirtualDevice&>(rRefDevice)), - x,y,width,height)); - else - return SurfaceSharedPtr(); + return SurfaceSharedPtr(new Gtk3Surface(rRefDevice, x, y, width, height)); } SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice, diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx index f040b9bc0ced..babebde8ab8a 100644 --- a/canvas/source/cairo/cairo_xlib_cairo.hxx +++ b/canvas/source/cairo/cairo_xlib_cairo.hxx @@ -97,6 +97,28 @@ namespace cairo { void* getRenderFormat() const { return maSysData.pRenderFormat; } long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; } }; + + class Gtk3Surface : public Surface + { + CairoSurfaceSharedPtr mpSurface; + int mnWidth; + int mnHeight; + public: + /// takes over ownership of passed cairo_surface + explicit Gtk3Surface(const CairoSurfaceSharedPtr& pSurface, int width, int height); + /// create surface on subarea of given drawable + explicit Gtk3Surface(const OutputDevice& rRefDevice, int x, int y, int width, int height); + + // Surface interface + virtual CairoSharedPtr getCairo() const SAL_OVERRIDE; + virtual CairoSurfaceSharedPtr getCairoSurface() const SAL_OVERRIDE { return mpSurface; } + virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const SAL_OVERRIDE; + + virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const SAL_OVERRIDE; + + virtual void Resize(int width, int height) SAL_OVERRIDE; + virtual void flush() const SAL_OVERRIDE; + }; } #endif diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 6e90d4577d2a..91dab6c308ad 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -235,6 +235,7 @@ class VCLXGraphics; class OutDevStateStack; typedef boost::intrusive_ptr< FontCharMap > FontCharMapPtr; +typedef struct _cairo cairo_t; namespace vcl { class FontInfo; @@ -378,6 +379,7 @@ public: SystemGraphicsData GetSystemGfxData() const; bool SupportsCairo() const; bool CanResizeCairoSurface() const; + cairo_t* GetCairoContext() const; css::uno::Any GetSystemGfxDataAny() const; void SetRefPoint(); diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index ea76cd3c3357..d43e725b8b8c 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -1219,6 +1219,11 @@ bool GenPspGraphics::CanResizeCairoSurface() const return false; } +cairo_t* GenPspGraphics::GetCairoContext() const +{ + return NULL; +} + SystemFontData GenPspGraphics::GetSysFontData( int /* nFallbacklevel */ ) const { return SystemFontData(); diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 3dee490cc7ff..de563063c631 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -743,4 +743,9 @@ bool SvpSalGraphics::CanResizeCairoSurface() const return false; } +cairo_t* SvpSalGraphics::GetCairoContext() const +{ + return NULL; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index e682e3a932bf..b4a683cc055c 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -203,6 +203,7 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; virtual bool CanResizeCairoSurface() const SAL_OVERRIDE; + virtual cairo_t* GetCairoContext() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 855dfff08d64..e4ff74d93ace 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -200,6 +200,7 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; + cairo_t* GetCairoContext() const SAL_OVERRIDE; virtual bool CanResizeCairoSurface() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 8ee3ccf9eb81..451c5823302a 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -420,6 +420,7 @@ public: GetGraphicsData() const SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; virtual bool CanResizeCairoSurface() const SAL_OVERRIDE; + virtual cairo_t* GetCairoContext() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE; virtual void BeginPaint() SAL_OVERRIDE { }; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 6d7d7871eb93..87971fd51013 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -441,6 +441,7 @@ public: /// Check whether cairo will work virtual bool SupportsCairo() const = 0; virtual bool CanResizeCairoSurface() const = 0; + virtual cairo_t* GetCairoContext() const = 0; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0; diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx index 2d002163a9d9..731b7f032bfa 100644 --- a/vcl/inc/unx/gtk/gtkgdi.hxx +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -50,13 +50,12 @@ public: Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ) SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; + virtual cairo_t* GetCairoContext() const SAL_OVERRIDE; void updateSettings( AllSettings& rSettings ); static void refreshFontconfig( GtkSettings *pSettings ); static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer ); - cairo_t* getCairoContext(); - void clipRegion(cairo_t* cr); private: diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 7f9bff69341f..74ba77d4d27b 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -263,6 +263,7 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; + virtual cairo_t* GetCairoContext() const SAL_OVERRIDE; virtual bool CanResizeCairoSurface() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 107140ba5cf1..a4800eabe2e0 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -447,6 +447,7 @@ public: virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual bool SupportsCairo() const SAL_OVERRIDE; virtual bool CanResizeCairoSurface() const SAL_OVERRIDE; + virtual cairo_t* GetCairoContext() const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; virtual void BeginPaint() SAL_OVERRIDE; diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index c2ec14b498bb..1ffa2282962a 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -319,6 +319,17 @@ bool OutputDevice::CanResizeCairoSurface() const return mpGraphics->CanResizeCairoSurface(); } +cairo_t* OutputDevice::GetCairoContext() const +{ + if (!mpGraphics) + { + if (!AcquireGraphics()) + return NULL; + } + + return mpGraphics->GetCairoContext(); +} + css::uno::Any OutputDevice::GetSystemGfxDataAny() const { const SystemGraphicsData aSysData = GetSystemGfxData(); diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 29366cabe76a..91bfa59520dc 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -467,6 +467,11 @@ bool X11SalGraphics::CanResizeCairoSurface() const return true; } +cairo_t* X11SalGraphics::GetCairoContext() const +{ + return NULL; +} + // draw a poly-polygon bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPolyPoly, double fTransparency ) { diff --git a/vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx b/vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx index f2f044e633af..032f20a39db0 100644 --- a/vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx +++ b/vcl/unx/gtk3/gdi/gtk3cairotextrender.cxx @@ -21,7 +21,7 @@ GlyphCache& GtkCairoTextRender::getPlatformGlyphCache() cairo_t* GtkCairoTextRender::getCairoContext() { - return mrParent.getCairoContext(); + return mrParent.GetCairoContext(); } void GtkCairoTextRender::getSurfaceOffset(double& nDX, double& nDY) diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx index 2554562e06eb..eaf56ea32849 100644 --- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx @@ -922,7 +922,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co return false; } - cairo_t *cr = getCairoContext(); + cairo_t *cr = GetCairoContext(); clipRegion(cr); cairo_translate(cr, rControlRegion.Left(), rControlRegion.Top()); @@ -1556,7 +1556,7 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) gtk_widget_path_free(path); } -cairo_t* GtkSalGraphics::getCairoContext() +cairo_t* GtkSalGraphics::GetCairoContext() const { return mpFrame->getCairoContext(); } |