summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-19 14:43:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-03-23 11:42:28 +0000
commite510a208b01c87a341b43d74d8d901f992379b84 (patch)
tree7f437b7d48e60ec14b0051993a9f2eb88f40bd53
parent2b838285e206912374f464bd1ab8dc8a561f59f5 (diff)
move cairo helpers to vcl and make per-plug
Change-Id: I4de4d5c3a191784598e93a8cf70e45a3f59ae857 Reviewed-on: https://gerrit.libreoffice.org/14907 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--canvas/Library_cairocanvas.mk32
-rw-r--r--canvas/source/cairo/cairo_cachedbitmap.hxx2
-rw-r--r--canvas/source/cairo/cairo_canvas.cxx2
-rw-r--r--canvas/source/cairo/cairo_canvas.hxx2
-rw-r--r--canvas/source/cairo/cairo_canvasbitmap.cxx65
-rw-r--r--canvas/source/cairo/cairo_canvasbitmap.hxx3
-rw-r--r--canvas/source/cairo/cairo_canvascustomsprite.cxx2
-rw-r--r--canvas/source/cairo/cairo_canvascustomsprite.hxx5
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx42
-rw-r--r--canvas/source/cairo/cairo_canvashelper.hxx6
-rw-r--r--canvas/source/cairo/cairo_devicehelper.cxx20
-rw-r--r--canvas/source/cairo/cairo_devicehelper.hxx3
-rw-r--r--canvas/source/cairo/cairo_repainttarget.hxx2
-rw-r--r--canvas/source/cairo/cairo_sprite.hxx2
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.cxx2
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.hxx2
-rw-r--r--canvas/source/cairo/cairo_spritecanvashelper.hxx2
-rw-r--r--canvas/source/cairo/cairo_spritedevicehelper.cxx11
-rw-r--r--canvas/source/cairo/cairo_spritedevicehelper.hxx4
-rw-r--r--canvas/source/cairo/cairo_surfaceprovider.hxx5
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx2
-rw-r--r--canvas/source/cairo/cairo_textlayout.hxx2
-rw-r--r--config_host/config_cairo_canvas.h.in6
-rw-r--r--configure.ac2
-rw-r--r--include/vcl/cairo.hxx (renamed from canvas/source/cairo/cairo_cairo.hxx)38
-rw-r--r--include/vcl/outdev.hxx12
-rw-r--r--vcl/Library_vcl.mk3
-rw-r--r--vcl/Library_vclplug_gen.mk1
-rw-r--r--vcl/generic/print/genpspgraphics.cxx20
-rw-r--r--vcl/headless/svpgdi.cxx20
-rw-r--r--vcl/inc/cairo_cairo.hxx36
-rw-r--r--vcl/inc/generic/genpspgraphics.h4
-rw-r--r--vcl/inc/headless/svpgdi.hxx4
-rw-r--r--vcl/inc/quartz/salgdi.h4
-rw-r--r--vcl/inc/salgdi.hxx7
-rw-r--r--vcl/inc/unx/salgdi.h4
-rw-r--r--vcl/inc/win/salgdi.h4
-rw-r--r--vcl/quartz/cairo_quartz_cairo.cxx (renamed from canvas/source/cairo/cairo_quartz_cairo.cxx)81
-rw-r--r--vcl/quartz/cairo_quartz_cairo.hxx (renamed from canvas/source/cairo/cairo_quartz_cairo.hxx)0
-rw-r--r--vcl/quartz/salgdicommon.cxx113
-rw-r--r--vcl/source/outdev/outdev.cxx46
-rw-r--r--vcl/source/window/cairo_cairo.cxx (renamed from canvas/source/cairo/cairo_cairo.cxx)7
-rw-r--r--vcl/unx/generic/gdi/cairo_xlib_cairo.cxx (renamed from canvas/source/cairo/cairo_xlib_cairo.cxx)65
-rw-r--r--vcl/unx/generic/gdi/cairo_xlib_cairo.hxx (renamed from canvas/source/cairo/cairo_xlib_cairo.hxx)5
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx70
-rw-r--r--vcl/win/source/gdi/cairo_win32_cairo.cxx (renamed from canvas/source/cairo/cairo_win32_cairo.cxx)81
-rw-r--r--vcl/win/source/gdi/cairo_win32_cairo.hxx (renamed from canvas/source/cairo/cairo_win32_cairo.hxx)2
-rw-r--r--vcl/win/source/gdi/salgdi.cxx134
48 files changed, 584 insertions, 403 deletions
diff --git a/canvas/Library_cairocanvas.mk b/canvas/Library_cairocanvas.mk
index 72d1b8d3a5ca..f786fe17ce59 100644
--- a/canvas/Library_cairocanvas.mk
+++ b/canvas/Library_cairocanvas.mk
@@ -47,7 +47,6 @@ $(eval $(call gb_Library_use_libraries,cairocanvas,\
$(eval $(call gb_Library_add_exception_objects,cairocanvas,\
canvas/source/cairo/cairo_cachedbitmap \
- canvas/source/cairo/cairo_cairo \
canvas/source/cairo/cairo_canvas \
canvas/source/cairo/cairo_canvasbitmap \
canvas/source/cairo/cairo_canvascustomsprite \
@@ -68,35 +67,4 @@ $(eval $(call gb_Library_use_externals,cairocanvas,\
cairo \
))
-ifeq ($(OS),WNT)
-
-$(eval $(call gb_Library_add_exception_objects,cairocanvas,\
- canvas/source/cairo/cairo_win32_cairo \
-))
-$(eval $(call gb_Library_use_libraries,cairocanvas,\
- gdi32 \
-))
-
-else
-
-ifneq (,$(filter MACOSX IOS,$(OS)))
-$(eval $(call gb_Library_add_exception_objects,cairocanvas,\
- canvas/source/cairo/cairo_quartz_cairo \
-))
-else ifeq ($(GUIBASE),unx)
-$(eval $(call gb_Library_add_exception_objects,cairocanvas,\
- canvas/source/cairo/cairo_xlib_cairo \
-))
-
-# freetype? fontconfig? -> test on Solaris
-$(eval $(call gb_Library_add_libs,cairocanvas,\
- -lX11 \
-))
-$(eval $(call gb_Library_use_externals,cairocanvas,\
- Xrender \
-))
-endif
-
-endif
-
# vim: set noet sw=4 ts=4:
diff --git a/canvas/source/cairo/cairo_cachedbitmap.hxx b/canvas/source/cairo/cairo_cachedbitmap.hxx
index 3bb293982cd0..6ca25b7dfc3f 100644
--- a/canvas/source/cairo/cairo_cachedbitmap.hxx
+++ b/canvas/source/cairo/cairo_cachedbitmap.hxx
@@ -22,7 +22,7 @@
#include <canvas/base/cachedprimitivebase.hxx>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
/* Definition of CachedBitmap class */
diff --git a/canvas/source/cairo/cairo_canvas.cxx b/canvas/source/cairo/cairo_canvas.cxx
index 58bd7f0a030f..c494e91020fb 100644
--- a/canvas/source/cairo/cairo_canvas.cxx
+++ b/canvas/source/cairo/cairo_canvas.cxx
@@ -138,7 +138,7 @@ namespace cairocanvas
return maDeviceHelper.getSurface();
}
- SurfaceSharedPtr Canvas::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr Canvas::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
return maDeviceHelper.createSurface( rSize, aContent );
}
diff --git a/canvas/source/cairo/cairo_canvas.hxx b/canvas/source/cairo/cairo_canvas.hxx
index 8c5884add427..d3e342ea7747 100644
--- a/canvas/source/cairo/cairo_canvas.hxx
+++ b/canvas/source/cairo/cairo_canvas.hxx
@@ -135,7 +135,7 @@ namespace cairocanvas
// SurfaceProvider
virtual ::cairo::SurfaceSharedPtr getSurface() SAL_OVERRIDE;
- virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
+ virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ) SAL_OVERRIDE;
virtual OutputDevice* getOutputDevice() SAL_OVERRIDE;
diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx
index 405f9bc7dd1a..22ca7fdfa932 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -27,46 +27,9 @@
#include <vcl/bmpacc.hxx>
#include <vcl/bitmapex.hxx>
-#ifdef CAIRO_HAS_XLIB_SURFACE
-# include "cairo_xlib_cairo.hxx"
-#elif defined CAIRO_HAS_QUARTZ_SURFACE
-# include "cairo_quartz_cairo.hxx"
-#elif defined CAIRO_HAS_WIN32_SURFACE
-# include "cairo_win32_cairo.hxx"
-# include <cairo-win32.h>
-#else
-# error Native API needed.
-#endif
-
using namespace ::cairo;
using namespace ::com::sun::star;
-#ifdef CAIRO_HAS_WIN32_SURFACE
-namespace
-{
- HBITMAP surface2HBitmap( const SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize )
- {
- // can't seem to retrieve HBITMAP from cairo. copy content then
- HDC hScreenDC=GetDC(NULL);
- HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
- rSize.getX(),
- rSize.getY() );
-
- HDC hBmpDC = CreateCompatibleDC( 0 );
- HBITMAP hBmpOld = (HBITMAP) SelectObject( hBmpDC, hBmpBitmap );
-
- BitBlt( hBmpDC, 0, 0, rSize.getX(), rSize.getX(),
- cairo_win32_surface_get_dc(rSurface->getCairoSurface().get()),
- 0, 0, SRCCOPY );
-
- SelectObject( hBmpDC, hBmpOld );
- DeleteDC( hBmpDC );
-
- return hBmpBitmap;
- }
-}
-#endif
-
namespace cairocanvas
{
CanvasBitmap::CanvasBitmap( const ::basegfx::B2ISize& rSize,
@@ -112,7 +75,7 @@ namespace cairocanvas
return mpBufferSurface;
}
- SurfaceSharedPtr CanvasBitmap::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr CanvasBitmap::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
return mpSurfaceProvider->createSurface(rSize,aContent);
}
@@ -222,31 +185,7 @@ namespace cairocanvas
}
case 1:
{
-#ifdef CAIRO_HAS_XLIB_SURFACE
- X11Surface& rXlibSurface=dynamic_cast<X11Surface&>(*mpBufferSurface.get());
- uno::Sequence< uno::Any > args( 3 );
- args[0] = uno::Any( false ); // do not call XFreePixmap on it
- args[1] = uno::Any( rXlibSurface.getPixmap()->mhDrawable );
- args[2] = uno::Any( sal_Int32( rXlibSurface.getDepth() ) );
-
- aRV = uno::Any( args );
-#elif defined CAIRO_HAS_QUARTZ_SURFACE
- QuartzSurface* pQuartzSurface = dynamic_cast<QuartzSurface*>(mpBufferSurface.get());
- OSL_ASSERT(pQuartzSurface);
- uno::Sequence< uno::Any > args( 1 );
- args[0] = uno::Any( sal_IntPtr (pQuartzSurface->getCGContext()) );
- aRV = uno::Any( args );
-#elif defined CAIRO_HAS_WIN32_SURFACE
- // TODO(F2): check whether under all circumstances,
- // the alpha channel is ignored here.
- uno::Sequence< uno::Any > args( 1 );
- args[1] = uno::Any( sal_Int64(surface2HBitmap(mpBufferSurface,maSize)) );
-
- aRV = uno::Any( args );
- // caller frees the bitmap
-#else
-# error Please define fast prop retrieval for your platform!
-#endif
+ aRV = getOutputDevice()->GetNativeSurfaceHandle(mpBufferSurface, maSize);
break;
}
case 2:
diff --git a/canvas/source/cairo/cairo_canvasbitmap.hxx b/canvas/source/cairo/cairo_canvasbitmap.hxx
index ae9b3472d094..bf1299f67592 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.hxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.hxx
@@ -35,7 +35,6 @@
#include <canvas/base/basemutexhelper.hxx>
#include <canvas/base/integerbitmapbase.hxx>
-#include "cairo_cairo.hxx"
#include "cairo_canvashelper.hxx"
#include "cairo_repainttarget.hxx"
#include "cairo_spritecanvas.hxx"
@@ -96,7 +95,7 @@ namespace cairocanvas
// SurfaceProvider
virtual ::cairo::SurfaceSharedPtr getSurface() SAL_OVERRIDE;
- virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
+ virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ) SAL_OVERRIDE;
virtual OutputDevice* getOutputDevice() SAL_OVERRIDE;
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.cxx b/canvas/source/cairo/cairo_canvascustomsprite.cxx
index 743d31610266..bba604521eb9 100644
--- a/canvas/source/cairo/cairo_canvascustomsprite.cxx
+++ b/canvas/source/cairo/cairo_canvascustomsprite.cxx
@@ -109,7 +109,7 @@ namespace cairocanvas
return mpBufferSurface;
}
- SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
return mpSpriteCanvas->createSurface(rSize,aContent);
}
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.hxx b/canvas/source/cairo/cairo_canvascustomsprite.hxx
index 31bf4eabd95a..f4be338428aa 100644
--- a/canvas/source/cairo/cairo_canvascustomsprite.hxx
+++ b/canvas/source/cairo/cairo_canvascustomsprite.hxx
@@ -36,8 +36,9 @@
#include <canvas/base/basemutexhelper.hxx>
#include <canvas/base/canvascustomspritebase.hxx>
+#include <vcl/cairo.hxx>
+
#include "cairo_sprite.hxx"
-#include "cairo_cairo.hxx"
#include "cairo_canvashelper.hxx"
#include "cairo_repainttarget.hxx"
#include "cairo_spritehelper.hxx"
@@ -130,7 +131,7 @@ namespace cairocanvas
// SurfaceProvider
virtual ::cairo::SurfaceSharedPtr getSurface() SAL_OVERRIDE;
- virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
+ virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ) SAL_OVERRIDE;
virtual OutputDevice* getOutputDevice() SAL_OVERRIDE;
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index c0034319aa28..d86b72913a5b 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -110,7 +110,7 @@ namespace cairocanvas
mpCairo = pSurface->getCairo();
}
- static void setColor( Cairo* pCairo,
+ static void setColor( cairo_t* pCairo,
const uno::Sequence<double>& rColor )
{
if( rColor.getLength() > 3 )
@@ -132,9 +132,9 @@ namespace cairocanvas
const rendering::RenderState& renderState,
bool bSetColor )
{
- Matrix aViewMatrix;
- Matrix aRenderMatrix;
- Matrix aCombinedMatrix;
+ cairo_matrix_t aViewMatrix;
+ cairo_matrix_t aRenderMatrix;
+ cairo_matrix_t aCombinedMatrix;
cairo_matrix_init( &aViewMatrix,
viewState.AffineTransform.m00, viewState.AffineTransform.m10, viewState.AffineTransform.m01,
@@ -643,7 +643,7 @@ namespace cairocanvas
if( pAlphaReadAcc )
aAlpha.ReleaseAccess( pAlphaReadAcc );
- SurfaceSharedPtr pImageSurface = createSurface(
+ SurfaceSharedPtr pImageSurface = rSurfaceProvider->getOutputDevice()->CreateSurface(
CairoSurfaceSharedPtr(
cairo_image_surface_create_for_data(
data,
@@ -661,7 +661,7 @@ namespace cairocanvas
return pSurface;
}
- static void addColorStops( Pattern* pPattern, const uno::Sequence< uno::Sequence< double > >& rColors, const uno::Sequence< double >& rStops, bool bReverseStops = false )
+ static void addColorStops( cairo_pattern_t* pPattern, const uno::Sequence< uno::Sequence< double > >& rColors, const uno::Sequence< double >& rStops, bool bReverseStops = false )
{
int i;
@@ -705,9 +705,9 @@ namespace cairocanvas
return uno::Sequence<double>();
}
- static Pattern* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon& rPolygon )
+ static cairo_pattern_t* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon& rPolygon )
{
- Pattern* pPattern = NULL;
+ cairo_pattern_t* pPattern = NULL;
const ::canvas::ParametricPolyPolygon::Values aValues = rPolygon.getValues();
double x0, x1, y0, y1, cx, cy, r0, r1;
@@ -739,7 +739,7 @@ namespace cairocanvas
}
static void doOperation( Operation aOperation,
- Cairo* pCairo,
+ cairo_t* pCairo,
const uno::Sequence< rendering::Texture >* pTextures,
const SurfaceProviderRef& pDevice,
const basegfx::B2DRange& rBounds )
@@ -764,7 +764,7 @@ namespace cairocanvas
cairo_save( pCairo );
::com::sun::star::geometry::AffineMatrix2D aTransform( aTexture.AffineTransform );
- Matrix aScaleMatrix, aTextureMatrix, aScaledTextureMatrix;
+ cairo_matrix_t aScaleMatrix, aTextureMatrix, aScaledTextureMatrix;
cairo_matrix_init( &aTextureMatrix,
aTransform.m00, aTransform.m10, aTransform.m01,
@@ -827,7 +827,7 @@ namespace cairocanvas
::canvas::ParametricPolyPolygon* pPolyImpl = static_cast< ::canvas::ParametricPolyPolygon* >( aTexture.Gradient.get() );
::com::sun::star::geometry::AffineMatrix2D aTransform( aTexture.AffineTransform );
- Matrix aTextureMatrix;
+ cairo_matrix_t aTextureMatrix;
cairo_matrix_init( &aTextureMatrix,
aTransform.m00, aTransform.m10, aTransform.m01,
@@ -882,7 +882,7 @@ namespace cairocanvas
}
else
{
- Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
+ cairo_pattern_t* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
if( pPattern )
{
@@ -916,10 +916,10 @@ namespace cairocanvas
}
}
- static void clipNULL( Cairo *pCairo )
+ static void clipNULL( cairo_t *pCairo )
{
SAL_INFO( "canvas.cairo", "clipNULL");
- Matrix aOrigMatrix, aIdentityMatrix;
+ cairo_matrix_t aOrigMatrix, aIdentityMatrix;
/* we set identity matrix here to overcome bug in cairo 0.9.2
where XCreatePixmap is called with zero width and height.
@@ -942,7 +942,7 @@ namespace cairocanvas
void doPolyPolygonImplementation( ::basegfx::B2DPolyPolygon aPolyPolygon,
Operation aOperation,
- Cairo* pCairo,
+ cairo_t* pCairo,
const uno::Sequence< rendering::Texture >* pTextures,
const SurfaceProviderRef& pDevice,
rendering::FillRule eFillrule )
@@ -952,7 +952,7 @@ namespace cairocanvas
"CanvasHelper::fillTexturedPolyPolygon: empty texture sequence");
bool bOpToDo = false;
- Matrix aOrigMatrix, aIdentityMatrix;
+ cairo_matrix_t aOrigMatrix, aIdentityMatrix;
double nX, nY, nBX, nBY, nAX, nAY;
cairo_get_matrix( pCairo, &aOrigMatrix );
@@ -1073,7 +1073,7 @@ namespace cairocanvas
Operation aOperation,
bool bNoLineJoin,
const uno::Sequence< rendering::Texture >* pTextures,
- Cairo* pCairo ) const
+ cairo_t* pCairo ) const
{
const ::basegfx::B2DPolyPolygon& rPolyPoly(
::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon) );
@@ -1172,7 +1172,7 @@ namespace cairocanvas
useStates( viewState, renderState, true );
- Matrix aMatrix;
+ cairo_matrix_t aMatrix;
double w = strokeAttributes.StrokeWidth, h = 0;
cairo_get_matrix( mpCairo.get(), &aMatrix );
cairo_matrix_transform_distance( &aMatrix, &w, &h );
@@ -1351,7 +1351,7 @@ namespace cairocanvas
useStates( viewState, renderState, true );
- Matrix aMatrix;
+ cairo_matrix_t aMatrix;
cairo_get_matrix( mpCairo.get(), &aMatrix );
if( ! ::rtl::math::approxEqual( aMatrix.xx, 1 ) &&
@@ -1552,7 +1552,7 @@ namespace cairocanvas
{
const sal_Int32 nWidth( rect.X2 - rect.X1 );
const sal_Int32 nHeight( rect.Y2 - rect.Y1 );
- const Format eFormat( mbHaveAlpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24 );
+ const cairo_format_t eFormat( mbHaveAlpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24 );
uno::Sequence< sal_Int8 > aRes( 4*nWidth*nHeight );
sal_Int8* pData = aRes.getArray();
cairo_surface_t* pImageSurface = cairo_image_surface_create_for_data( reinterpret_cast<unsigned char *>(pData),
@@ -2294,7 +2294,7 @@ namespace cairocanvas
useStates( viewState, renderState, true );
- Matrix aMatrix;
+ cairo_matrix_t aMatrix;
cairo_get_matrix( mpCairo.get(), &aMatrix );
aMatrix.xx = aMatrix.yy = 1;
diff --git a/canvas/source/cairo/cairo_canvashelper.hxx b/canvas/source/cairo/cairo_canvashelper.hxx
index a2282bcbbac5..b67904d6ebf5 100644
--- a/canvas/source/cairo/cairo_canvashelper.hxx
+++ b/canvas/source/cairo/cairo_canvashelper.hxx
@@ -30,7 +30,7 @@
#include <boost/utility.hpp>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
#include "cairo_surfaceprovider.hxx"
class VirtualDevice;
@@ -236,7 +236,7 @@ namespace cairocanvas
Operation aOperation,
bool bNoLineJoin = false,
const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL,
- ::cairo::Cairo* pCairo=NULL ) const;
+ cairo_t* pCairo=NULL ) const;
::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > implDrawBitmapSurface(
const ::com::sun::star::rendering::XCanvas* pCanvas,
@@ -291,7 +291,7 @@ namespace cairocanvas
/// also needed from SpriteHelper
void doPolyPolygonImplementation( ::basegfx::B2DPolyPolygon aPolyPolygon,
Operation aOperation,
- ::cairo::Cairo* pCairo,
+ cairo_t* pCairo,
const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures,
const SurfaceProviderRef& pDevice,
::com::sun::star::rendering::FillRule eFillrule );
diff --git a/canvas/source/cairo/cairo_devicehelper.cxx b/canvas/source/cairo/cairo_devicehelper.cxx
index c5296b733277..9e7ba2e13ca5 100644
--- a/canvas/source/cairo/cairo_devicehelper.cxx
+++ b/canvas/source/cairo/cairo_devicehelper.cxx
@@ -65,12 +65,11 @@ namespace cairocanvas
{
implInit(rSurfaceProvider, rRefDevice);
- OutputDevice* pOutDev=getOutputDevice();
- mpSurface = cairo::createSurface( *pOutDev,
- pOutDev->GetOutOffXPixel(),
- pOutDev->GetOutOffYPixel(),
- pOutDev->GetOutputWidthPixel(),
- pOutDev->GetOutputHeightPixel() );
+ OutputDevice* pOutDev = getOutputDevice();
+ mpSurface = pOutDev->CreateSurface(pOutDev->GetOutOffXPixel(),
+ pOutDev->GetOutOffYPixel(),
+ pOutDev->GetOutputWidthPixel(),
+ pOutDev->GetOutputHeightPixel());
}
void DeviceHelper::disposing()
@@ -99,8 +98,7 @@ namespace cairocanvas
if (!bReuseSurface)
{
- mpSurface = cairo::createSurface(
- *pOutDev,
+ mpSurface = pOutDev->CreateSurface(
pOutDev->GetOutOffXPixel(),
pOutDev->GetOutOffYPixel(),
rSize.getX(), rSize.getY() );
@@ -260,7 +258,7 @@ namespace cairocanvas
}
}
- SurfaceSharedPtr DeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr DeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
if( mpSurface )
return mpSurface->getSimilar( aContent, rSize.getX(), rSize.getY() );
@@ -270,8 +268,8 @@ namespace cairocanvas
SurfaceSharedPtr DeviceHelper::createSurface( BitmapSystemData& rData, const Size& rSize )
{
- if( mpRefDevice )
- return createBitmapSurface( *mpRefDevice, rData, rSize );
+ if (mpRefDevice)
+ return mpRefDevice->CreateBitmapSurface(rData, rSize);
return SurfaceSharedPtr();
}
diff --git a/canvas/source/cairo/cairo_devicehelper.hxx b/canvas/source/cairo/cairo_devicehelper.hxx
index d5a6ca3077bc..81f71810d61d 100644
--- a/canvas/source/cairo/cairo_devicehelper.hxx
+++ b/canvas/source/cairo/cairo_devicehelper.hxx
@@ -29,7 +29,6 @@
#include <vcl/window.hxx>
#include <vcl/bitmap.hxx>
-#include "cairo_cairo.hxx"
#include "cairo_surfaceprovider.hxx"
/* Definition of DeviceHelper class */
@@ -91,7 +90,7 @@ namespace cairocanvas
OutputDevice* getOutputDevice() const { return mpRefDevice; }
::cairo::SurfaceSharedPtr getSurface() { return mpSurface; }
- ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
+ ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA );
::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize );
protected:
diff --git a/canvas/source/cairo/cairo_repainttarget.hxx b/canvas/source/cairo/cairo_repainttarget.hxx
index 7955b5ddded7..0a2bf9dd8fdf 100644
--- a/canvas/source/cairo/cairo_repainttarget.hxx
+++ b/canvas/source/cairo/cairo_repainttarget.hxx
@@ -22,7 +22,7 @@
#include <rtl/ref.hxx>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
namespace cairocanvas
{
diff --git a/canvas/source/cairo/cairo_sprite.hxx b/canvas/source/cairo/cairo_sprite.hxx
index d2171db3dac6..e5ea93d0ce05 100644
--- a/canvas/source/cairo/cairo_sprite.hxx
+++ b/canvas/source/cairo/cairo_sprite.hxx
@@ -22,7 +22,7 @@
#include <canvas/base/sprite.hxx>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
namespace cairocanvas
{
diff --git a/canvas/source/cairo/cairo_spritecanvas.cxx b/canvas/source/cairo/cairo_spritecanvas.cxx
index 4e7be178cca0..40c37d1ca104 100644
--- a/canvas/source/cairo/cairo_spritecanvas.cxx
+++ b/canvas/source/cairo/cairo_spritecanvas.cxx
@@ -151,7 +151,7 @@ namespace cairocanvas
return maDeviceHelper.getBufferSurface();
}
- SurfaceSharedPtr SpriteCanvas::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr SpriteCanvas::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
return maDeviceHelper.createSurface( rSize, aContent );
}
diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx
index 72583137c2c6..ae419c700a69 100644
--- a/canvas/source/cairo/cairo_spritecanvas.hxx
+++ b/canvas/source/cairo/cairo_spritecanvas.hxx
@@ -134,7 +134,7 @@ namespace cairocanvas
// SurfaceProvider
virtual ::cairo::SurfaceSharedPtr getSurface() SAL_OVERRIDE;
- virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
+ virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) SAL_OVERRIDE;
virtual ::cairo::SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ) SAL_OVERRIDE;
virtual OutputDevice* getOutputDevice() SAL_OVERRIDE;
diff --git a/canvas/source/cairo/cairo_spritecanvashelper.hxx b/canvas/source/cairo/cairo_spritecanvashelper.hxx
index 0f68bfc6f6b7..11b13510338d 100644
--- a/canvas/source/cairo/cairo_spritecanvashelper.hxx
+++ b/canvas/source/cairo/cairo_spritecanvashelper.hxx
@@ -25,7 +25,7 @@
#include <canvas/spriteredrawmanager.hxx>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
#include "cairo_canvashelper.hxx"
namespace basegfx
diff --git a/canvas/source/cairo/cairo_spritedevicehelper.cxx b/canvas/source/cairo/cairo_spritedevicehelper.cxx
index 523354809493..6f7730b2ee14 100644
--- a/canvas/source/cairo/cairo_spritedevicehelper.cxx
+++ b/canvas/source/cairo/cairo_spritedevicehelper.cxx
@@ -31,12 +31,12 @@
#include <basegfx/tools/unopolypolygon.hxx>
#include <vcl/syschild.hxx>
+#include <vcl/cairo.hxx>
#include <vcl/canvastools.hxx>
#include "cairo_spritecanvas.hxx"
#include "cairo_canvasbitmap.hxx"
#include "cairo_devicehelper.hxx"
-#include "cairo_cairo.hxx"
using namespace ::cairo;
using namespace ::com::sun::star;
@@ -134,7 +134,7 @@ namespace cairocanvas
return DeviceHelper::getSurface();
}
- SurfaceSharedPtr SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
+ SurfaceSharedPtr SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
{
if( mpBufferSurface )
return mpBufferSurface->getSimilar( aContent, rSize.getX(), rSize.getY() );
@@ -144,13 +144,12 @@ namespace cairocanvas
SurfaceSharedPtr SpriteDeviceHelper::createSurface( BitmapSystemData& rData, const Size& rSize )
{
- if( getOutputDevice() )
- return createBitmapSurface( *getOutputDevice(), rData, rSize );
-
+ OutputDevice *pDevice = getOutputDevice();
+ if (pDevice)
+ return pDevice->CreateBitmapSurface(rData, rSize);
return SurfaceSharedPtr();
}
-
/** SpriteDeviceHelper::flush Flush the platform native window
*
* Flushes the window by using the internally stored mpSysData.
diff --git a/canvas/source/cairo/cairo_spritedevicehelper.hxx b/canvas/source/cairo/cairo_spritedevicehelper.hxx
index 7f0495bc323d..0f586c5e546e 100644
--- a/canvas/source/cairo/cairo_spritedevicehelper.hxx
+++ b/canvas/source/cairo/cairo_spritedevicehelper.hxx
@@ -28,8 +28,8 @@
#include <vcl/window.hxx>
#include <vcl/bitmap.hxx>
+#include <vcl/cairo.hxx>
-#include "cairo_cairo.hxx"
#include "cairo_devicehelper.hxx"
/* Definition of DeviceHelper class */
@@ -64,7 +64,7 @@ namespace cairocanvas
::cairo::SurfaceSharedPtr getBufferSurface() { return mpBufferSurface; }
::cairo::SurfaceSharedPtr getWindowSurface();
- ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
+ ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA );
::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize );
const ::basegfx::B2ISize& getSizePixel() { return maSize; }
void flush();
diff --git a/canvas/source/cairo/cairo_surfaceprovider.hxx b/canvas/source/cairo/cairo_surfaceprovider.hxx
index 0521b2cc0e0f..9dea2a1dc19a 100644
--- a/canvas/source/cairo/cairo_surfaceprovider.hxx
+++ b/canvas/source/cairo/cairo_surfaceprovider.hxx
@@ -23,7 +23,8 @@
#include <rtl/ref.hxx>
#include <com/sun/star/uno/XInterface.hpp>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
+#include <cairo.h>
class OutputDevice;
class Bitmap;
@@ -52,7 +53,7 @@ namespace cairocanvas
/// create new surface in given size
virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize,
- ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ) = 0;
+ int aContent = CAIRO_CONTENT_COLOR_ALPHA ) = 0;
/// create new surface from given bitmap
virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) = 0;
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 936593acf760..008a7d71be85 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -46,7 +46,7 @@
#include "cairo_spritecanvas.hxx"
#ifdef CAIRO_HAS_QUARTZ_SURFACE
-# include "cairo_quartz_cairo.hxx"
+#include <cairo-quartz.h>
#elif defined CAIRO_HAS_WIN32_SURFACE
# include "cairo_win32_cairo.hxx"
# include <cairo-win32.h>
diff --git a/canvas/source/cairo/cairo_textlayout.hxx b/canvas/source/cairo/cairo_textlayout.hxx
index 25296fcad90f..80bfe850b6b7 100644
--- a/canvas/source/cairo/cairo_textlayout.hxx
+++ b/canvas/source/cairo/cairo_textlayout.hxx
@@ -32,7 +32,7 @@
#include <boost/utility.hpp>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
#include "cairo_canvasfont.hxx"
diff --git a/config_host/config_cairo_canvas.h.in b/config_host/config_cairo_canvas.h.in
new file mode 100644
index 000000000000..0c3817533f61
--- /dev/null
+++ b/config_host/config_cairo_canvas.h.in
@@ -0,0 +1,6 @@
+#ifndef CONFIG_CAIRO_CANVAS_H
+#define CONFIG_CAIRO_CANVAS_H
+
+#define ENABLE_CAIRO_CANVAS 0
+
+#endif
diff --git a/configure.ac b/configure.ac
index 69688b5b6d6b..11b942c621ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10171,6 +10171,7 @@ ENABLE_CAIRO_CANVAS=""
if test "$enable_cairo_canvas" = "yes"; then
test_cairo=yes
ENABLE_CAIRO_CANVAS="TRUE"
+ AC_DEFINE(ENABLE_CAIRO_CANVAS)
fi
AC_SUBST(ENABLE_CAIRO_CANVAS)
@@ -12911,6 +12912,7 @@ AC_CONFIG_FILES([config_host.mk
AC_CONFIG_HEADERS([config_host/config_buildid.h])
AC_CONFIG_HEADERS([config_host/config_clang.h])
AC_CONFIG_HEADERS([config_host/config_eot.h])
+AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
AC_CONFIG_HEADERS([config_host/config_cups.h])
AC_CONFIG_HEADERS([config_host/config_features.h])
AC_CONFIG_HEADERS([config_host/config_folders.h])
diff --git a/canvas/source/cairo/cairo_cairo.hxx b/include/vcl/cairo.hxx
index e256610a54d4..c8cc23e802b3 100644
--- a/canvas/source/cairo/cairo_cairo.hxx
+++ b/include/vcl/cairo.hxx
@@ -17,33 +17,21 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CAIRO_HXX
-#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CAIRO_HXX
+#ifndef INCLUDED_VCL_CAIRO_HXX
+#define INCLUDED_VCL_CAIRO_HXX
#include <sal/config.h>
#include <boost/shared_ptr.hpp>
-struct SystemEnvData;
-struct BitmapSystemData;
-struct SystemGraphicsData;
-class VirtualDevice;
-class OutputDevice;
-namespace vcl { class Window; }
-class Size;
+typedef struct _cairo_surface cairo_surface_t;
+typedef struct _cairo cairo_t;
-#include <cairo.h>
+class VirtualDevice;
namespace cairo {
- typedef cairo_t Cairo;
- typedef cairo_matrix_t Matrix;
- typedef cairo_format_t Format;
- typedef cairo_content_t Content;
- typedef cairo_pattern_t Pattern;
typedef boost::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr;
- typedef boost::shared_ptr<Cairo> CairoSharedPtr;
-
- const SystemEnvData* GetSysData(const vcl::Window *pOutputWindow);
+ typedef boost::shared_ptr<cairo_t> CairoSharedPtr;
/** Cairo surface interface
@@ -58,13 +46,13 @@ namespace cairo {
// Query methods
virtual CairoSharedPtr getCairo() const = 0;
virtual CairoSurfaceSharedPtr getCairoSurface() const = 0;
- virtual boost::shared_ptr<Surface> getSimilar( Content aContent, int width, int height ) const = 0;
+ virtual boost::shared_ptr<Surface> getSimilar(int cairo_content_type, int width, int height) const = 0;
/// factory for VirDev on this surface
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const = 0;
/// Resize the surface (possibly destroying content), only possible for X11 typically
- /// so on failure create a new surface instead
+ /// so on failure caller must create a new surface instead
virtual bool Resize( int /*width*/, int /*height*/ ) { return false; }
/// Flush all pending output to surface
@@ -72,16 +60,6 @@ namespace cairo {
};
typedef boost::shared_ptr<Surface> SurfaceSharedPtr;
-
- /// Create Surface from given cairo surface
- SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface );
- /// Create surface with given dimensions
- SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
- int x, int y, int width, int height );
- /// Create Surface for given bitmap data
- SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
- const BitmapSystemData& rData,
- const Size& rSize );
}
#endif
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c3adbbff7bfc..7911b662b285 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -26,6 +26,7 @@
#include <tools/color.hxx>
#include <tools/poly.hxx>
+#include <vcl/cairo.hxx>
#include <vcl/devicecoordinate.hxx>
#include <vcl/dllapi.h>
#include <vcl/font.hxx>
@@ -120,6 +121,8 @@ namespace basegfx {
class B2DHomMatrix;
class B2DPolygon;
class B2DPolyPolygon;
+ class B2IVector;
+ typedef B2IVector B2ISize;
}
namespace com {
@@ -233,6 +236,7 @@ class FontSelectPattern;
class ImplFontMetricData;
class VCLXGraphics;
class OutDevStateStack;
+struct BitmapSystemData;
typedef boost::intrusive_ptr< FontCharMap > FontCharMapPtr;
@@ -377,6 +381,14 @@ public:
SystemGraphicsData GetSystemGfxData() const;
bool SupportsCairo() const;
+ /// Create Surface from given cairo surface
+ cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const;
+ /// Create surface with given dimensions
+ cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const;
+ /// Create Surface for given bitmap data
+ cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const;
+ /// Return native handle for underlying surface
+ css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const;
css::uno::Any GetSystemGfxDataAny() const;
void SetRefPoint();
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 701766473404..4eaca9a3ad64 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -135,6 +135,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/opengl/texture \
vcl/source/opengl/OpenGLContext \
vcl/source/opengl/OpenGLHelper \
+ vcl/source/window/cairo_cairo \
vcl/source/window/openglwin \
vcl/source/window/settings \
vcl/source/window/paint \
@@ -496,6 +497,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/osx/PictToBmpFlt \
vcl/osx/clipboard \
vcl/osx/service_entry \
+ vcl/quartz/cairo_quartz_cairo \
$(vcl_quartz_code) \
vcl/quartz/salgdiutils \
vcl/osx/salnativewidgets \
@@ -665,6 +667,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/win/source/app/salinst \
vcl/win/source/app/salshl \
vcl/win/source/app/saltimer \
+ vcl/win/source/gdi/cairo_win32_cairo \
vcl/win/source/gdi/gdiimpl \
vcl/win/source/gdi/salbmp \
vcl/win/source/gdi/salgdi \
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 56135af18f78..79bd353cea57 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/unx/generic/dtrans/X11_selection \
vcl/unx/generic/dtrans/X11_service \
vcl/unx/generic/dtrans/X11_transferable \
+ vcl/unx/generic/gdi/cairo_xlib_cairo \
vcl/unx/generic/gdi/x11cairotextrender \
vcl/unx/generic/gdi/gcach_xpeer \
vcl/unx/generic/gdi/gdiimpl \
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index a5457ce399f6..1f7eb2b20999 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -1214,6 +1214,26 @@ bool GenPspGraphics::SupportsCairo() const
return false;
}
+cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+cairo::SurfaceSharedPtr GenPspGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+cairo::SurfaceSharedPtr GenPspGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+css::uno::Any GenPspGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/, const basegfx::B2ISize& /*rSize*/) const
+{
+ return css::uno::Any();
+}
+
SystemFontData GenPspGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
{
return SystemFontData();
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index f63ae479f31b..49eff809c64a 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -738,4 +738,24 @@ bool SvpSalGraphics::SupportsCairo() const
return false;
}
+cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+cairo::SurfaceSharedPtr SvpSalGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const
+{
+ return cairo::SurfaceSharedPtr();
+}
+
+css::uno::Any SvpSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/, const basegfx::B2ISize& /*rSize*/) const
+{
+ return css::uno::Any();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/cairo_cairo.hxx b/vcl/inc/cairo_cairo.hxx
new file mode 100644
index 000000000000..968954b1ce19
--- /dev/null
+++ b/vcl/inc/cairo_cairo.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CAIRO_HXX
+#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CAIRO_HXX
+
+#include <sal/config.h>
+#include <vcl/cairo.hxx>
+#include "vcl/dllapi.h"
+
+struct SystemEnvData;
+namespace vcl { class Window; }
+
+namespace cairo {
+ VCL_PLUGIN_PUBLIC const SystemEnvData* GetSysData(const vcl::Window *pOutputWindow);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h
index 5e8bcf353e65..8b78faa8d0b1 100644
--- a/vcl/inc/generic/genpspgraphics.h
+++ b/vcl/inc/generic/genpspgraphics.h
@@ -202,6 +202,10 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) 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 9cc4dbab07b6..3d68e7649314 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -200,6 +200,10 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) 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 54bd2a932831..e9cddd80af3e 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -419,6 +419,10 @@ public:
virtual SystemGraphicsData
GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) 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 ef1812077ee8..827baa0f2514 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -440,6 +440,13 @@ public:
/// Check whether cairo will work
virtual bool SupportsCairo() const = 0;
+ /// Create Surface from given cairo surface
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const = 0;
+ /// Create surface with given dimensions
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const = 0;
+ /// Create Surface for given bitmap data
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const = 0;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const = 0;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0;
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index b8a2a60972de..0a0d0d329bce 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -263,6 +263,10 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const SAL_OVERRIDE;
virtual void BeginPaint() SAL_OVERRIDE;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index e956e0ff4644..fdd931ce5fe6 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -449,6 +449,10 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
+ virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
+ virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
virtual void BeginPaint() SAL_OVERRIDE;
diff --git a/canvas/source/cairo/cairo_quartz_cairo.cxx b/vcl/quartz/cairo_quartz_cairo.cxx
index 8da24f3391dd..b3a05541c438 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.cxx
+++ b/vcl/quartz/cairo_quartz_cairo.cxx
@@ -17,7 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#if defined MACOSX || defined IOS
+#include <config_cairo_canvas.h>
+
+#if ENABLE_CAIRO_CANVAS
/************************************************************************
* Mac OS X/Quartz and iOS surface backend for LibreOffice Cairo Canvas *
************************************************************************/
@@ -29,7 +31,7 @@
#include "cairo_cairo.hxx"
-#if defined CAIRO_HAS_QUARTZ_SURFACE
+#include <config_cairo_canvas.h>
#include "cairo_quartz_cairo.hxx"
@@ -251,81 +253,8 @@ namespace cairo
new VirtualDevice( &aSystemGraphicsData, Size(1, 1), getDepth() ));
}
- /**
- * cairo::createSurface: Create generic Canvas surface using given Cairo Surface
- *
- * @param rSurface Cairo Surface
- *
- * @return new Surface
- */
- SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface )
- {
- return SurfaceSharedPtr(new QuartzSurface(rSurface));
- }
-
- /**
- * cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
- *
- * @param rSurface Cairo Surface
- *
- * For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
- *
- * @return new Surface
- */
- SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
- int x, int y, int width, int height )
- {
- SurfaceSharedPtr surf;
-
- if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
- {
- const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
- const SystemEnvData* pSysData = GetSysData(&rWindow);
- if (pSysData)
- surf = SurfaceSharedPtr(new QuartzSurface(pSysData->pView, x, y, width, height));
- }
- else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
- {
- SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
-
- if (aSysData.rCGContext)
- surf = SurfaceSharedPtr(new QuartzSurface(aSysData.rCGContext, x, y, width, height));
- }
- return surf;
- }
-
- /**
- * cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
- * @param OutputDevice (not used)
- * @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
- * @param rSize width and height of the new surface
- *
- * Create a surface based on image data on rData
- *
- * @return new surface or empty surface
- **/
- SurfaceSharedPtr createBitmapSurface( const OutputDevice& /* rRefDevice */,
- const BitmapSystemData& rData,
- const Size& rSize )
- {
- OSL_TRACE( "requested size: %d x %d available size: %d x %d",
- rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
-
- if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
- {
- CGContextRef rContext = (CGContextRef)rData.rImageContext;
- OSL_TRACE("Canvas::cairo::createBitmapSurface(): New native image surface, context = %p.", rData.rImageContext);
-
- return SurfaceSharedPtr(new QuartzSurface(rContext, 0, 0, rData.mnWidth, rData.mnHeight));
- }
- return SurfaceSharedPtr();
- }
-
} // namespace cairo
-#endif // CAIRO_HAS_QUARTZ_SURFACE
-
-#endif // QUARTZ
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_quartz_cairo.hxx b/vcl/quartz/cairo_quartz_cairo.hxx
index a3f94d20abf3..a3f94d20abf3 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.hxx
+++ b/vcl/quartz/cairo_quartz_cairo.hxx
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index b982dd4ff7bb..febf2fdc569a 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -39,6 +39,11 @@
#include <vcl/sysdata.hxx>
#endif
+#include <config_cairo_canvas.h>
+#if ENABLE_CAIRO_CANVAS
+#include "cairo_quartz_cairo.hxx"
+#endif
+
#if defined(IOS) && defined(DBG_UTIL)
// Variables in TiledView.m
@@ -1447,7 +1452,115 @@ SystemGraphicsData AquaSalGraphics::GetGraphicsData() const
bool AquaSalGraphics::SupportsCairo() const
{
+#if ENABLE_CAIRO_CANVAS
return true;
+#else
+ return false;
+#endif
+}
+
+/**
+ * cairo::createSurface: Create generic Canvas surface using given Cairo Surface
+ *
+ * @param rSurface Cairo Surface
+ *
+ * @return new Surface
+ */
+cairo::SurfaceSharedPtr AquaSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+#if ENABLE_CAIRO_CANVAS
+ return cairo::SurfaceSharedPtr(new cairo::QuartzSurface(rSurface));
+#else
+ (void)rSurface;
+ return cairo::SurfaceSharedPtr();
+#endif
+}
+
+/**
+ * cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
+ *
+ * @param rSurface Cairo Surface
+ *
+ * For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
+ * For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
+ *
+ * @return new Surface
+ */
+cairo::SurfaceSharedPtr AquaSalGraphics::CreateSurface( const OutputDevice& rRefDevice,
+ int x, int y, int width, int height ) const
+{
+ cairo::SurfaceSharedPtr surf;
+#if ENABLE_CAIRO_CANVAS
+ if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
+ {
+ const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
+ const SystemEnvData* pSysData = GetSysData(&rWindow);
+ if (pSysData)
+ surf = cairo::SurfaceSharedPtr(new cairo::QuartzSurface(pSysData->pView, x, y, width, height));
+ }
+ else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
+ {
+ SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
+
+ if (aSysData.rCGContext)
+ surf = cairo::SurfaceSharedPtr(new cairo::QuartzSurface(aSysData.rCGContext, x, y, width, height));
+ }
+#else
+ (void)rRefDevice;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+#endif
+ return surf;
+}
+
+/**
+ * cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
+ * @param OutputDevice (not used)
+ * @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
+ * @param rSize width and height of the new surface
+ *
+ * Create a surface based on image data on rData
+ *
+ * @return new surface or empty surface
+ **/
+cairo::SurfaceSharedPtr AquaSalGraphics::CreateBitmapSurface( const OutputDevice& /* rRefDevice */,
+ const BitmapSystemData& rData,
+ const Size& rSize ) const
+{
+#if ENABLE_CAIRO_CANVAS
+ OSL_TRACE( "requested size: %d x %d available size: %d x %d",
+ rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
+
+ if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
+ {
+ CGContextRef rContext = (CGContextRef)rData.rImageContext;
+ OSL_TRACE("Canvas::cairo::createBitmapSurface(): New native image surface, context = %p.", rData.rImageContext);
+
+ return cairo::SurfaceSharedPtr(new cairo::QuartzSurface(rContext, 0, 0, rData.mnWidth, rData.mnHeight));
+ }
+#else
+ (void)rData;
+ (void)rSize;
+#endif
+ return cairo::SurfaceSharedPtr();
+}
+
+css::uno::Any AquaSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& /*rSize*/) const
+{
+ sal_IntPtr handle;
+#if ENABLE_CAIRO_CANVAS
+ cairo::QuartzSurface* pQuartzSurface = dynamic_cast<cairo::QuartzSurface*>(rSurface.get());
+ OSL_ASSERT(pQuartzSurface);
+ handle = sal_IntPtr (pQuartzSurface->getCGContext());
+#else
+ handle = 0;
+ (void)rSurface;
+#endif
+ css::uno::Sequence< css::uno::Any > args( 1 );
+ args[0] = css::uno::Any( handle );
+ return css::uno::Any( args );
}
long AquaSalGraphics::GetGraphicsWidth() const
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index c64fbfffcc84..0fe76778cd1e 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -64,6 +64,8 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
+#include <config_cairo_canvas.h>
+
#include <numeric>
#include <stack>
@@ -299,6 +301,7 @@ SystemGraphicsData OutputDevice::GetSystemGfxData() const
bool OutputDevice::SupportsCairo() const
{
+#if ENABLE_CAIRO_CANVAS
if (!mpGraphics)
{
if (!AcquireGraphics())
@@ -306,6 +309,49 @@ bool OutputDevice::SupportsCairo() const
}
return mpGraphics->SupportsCairo();
+#else
+ return false;
+#endif
+}
+
+cairo::SurfaceSharedPtr OutputDevice::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+ if (!mpGraphics)
+ {
+ if (!AcquireGraphics())
+ return cairo::SurfaceSharedPtr();
+ }
+ return mpGraphics->CreateSurface(rSurface);
+}
+
+cairo::SurfaceSharedPtr OutputDevice::CreateSurface(int x, int y, int width, int height) const
+{
+ if (!mpGraphics)
+ {
+ if (!AcquireGraphics())
+ return cairo::SurfaceSharedPtr();
+ }
+ return mpGraphics->CreateSurface(*this, x, y, width, height);
+}
+
+cairo::SurfaceSharedPtr OutputDevice::CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const
+{
+ if (!mpGraphics)
+ {
+ if (!AcquireGraphics())
+ return cairo::SurfaceSharedPtr();
+ }
+ return mpGraphics->CreateBitmapSurface(*this, rData, rSize);
+}
+
+css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const
+{
+ if (!mpGraphics)
+ {
+ if (!AcquireGraphics())
+ return css::uno::Any();
+ }
+ return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
}
css::uno::Any OutputDevice::GetSystemGfxDataAny() const
diff --git a/canvas/source/cairo/cairo_cairo.cxx b/vcl/source/window/cairo_cairo.cxx
index ff78a8d82323..a722c2e8d073 100644
--- a/canvas/source/cairo/cairo_cairo.cxx
+++ b/vcl/source/window/cairo_cairo.cxx
@@ -17,10 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "cairo_cairo.hxx"
-
#include <vcl/sysdata.hxx>
#include <vcl/syschild.hxx>
+#include "cairo_cairo.hxx"
+#ifdef _WIN32
+#include <prewin.h>
+#include <postwin.h>
+#endif
namespace cairo
{
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
index f6720d34eaec..3f063b37e8c7 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
@@ -24,6 +24,7 @@
#include <X11/Xlib.h>
#include <postx.h>
+#include "cairo_cairo.hxx"
#include "cairo_xlib_cairo.hxx"
#include <vcl/sysdata.hxx>
@@ -193,18 +194,18 @@ namespace cairo
/**
* Surface::getSimilar: Create new similar Canvas surface
- * @param aContent format of the new surface (cairo_content_t from cairo/src/cairo.h)
+ * @param cairo_content_type 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. This normally creates platform native surface, even though
* generic function is used.
*
- * Cairo surface from aContent (cairo_content_t)
+ * Cairo surface from cairo_content_type (cairo_content_t)
*
* @return new surface or NULL
**/
- SurfaceSharedPtr X11Surface::getSimilar( Content aContent, int width, int height ) const
+ SurfaceSharedPtr X11Surface::getSimilar(int cairo_content_type, int width, int height ) const
{
Pixmap hPixmap;
@@ -213,7 +214,7 @@ namespace cairo
XRenderPictFormat* pFormat;
int nFormat;
- switch (aContent)
+ switch (cairo_content_type)
{
case CAIRO_CONTENT_ALPHA:
nFormat = PictStandardA8;
@@ -251,7 +252,8 @@ namespace cairo
new X11Surface( maSysData,
X11PixmapSharedPtr(),
CairoSurfaceSharedPtr(
- cairo_surface_create_similar( mpSurface.get(), aContent, width, height ),
+ cairo_surface_create_similar( mpSurface.get(),
+ static_cast<cairo_content_t>(cairo_content_type), width, height ),
&cairo_surface_destroy )));
}
@@ -304,59 +306,6 @@ namespace cairo
return -1;
}
-
- SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface )
- {
- return SurfaceSharedPtr(new X11Surface(rSurface));
- }
-
- static X11SysData getSysData( const vcl::Window& rWindow )
- {
- const SystemEnvData* pSysData = GetSysData(&rWindow);
-
- if( !pSysData )
- return X11SysData();
- else
- return X11SysData(*pSysData);
- }
-
- static X11SysData getSysData( const VirtualDevice& rVirDev )
- {
- return X11SysData( rVirDev.GetSystemGfxData() );
- }
-
- 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();
- }
-
- SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice,
- const BitmapSystemData& rData,
- const Size& rSize )
- {
- SAL_INFO(
- "canvas.cairo",
- "requested size: " << rSize.Width() << " x " << rSize.Height()
- << " available size: " << rData.mnWidth << " x "
- << rData.mnHeight);
- if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
- {
- if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
- return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const vcl::Window&>(rRefDevice)), rData ));
- else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
- return SurfaceSharedPtr(new X11Surface(getSysData(static_cast<const VirtualDevice&>(rRefDevice)), rData ));
- }
-
- return SurfaceSharedPtr();
- }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
index a7071cecd6bd..076f34f2676c 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
@@ -24,8 +24,9 @@
#include <sal/types.h>
-#include "cairo_cairo.hxx"
+#include <vcl/cairo.hxx>
+class BitmapSystemData;
struct SystemEnvData;
struct SystemGraphicsData;
@@ -84,7 +85,7 @@ namespace cairo {
// 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 SurfaceSharedPtr getSimilar(int cairo_content_type, int width, int height) const SAL_OVERRIDE;
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const SAL_OVERRIDE;
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 5b861cac7f1a..ee68a0cac9da 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -40,7 +40,8 @@
#include "basegfx/polygon/b2dpolypolygoncutter.hxx"
#include "basegfx/polygon/b2dtrapezoid.hxx"
-#include "vcl/jobdata.hxx"
+#include <vcl/jobdata.hxx>
+#include <vcl/virdev.hxx>
#include "unx/salunx.h"
#include "unx/saldata.hxx"
@@ -61,6 +62,8 @@
#include "generic/printergfx.hxx"
#include "xrender_peer.hxx"
+#include "cairo_cairo.hxx"
+#include "cairo_xlib_cairo.hxx"
#include <vcl/opengl/OpenGLHelper.hxx>
@@ -456,6 +459,71 @@ bool X11SalGraphics::SupportsCairo() const
return XQueryExtension(pDisplay, "RENDER", &nDummy, &nDummy, &nDummy);
}
+cairo::SurfaceSharedPtr X11SalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+ return cairo::SurfaceSharedPtr(new cairo::X11Surface(rSurface));
+}
+
+namespace
+{
+ static cairo::X11SysData getSysData( const vcl::Window& rWindow )
+ {
+ const SystemEnvData* pSysData = cairo::GetSysData(&rWindow);
+
+ if( !pSysData )
+ return cairo::X11SysData();
+ else
+ return cairo::X11SysData(*pSysData);
+ }
+
+ static cairo::X11SysData getSysData( const VirtualDevice& rVirDev )
+ {
+ return cairo::X11SysData( rVirDev.GetSystemGfxData() );
+ }
+}
+
+cairo::SurfaceSharedPtr X11SalGraphics::CreateSurface( const OutputDevice& rRefDevice,
+ int x, int y, int width, int height ) const
+{
+ if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
+ return cairo::SurfaceSharedPtr(new cairo::X11Surface(getSysData(static_cast<const vcl::Window&>(rRefDevice)),
+ x,y,width,height));
+ if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
+ return cairo::SurfaceSharedPtr(new cairo::X11Surface(getSysData(static_cast<const VirtualDevice&>(rRefDevice)),
+ x,y,width,height));
+ return cairo::SurfaceSharedPtr();
+}
+
+cairo::SurfaceSharedPtr X11SalGraphics::CreateBitmapSurface( const OutputDevice& rRefDevice,
+ const BitmapSystemData& rData,
+ const Size& rSize ) const
+{
+ SAL_INFO(
+ "canvas.cairo",
+ "requested size: " << rSize.Width() << " x " << rSize.Height()
+ << " available size: " << rData.mnWidth << " x "
+ << rData.mnHeight);
+ if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
+ {
+ if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
+ return cairo::SurfaceSharedPtr(new cairo::X11Surface(getSysData(static_cast<const vcl::Window&>(rRefDevice)), rData ));
+ else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
+ return cairo::SurfaceSharedPtr(new cairo::X11Surface(getSysData(static_cast<const VirtualDevice&>(rRefDevice)), rData ));
+ }
+
+ return cairo::SurfaceSharedPtr();
+}
+
+css::uno::Any X11SalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& /*rSize*/) const
+{
+ cairo::X11Surface& rXlibSurface=dynamic_cast<cairo::X11Surface&>(*rSurface.get());
+ css::uno::Sequence< css::uno::Any > args( 3 );
+ args[0] = css::uno::Any( false ); // do not call XFreePixmap on it
+ args[1] = css::uno::Any( rXlibSurface.getPixmap()->mhDrawable );
+ args[2] = css::uno::Any( sal_Int32( rXlibSurface.getDepth() ) );
+ return css::uno::Any(args);
+}
+
// draw a poly-polygon
bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPolyPoly, double fTransparency )
{
diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/vcl/win/source/gdi/cairo_win32_cairo.cxx
index d6a4aba59ffd..9cf81c7002de 100644
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ b/vcl/win/source/gdi/cairo_win32_cairo.cxx
@@ -17,7 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifdef WNT
+#include <config_cairo_canvas.h>
+
+#if ENABLE_CAIRO_CANVAS
/************************************************************************
* Win32 surface backend for LibreOffice Cairo Canvas *
************************************************************************/
@@ -29,8 +31,6 @@
#include "cairo_win32_cairo.hxx"
-#ifdef CAIRO_HAS_WIN32_SURFACE
-
namespace cairo
{
@@ -130,7 +130,7 @@ namespace cairo
*
* @return new surface or NULL
**/
- SurfaceSharedPtr Win32Surface::getSimilar( Content aContent, int width, int height ) const
+ SurfaceSharedPtr Win32Surface::getSimilar( int aContent, int width, int height ) const
{
return SurfaceSharedPtr(
new Win32Surface(
@@ -180,79 +180,8 @@ namespace cairo
new VirtualDevice( &aSystemGraphicsData, Size(1, 1), sal::static_int_cast<USHORT>(getDepth()) ));
}
-
- /**
- * cairo::createSurface: Create generic Canvas surface using given Cairo Surface
- *
- * @param rSurface Cairo Surface
- *
- * @return new Surface
- */
- SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface )
- {
- return SurfaceSharedPtr(new Win32Surface(rSurface));
- }
-
-
- /**
- * cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
- *
- * @param rSurface Cairo Surface
- *
- * For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
- *
- * @return new Surface
- */
- SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
- int x, int y, int /* width */, int /* height */)
- {
- SurfaceSharedPtr surf;
-
- if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
- {
- const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
- const SystemEnvData* pSysData = GetSysData(&rWindow);
- if (pSysData && pSysData->hWnd)
- surf = SurfaceSharedPtr(new Win32Surface(GetDC((HWND) pSysData->hWnd), x, y));
- }
- else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
- {
- SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
- if (aSysData.hDC)
- surf = SurfaceSharedPtr(new Win32Surface((HDC) aSysData.hDC, x, y));
- }
- return surf;
- }
-
-
- /**
- * cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
- * @param OutputDevice (not used)
- * @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
- * @param rSize width and height of the new surface
- *
- * Create a surface based on image data on rData
- *
- * @return new surface or empty surface
- **/
- SurfaceSharedPtr createBitmapSurface( const OutputDevice& /* rRefDevice */,
- const BitmapSystemData& rData,
- const Size& rSize )
- {
- OSL_TRACE( "requested size: %d x %d available size: %d x %d",
- rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
-
- if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
- return SurfaceSharedPtr(new Win32Surface( rData ));
- else
- return SurfaceSharedPtr();
- }
-
} // namespace cairo
-#endif // CAIRO_HAS_WIN32_SURFACE
-
-#endif // WNT
+#endif // #ENABLE_CAIRO_CANVAS
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/vcl/win/source/gdi/cairo_win32_cairo.hxx
index 6df30f58ef40..dd1be37db7dd 100644
--- a/canvas/source/cairo/cairo_win32_cairo.hxx
+++ b/vcl/win/source/gdi/cairo_win32_cairo.hxx
@@ -41,7 +41,7 @@ namespace cairo {
// Surface interface
virtual CairoSharedPtr getCairo() const;
virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
- virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
+ virtual SurfaceSharedPtr getSimilar( int aContent, int width, int height ) const;
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index ff74b0f5546f..66f95d94a9db 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -36,9 +36,14 @@
#include "salgdiimpl.hxx"
#include "gdiimpl.hxx"
#include "opengl/win/gdiimpl.hxx"
+#include <config_cairo_canvas.h>
+#if ENABLE_CAIRO_CANVAS
+#include "cairo_win32_cairo.cxx"
+#endif
#include <vcl/opengl/OpenGLHelper.hxx>
+
#define DITHER_PAL_DELTA 51
#define DITHER_PAL_STEPS 6
#define DITHER_PAL_COUNT (DITHER_PAL_STEPS*DITHER_PAL_STEPS*DITHER_PAL_STEPS)
@@ -1075,7 +1080,136 @@ SystemGraphicsData WinSalGraphics::GetGraphicsData() const
bool WinSalGraphics::SupportsCairo() const
{
+#if ENABLE_CAIRO_CANVAS
return true;
+#else
+ return false;
+#endif
+}
+
+/**
+ * cairo::createSurface: Create generic Canvas surface using given Cairo Surface
+ *
+ * @param rSurface Cairo Surface
+ *
+ * @return new Surface
+ */
+cairo::SurfaceSharedPtr WinSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
+{
+#if ENABLE_CAIRO_CANVAS
+ return cairo::SurfaceSharedPtr(new cairo::Win32Surface(rSurface));
+#else
+ (void)rSurface;
+ return cairo::SurfaceSharedPtr();
+#endif
+}
+
+/**
+ * cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
+ *
+ * @param rSurface Cairo Surface
+ *
+ * For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
+ * For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
+ *
+ * @return new Surface
+ */
+cairo::SurfaceSharedPtr WinSalGraphics::CreateSurface( const OutputDevice& rRefDevice,
+ int x, int y, int /* width */, int /* height */) const
+{
+ cairo::SurfaceSharedPtr surf;
+
+#if ENABLE_CAIRO_CANVAS
+ if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
+ {
+ const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
+ const SystemEnvData* pSysData = GetSysData(&rWindow);
+ if (pSysData && pSysData->hWnd)
+ surf = cairo::SurfaceSharedPtr(new cairo::Win32Surface(GetDC((HWND) pSysData->hWnd), x, y));
+ }
+ else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
+ {
+ SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
+ if (aSysData.hDC)
+ surf = cairo::SurfaceSharedPtr(new cairo::Win32Surface((HDC) aSysData.hDC, x, y));
+ }
+#else
+ (void)x;
+ (void)y;
+#endif
+
+ return surf;
+}
+
+/**
+ * cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
+ * @param OutputDevice (not used)
+ * @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
+ * @param rSize width and height of the new surface
+ *
+ * Create a surface based on image data on rData
+ *
+ * @return new surface or empty surface
+ **/
+cairo::SurfaceSharedPtr WinSalGraphics::CreateBitmapSurface( const OutputDevice& /* rRefDevice */,
+ const BitmapSystemData& rData,
+ const Size& rSize ) const
+{
+ OSL_TRACE( "requested size: %d x %d available size: %d x %d",
+ rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
+
+#if ENABLE_CAIRO_CANVAS
+ if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
+ return cairo::SurfaceSharedPtr(new cairo::Win32Surface( rData ));
+#else
+ (void)rData;
+ (void)rSize;
+#endif
+ return cairo::SurfaceSharedPtr();
+}
+
+#if ENABLE_CAIRO_CANVAS
+namespace
+{
+ HBITMAP surface2HBitmap( const SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize )
+ {
+ // can't seem to retrieve HBITMAP from cairo. copy content then
+ HDC hScreenDC=GetDC(NULL);
+ HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
+ rSize.getX(),
+ rSize.getY() );
+
+ HDC hBmpDC = CreateCompatibleDC( 0 );
+ HBITMAP hBmpOld = (HBITMAP) SelectObject( hBmpDC, hBmpBitmap );
+
+ BitBlt( hBmpDC, 0, 0, rSize.getX(), rSize.getX(),
+ cairo_win32_surface_get_dc(rSurface->getCairoSurface().get()),
+ 0, 0, SRCCOPY );
+
+ SelectObject( hBmpDC, hBmpOld );
+ DeleteDC( hBmpDC );
+
+ return hBmpBitmap;
+ }
+}
+#endif
+
+css::uno::Any WinSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const
+{
+ // TODO(F2): check whether under all circumstances,
+ // the alpha channel is ignored here.
+ css::uno::Sequence< css::uno::Any > args( 1 );
+ sal_Int64 nHandle;
+#if ENABLE_CAIRO_CANVAS
+ nHandle = sal_Int64(surface2HBitmap(rSurface, rSize));
+#else
+ (void)rSurface;
+ (void)rSize;
+ nHandle = 0;
+#endif
+ args[1] = css::uno::Any(nHandle);
+ // caller frees the bitmap
+ return css::uno::Any( args );
}
void WinSalGraphics::BeginPaint()