summaryrefslogtreecommitdiff
path: root/canvas
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 /canvas
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>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/Library_cairocanvas.mk32
-rw-r--r--canvas/source/cairo/cairo_cachedbitmap.hxx2
-rw-r--r--canvas/source/cairo/cairo_cairo.cxx48
-rw-r--r--canvas/source/cairo/cairo_cairo.hxx89
-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_quartz_cairo.cxx331
-rw-r--r--canvas/source/cairo/cairo_quartz_cairo.hxx70
-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--canvas/source/cairo/cairo_win32_cairo.cxx258
-rw-r--r--canvas/source/cairo/cairo_win32_cairo.hxx56
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.cxx362
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.hxx104
30 files changed, 61 insertions, 1475 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_cairo.cxx b/canvas/source/cairo/cairo_cairo.cxx
deleted file mode 100644
index ff78a8d82323..000000000000
--- a/canvas/source/cairo/cairo_cairo.cxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- 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 .
- */
-
-#include "cairo_cairo.hxx"
-
-#include <vcl/sysdata.hxx>
-#include <vcl/syschild.hxx>
-
-namespace cairo
-{
- /***************************************************************************************
- * Platform independent part of surface backends for LibreOffice Cairo Canvas *
- * For the rest of the functions (and the platform-specific derived *
- * Surface classes), see platform specific cairo_<platform>_cairo.cxx *
- ****************************************************************************************/
-
- const SystemEnvData* GetSysData(const vcl::Window *pOutputWindow)
- {
- const SystemEnvData* pSysData = NULL;
- // check whether we're a SysChild: have to fetch system data
- // directly from SystemChildWindow, because the GetSystemData
- // method is unfortunately not virtual
- const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( pOutputWindow );
- if( pSysChild )
- pSysData = pSysChild->GetSystemData();
- else
- pSysData = pOutputWindow->GetSystemData();
- return pSysData;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_cairo.hxx b/canvas/source/cairo/cairo_cairo.hxx
deleted file mode 100644
index e256610a54d4..000000000000
--- a/canvas/source/cairo/cairo_cairo.hxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- 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 <boost/shared_ptr.hpp>
-
-struct SystemEnvData;
-struct BitmapSystemData;
-struct SystemGraphicsData;
-class VirtualDevice;
-class OutputDevice;
-namespace vcl { class Window; }
-class Size;
-
-#include <cairo.h>
-
-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);
-
- /** Cairo surface interface
-
- For each cairo-supported platform, there's an implementation of
- this interface
- */
- struct Surface
- {
- public:
- virtual ~Surface() {}
-
- // 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;
-
- /// 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
- virtual bool Resize( int /*width*/, int /*height*/ ) { return false; }
-
- /// Flush all pending output to surface
- virtual void flush() const = 0;
- };
-
- 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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_quartz_cairo.cxx b/canvas/source/cairo/cairo_quartz_cairo.cxx
deleted file mode 100644
index 8da24f3391dd..000000000000
--- a/canvas/source/cairo/cairo_quartz_cairo.cxx
+++ /dev/null
@@ -1,331 +0,0 @@
-/* -*- 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 .
- */
-
-#if defined MACOSX || defined IOS
-/************************************************************************
- * Mac OS X/Quartz and iOS surface backend for LibreOffice Cairo Canvas *
- ************************************************************************/
-
-#include <osl/diagnose.h>
-#include <vcl/sysdata.hxx>
-#include <vcl/bitmap.hxx>
-#include <vcl/virdev.hxx>
-
-#include "cairo_cairo.hxx"
-
-#if defined CAIRO_HAS_QUARTZ_SURFACE
-
-#include "cairo_quartz_cairo.hxx"
-
-namespace cairo
-{
- /**
- * QuartzSurface::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()
- * and QuartzSurface::getSimilar()
- *
- * Set the mpSurface to the new surface or NULL
- **/
- QuartzSurface::QuartzSurface( const CairoSurfaceSharedPtr& pSurface ) :
- mpView(NULL),
- mpSurface( pSurface )
- {
- // Necessary, context is lost otherwise
- CGContextRetain( getCGContext() ); // == NULL for non-native surfaces
- }
-
- /**
- * QuartzSurface::Surface: Create Canvas surface from Window reference.
- * @param NSView
- * @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
- *
- * pSysData contains the platform native Window reference.
- * pSysData is used to create a surface on the Window
- *
- * Set the mpSurface to the new surface or NULL
- **/
- QuartzSurface::QuartzSurface( NSView* pView, int x, int y, int width, int height ) :
- mpView(pView),
- mpSurface()
- {
- OSL_TRACE("Canvas::cairo::Surface(NSView*, x:%d, y:%d, w:%d, h:%d): New Surface for window", x, y, width, height);
-
- // on Mac OS X / Quartz we are not drawing directly to the screen, but via regular CGContextRef.
- // The actual drawing to NSView (i.e. screen) is done in QuartzSurface::flush()
-
- // HACK: currently initial size for windowsurface is 0x0, which is not possible for us.
- if (width == 0 || height == 0) {
- width = [mpView bounds].size.width;
- height = [mpView bounds].size.height;
- OSL_TRACE("Canvas::cairo::Surface(): BUG!! size is ZERO! fixing to %d x %d...", width, height);
- }
-
- // create a generic surface, NSView/Window is ARGB32.
- mpSurface.reset(
- cairo_quartz_surface_create(CAIRO_FORMAT_ARGB32, width, height),
- &cairo_surface_destroy);
-
- cairo_surface_set_device_offset( mpSurface.get(), x, y );
- }
-
- /**
- * QuartzSurface::Surface: Create Canvas surface from CGContextRef.
- * @param CGContext Native graphics context
- * @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
- **/
- QuartzSurface::QuartzSurface( CGContextRef rContext, int x, int y, int width, int height ) :
- mpView(NULL),
- mpSurface()
- {
- OSL_TRACE("Canvas::cairo::Surface(CGContext:%p, x:%d, y:%d, w:%d, h:%d): New Surface.", rContext, x, y, width, height);
- // create surface based on CGContext
-
- // ensure kCGBitmapByteOrder32Host flag, otherwise Cairo breaks (we are practically always using CGBitmapContext)
- OSL_ASSERT ((CGBitmapContextGetBitsPerPixel(rContext) != 32) ||
- (CGBitmapContextGetBitmapInfo(rContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Host);
-
- mpSurface.reset(cairo_quartz_surface_create_for_cg_context(rContext, width, height),
- &cairo_surface_destroy);
-
- cairo_surface_set_device_offset( mpSurface.get(), x, y );
-
- // Necessary, context is lost otherwise
- CGContextRetain(rContext);
- }
-
-
- /**
- * QuartzSurface::getCairo: Create Cairo (drawing object) for the Canvas surface
- *
- * @return new Cairo or NULL
- **/
- CairoSharedPtr QuartzSurface::getCairo() const
- {
- if (mpSurface.get())
- {
- return CairoSharedPtr( cairo_create(mpSurface.get()),
- &cairo_destroy );
- }
- else
- {
- return CairoSharedPtr();
- }
- }
-
- /**
- * QuartzSurface::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. This normally creates platform native surface, even though
- * generic function is used.
- *
- * Cairo surface from aContent (cairo_content_t)
- *
- * @return new surface or NULL
- **/
- SurfaceSharedPtr QuartzSurface::getSimilar( Content aContent, int width, int height ) const
- {
- return SurfaceSharedPtr(
- new QuartzSurface(
- CairoSurfaceSharedPtr(
- cairo_surface_create_similar( mpSurface.get(), aContent, width, height ),
- &cairo_surface_destroy )));
- }
-
- /**
- * QuartzSurface::flush: Draw the data to screen
- **/
- void QuartzSurface::flush() const
- {
- // can only flush surfaces with NSView
- if( !mpView )
- return;
-
- OSL_TRACE("Canvas::cairo::QuartzSurface::flush(): flush to NSView");
-
- CGContextRef mrContext = getCGContext();
-
- if (!mrContext)
- return;
-#ifndef IOS
- [mpView lockFocus];
-#endif
-
-#ifndef IOS
- /**
- * This code is using same screen update code as in VCL (esp. AquaSalGraphics::UpdateWindow() )
- */
- CGContextRef rViewContext = reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
-#else
- // Just guessing for now...
- CGContextRef rViewContext = UIGraphicsGetCurrentContext();
-#endif
- CGImageRef xImage = CGBitmapContextCreateImage(mrContext);
- CGContextDrawImage(rViewContext,
- CGRectMake( 0, 0,
- CGImageGetWidth(xImage),
- CGImageGetHeight(xImage)),
- xImage);
- CGImageRelease( xImage );
- CGContextFlush( rViewContext );
-#ifndef IOS
- [mpView unlockFocus];
-#endif
- }
-
- /**
- * QuartzSurface::getDepth: Get the color depth of the Canvas surface.
- *
- * @return color depth
- **/
- int QuartzSurface::getDepth() const
- {
- if (mpSurface.get())
- {
- switch (cairo_surface_get_content (mpSurface.get()))
- {
- case CAIRO_CONTENT_ALPHA: return 8; break;
- case CAIRO_CONTENT_COLOR: return 24; break;
- case CAIRO_CONTENT_COLOR_ALPHA: return 32; break;
- }
- }
- OSL_TRACE("Canvas::cairo::QuartzSurface::getDepth(): ERROR - depth unspecified!");
-
- return -1;
- }
-
- /**
- * QuartzSurface::getCGContext: Get the native CGContextRef of the Canvas's cairo surface
- *
- * @return graphics context
- **/
- CGContextRef QuartzSurface::getCGContext() const
- {
- if (mpSurface.get())
- return cairo_quartz_surface_get_cg_context(mpSurface.get());
- else
- return NULL;
- }
-
- /**
- * cairo::createVirtualDevice: Create a VCL virtual device for the CGContext in the cairo Surface
- *
- * @return The new virtual device
- **/
- boost::shared_ptr<VirtualDevice> QuartzSurface::createVirtualDevice() const
- {
- SystemGraphicsData aSystemGraphicsData;
- aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
- aSystemGraphicsData.rCGContext = getCGContext();
- return boost::shared_ptr<VirtualDevice>(
- 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_quartz_cairo.hxx b/canvas/source/cairo/cairo_quartz_cairo.hxx
deleted file mode 100644
index a3f94d20abf3..000000000000
--- a/canvas/source/cairo/cairo_quartz_cairo.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- 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_QUARTZ_CAIRO_HXX
-#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_QUARTZ_CAIRO_HXX
-
-#include "cairo_cairo.hxx"
-
-#include "premac.h"
-#include <TargetConditionals.h>
-#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE
-# include <Cocoa/Cocoa.h>
-#else
-# include <UIKit/UIKit.h>
-# define NSView UIView
-#endif
-#include <cairo-quartz.h>
-#include "postmac.h"
-
-namespace cairo {
-
- class QuartzSurface : public Surface
- {
- NSView* mpView; // if NULL - bg surface
- CairoSurfaceSharedPtr mpSurface;
-
- public:
- /// takes over ownership of passed cairo_surface
- explicit QuartzSurface( const CairoSurfaceSharedPtr& pSurface );
-
- /// create surface on subarea of given CGContext
- explicit QuartzSurface( CGContextRef rContext, int x, int y, int width, int height );
-
- /// create a offscreen surface for given NSView
- QuartzSurface( NSView* pView, int x, int y, int width, int height );
-
- // Surface interface
- virtual CairoSharedPtr getCairo() const;
- virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
- virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
-
- virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
-
- virtual void flush() const;
-
- int getDepth() const;
-
- CGContextRef getCGContext() const;
- };
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx
deleted file mode 100644
index d6a4aba59ffd..000000000000
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ /dev/null
@@ -1,258 +0,0 @@
-/* -*- 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 .
- */
-
-#ifdef WNT
-/************************************************************************
- * Win32 surface backend for LibreOffice Cairo Canvas *
- ************************************************************************/
-
-#include <osl/diagnose.h>
-#include <vcl/bitmap.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/sysdata.hxx>
-
-#include "cairo_win32_cairo.hxx"
-
-#ifdef CAIRO_HAS_WIN32_SURFACE
-
-namespace cairo
-{
-
-#include <cairo-win32.h>
-
- /**
- * 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()
- * and Surface::getSimilar()
- *
- * Set the mpSurface to the new surface or NULL
- **/
- Win32Surface::Win32Surface( const CairoSurfaceSharedPtr& pSurface ) :
- mpSurface( pSurface )
- {}
-
- /**
- * Surface::Surface: Create Canvas surface from Window reference.
- * @param pSysData Platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * @param x horizontal location of the new surface
- * @param y vertical location of the new surface
- *
- * pSysData contains the platform native Window reference.
- * pSysData is used to create a surface on the Window
- *
- * Set the mpSurface to the new surface or NULL
- **/
- Win32Surface::Win32Surface( HDC hDC, int x, int y) :
- mpSurface(
- cairo_win32_surface_create(hDC),
- &cairo_surface_destroy)
- {
- cairo_surface_set_device_offset( mpSurface.get(), x, y );
- }
-
- /**
- * Surface::Surface: Create platform native Canvas surface from BitmapSystemData
- * @param pBmpData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
- *
- * Create a surface based on image data on pBmpData
- *
- * Set the mpSurface to the new surface or NULL
- **/
- Win32Surface::Win32Surface( const BitmapSystemData& rBmpData ) :
- mpSurface()
- {
- OSL_ASSERT(rBmpData.pDIB == NULL);
-
- if(rBmpData.pDIB != NULL)
- {
- // So just leave mpSurface to NULL, little else we can do at
- // this stage. Hopefully the Win32 patch to
- // cairocanvas::DeviceHelper::getSurface(BitmapSystemData&,
- // const Size&) will catch the cases where this
- // constructor would be called with a DIB bitmap, and we
- // will never get here. At least it worked for Ballmer.ppt.
- }
- else
- {
- HDC hDC = CreateCompatibleDC(NULL);
- void* hOrigBitmap;
- OSL_TRACE ("Surface::Surface(): Selecting bitmap %p into DC %p", rBmpData.pDDB, hDC);
- hOrigBitmap = SelectObject( hDC, (HANDLE)rBmpData.pDDB );
- if(hOrigBitmap == NULL)
- OSL_TRACE ("SelectObject failed: %d", GetLastError ());
- mpSurface.reset(
- cairo_win32_surface_create(hDC),
- &cairo_surface_destroy);
- }
- }
-
- /**
- * Surface::getCairo: Create Cairo (drawing object) for the Canvas surface
- *
- * @return new Cairo or NULL
- **/
- CairoSharedPtr Win32Surface::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. This normally creates platform native surface, even though
- * generic function is used.
- *
- * Cairo surface from aContent (cairo_content_t)
- *
- * @return new surface or NULL
- **/
- SurfaceSharedPtr Win32Surface::getSimilar( Content aContent, int width, int height ) const
- {
- return SurfaceSharedPtr(
- new Win32Surface(
- CairoSurfaceSharedPtr(
- cairo_surface_create_similar( mpSurface.get(), aContent, width, height ),
- &cairo_surface_destroy )));
- }
-
- void Win32Surface::flush() const
- {
- GdiFlush();
- }
-
- /**
- * Surface::getDepth: Get the color depth of the Canvas surface.
- *
- * @return color depth
- **/
- int Win32Surface::getDepth() const
- {
- if (mpSurface)
- {
- switch (cairo_surface_get_content (mpSurface.get()))
- {
- case CAIRO_CONTENT_ALPHA: return 8; break;
- case CAIRO_CONTENT_COLOR: return 24; break;
- case CAIRO_CONTENT_COLOR_ALPHA: return 32; break;
- }
- }
- OSL_TRACE("Canvas::cairo::Surface::getDepth(): ERROR - depth unspecified!");
- return -1;
- }
-
-
- /**
- * cairo::createVirtualDevice: Create a VCL virtual device for the CGContext in the cairo Surface
- *
- * @return The new virtual device
- **/
- boost::shared_ptr<VirtualDevice> Win32Surface::createVirtualDevice() const
- {
- SystemGraphicsData aSystemGraphicsData;
- aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
- aSystemGraphicsData.hDC = cairo_win32_surface_get_dc( mpSurface.get() );
-
- return boost::shared_ptr<VirtualDevice>(
- 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/canvas/source/cairo/cairo_win32_cairo.hxx
deleted file mode 100644
index 6df30f58ef40..000000000000
--- a/canvas/source/cairo/cairo_win32_cairo.hxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- 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_WIN32_CAIRO_HXX
-#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_WIN32_CAIRO_HXX
-
-#include "cairo_cairo.hxx"
-#include <prewin.h>
-#include <postwin.h>
-
-namespace cairo {
-
- class Win32Surface : public Surface
- {
- CairoSurfaceSharedPtr mpSurface;
-
- public:
- /// takes over ownership of passed cairo_surface
- explicit Win32Surface( const CairoSurfaceSharedPtr& pSurface );
- /// create surface on subarea of given drawable
- Win32Surface( HDC hDC, int x, int y );
- /// create surface for given bitmap data
- Win32Surface( const BitmapSystemData& rBmpData );
-
- // Surface interface
- virtual CairoSharedPtr getCairo() const;
- virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
- virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
-
- virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
-
- virtual void flush() const;
-
- int getDepth() const;
- };
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
deleted file mode 100644
index f6720d34eaec..000000000000
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ /dev/null
@@ -1,362 +0,0 @@
-/* -*- 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 .
- */
-
-#include <utility>
-
-#include <prex.h>
-#include <X11/extensions/Xrender.h>
-#include <X11/Xlib.h>
-#include <postx.h>
-
-#include "cairo_xlib_cairo.hxx"
-
-#include <vcl/sysdata.hxx>
-#include <vcl/bitmap.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/window.hxx>
-#include <basegfx/vector/b2isize.hxx>
-
-namespace
-{
- Pixmap limitXCreatePixmap(Display *display, Drawable d, unsigned int width, unsigned int height, unsigned int depth)
- {
- // The X protocol request CreatePixmap puts an upper bound
- // of 16 bit to the size. And in practice some drivers
- // fall over with values close to the max.
-
- // see, e.g. moz#424333, fdo#48961, rhbz#1086714
- // we've a duplicate of this in vcl :-(
- if (width > SAL_MAX_INT16-10 || height > SAL_MAX_INT16-10)
- {
- SAL_WARN("canvas", "overlarge pixmap: " << width << " x " << height);
- return None;
- }
- return XCreatePixmap(display, d, width, height, depth);
- }
-}
-
-namespace cairo
-{
-
-#include <cairo-xlib.h>
-#include <cairo-xlib-xrender.h>
-
- X11SysData::X11SysData() :
- pDisplay(NULL),
- hDrawable(0),
- pVisual(NULL),
- nScreen(0),
- nDepth(-1),
- aColormap(-1),
- pRenderFormat(NULL)
- {}
-
- X11SysData::X11SysData( const SystemGraphicsData& pSysDat ) :
- pDisplay(pSysDat.pDisplay),
- hDrawable(pSysDat.hDrawable),
- pVisual(pSysDat.pVisual),
- nScreen(pSysDat.nScreen),
- nDepth(pSysDat.nDepth),
- aColormap(pSysDat.aColormap),
- pRenderFormat(pSysDat.pXRenderFormat)
- {}
-
- X11SysData::X11SysData( const SystemEnvData& pSysDat ) :
- pDisplay(pSysDat.pDisplay),
- hDrawable(pSysDat.aWindow),
- pVisual(pSysDat.pVisual),
- nScreen(pSysDat.nScreen),
- nDepth(pSysDat.nDepth),
- aColormap(pSysDat.aColormap),
- pRenderFormat(NULL)
- {}
-
- X11Pixmap::~X11Pixmap()
- {
- if( mpDisplay && mhDrawable )
- XFreePixmap( (Display*)mpDisplay, mhDrawable );
- }
-
- /**
- * Surface::Surface: Create Canvas surface with existing data
- * @param pSysData Platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * @param pSurface Cairo surface
- *
- * pSysData contains the platform native Drawable reference
- * This constructor only stores data, it does no processing.
- * It is used by e.g. Surface::getSimilar()
- *
- * Set the mpSurface as pSurface
- **/
- X11Surface::X11Surface( const X11SysData& rSysData,
- const X11PixmapSharedPtr& rPixmap,
- const CairoSurfaceSharedPtr& pSurface ) :
- maSysData(rSysData),
- mpPixmap(rPixmap),
- mpSurface(pSurface)
- {}
-
- /**
- * 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()
- * Unlike other constructors, mpSysData is set to NULL
- *
- * Set the mpSurface as pSurface
- **/
- X11Surface::X11Surface( const CairoSurfaceSharedPtr& pSurface ) :
- maSysData(),
- mpPixmap(),
- mpSurface(pSurface)
- {}
-
- /**
- * Surface::Surface: Create Canvas surface from Window reference.
- * @param pSysData Platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * @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
- *
- * pSysData contains the platform native Window reference.
- *
- * pSysData is used to create a surface on the Window
- *
- * Set the mpSurface to the new surface or NULL
- **/
- X11Surface::X11Surface( const X11SysData& rSysData, int x, int y, int width, int height ) :
- maSysData(rSysData),
- mpPixmap(),
- mpSurface(
- cairo_xlib_surface_create( (Display*)rSysData.pDisplay,
- rSysData.hDrawable,
- (Visual*)rSysData.pVisual,
- width + x, height + y ),
- &cairo_surface_destroy)
- {
- cairo_surface_set_device_offset(mpSurface.get(), x, y );
- }
-
- /**
- * Surface::Surface: Create platform native Canvas surface from BitmapSystemData
- * @param pSysData Platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
- * @param pBmpData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
- * @param width width of the new surface
- * @param height height of the new surface
- *
- * The pBmpData provides the imagedata that the created surface should contain.
- *
- * Set the mpSurface to the new surface or NULL
- **/
- X11Surface::X11Surface( const X11SysData& rSysData,
- const BitmapSystemData& rData ) :
- maSysData( rSysData ),
- mpPixmap(),
- mpSurface(
- cairo_xlib_surface_create( (Display*)rSysData.pDisplay,
- reinterpret_cast<Drawable>(rData.aPixmap),
- (Visual*) rSysData.pVisual,
- rData.mnWidth, rData.mnHeight ),
- &cairo_surface_destroy)
- {
- }
-
- /**
- * Surface::getCairo: Create Cairo (drawing object) for the Canvas surface
- *
- * @return new Cairo or NULL
- **/
- CairoSharedPtr X11Surface::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. This normally creates platform native surface, even though
- * generic function is used.
- *
- * Cairo surface from aContent (cairo_content_t)
- *
- * @return new surface or NULL
- **/
- SurfaceSharedPtr X11Surface::getSimilar( Content aContent, int width, int height ) const
- {
- Pixmap hPixmap;
-
- if( maSysData.pDisplay && maSysData.hDrawable )
- {
- XRenderPictFormat* pFormat;
- int nFormat;
-
- switch (aContent)
- {
- case CAIRO_CONTENT_ALPHA:
- nFormat = PictStandardA8;
- break;
- case CAIRO_CONTENT_COLOR:
- nFormat = PictStandardRGB24;
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- default:
- nFormat = PictStandardARGB32;
- break;
- }
-
- pFormat = XRenderFindStandardFormat( (Display*)maSysData.pDisplay, nFormat );
- hPixmap = limitXCreatePixmap( (Display*)maSysData.pDisplay, maSysData.hDrawable,
- width > 0 ? width : 1, height > 0 ? height : 1,
- pFormat->depth );
-
- X11SysData aSysData(maSysData);
- aSysData.pRenderFormat = pFormat;
- return SurfaceSharedPtr(
- new X11Surface( aSysData,
- X11PixmapSharedPtr(
- new X11Pixmap(hPixmap, maSysData.pDisplay)),
- CairoSurfaceSharedPtr(
- cairo_xlib_surface_create_with_xrender_format(
- (Display*)maSysData.pDisplay,
- hPixmap,
- ScreenOfDisplay((Display *)maSysData.pDisplay, maSysData.nScreen),
- pFormat, width, height ),
- &cairo_surface_destroy) ));
- }
- else
- return SurfaceSharedPtr(
- new X11Surface( maSysData,
- X11PixmapSharedPtr(),
- CairoSurfaceSharedPtr(
- cairo_surface_create_similar( mpSurface.get(), aContent, width, height ),
- &cairo_surface_destroy )));
- }
-
- boost::shared_ptr<VirtualDevice> X11Surface::createVirtualDevice() const
- {
- SystemGraphicsData aSystemGraphicsData;
-
- aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
- aSystemGraphicsData.hDrawable = getDrawable();
- aSystemGraphicsData.pXRenderFormat = getRenderFormat();
-
- int width = cairo_xlib_surface_get_width(mpSurface.get());
- int height = cairo_xlib_surface_get_height(mpSurface.get());
-
- return boost::shared_ptr<VirtualDevice>(
- new VirtualDevice(&aSystemGraphicsData,
- Size(width, height),
- std::max(getDepth(), 0)));
- }
-
- /**
- * 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
- **/
- bool X11Surface::Resize(int width, int height)
- {
- cairo_xlib_surface_set_size(mpSurface.get(), width, height);
- return true;
- }
-
- void X11Surface::flush() const
- {
- XSync( (Display*)maSysData.pDisplay, false );
- }
-
- /**
- * Surface::getDepth: Get the color depth of the Canvas surface.
- *
- * @return color depth
- **/
- int X11Surface::getDepth() const
- {
- if( maSysData.pRenderFormat )
- return ((XRenderPictFormat*) maSysData.pRenderFormat)->depth;
-
- 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/canvas/source/cairo/cairo_xlib_cairo.hxx
deleted file mode 100644
index a7071cecd6bd..000000000000
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- 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_XLIB_CAIRO_HXX
-#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_XLIB_CAIRO_HXX
-
-#include <sal/config.h>
-
-#include <sal/types.h>
-
-#include "cairo_cairo.hxx"
-
-struct SystemEnvData;
-struct SystemGraphicsData;
-
-namespace cairo {
-
- /// Holds all X11-output relevant data
- struct X11SysData
- {
- X11SysData();
- explicit X11SysData( const SystemGraphicsData& );
- explicit X11SysData( const SystemEnvData& );
-
- void* pDisplay; // the relevant display connection
- long hDrawable; // a drawable
- void* pVisual; // the visual in use
- int nScreen; // the current screen of the drawable
- int nDepth; // depth of said visual
- long aColormap; // the colormap being used
- void* pRenderFormat; // render format for drawable
- };
-
- /// RAII wrapper for a pixmap
- struct X11Pixmap
- {
- void* mpDisplay; // the relevant display connection
- long mhDrawable; // a drawable
-
- X11Pixmap( long hDrawable, void* pDisplay ) :
- mpDisplay(pDisplay),
- mhDrawable(hDrawable)
- {}
-
- ~X11Pixmap();
-
- void clear() { mpDisplay=NULL; mhDrawable=0; }
- };
-
- typedef boost::shared_ptr<X11Pixmap> X11PixmapSharedPtr;
-
- class X11Surface : public Surface
- {
- const X11SysData maSysData;
- X11PixmapSharedPtr mpPixmap;
- CairoSurfaceSharedPtr mpSurface;
-
- X11Surface( const X11SysData& rSysData, const X11PixmapSharedPtr& rPixmap, const CairoSurfaceSharedPtr& pSurface );
-
- public:
- /// takes over ownership of passed cairo_surface
- explicit X11Surface( const CairoSurfaceSharedPtr& pSurface );
- /// create surface on subarea of given drawable
- X11Surface( const X11SysData& rSysData, int x, int y, int width, int height );
- /// create surface for given bitmap data
- X11Surface( const X11SysData& rSysData, const BitmapSystemData& rBmpData );
-
- // 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 bool Resize( int width, int height ) SAL_OVERRIDE;
-
- virtual void flush() const SAL_OVERRIDE;
-
- int getDepth() const;
- X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
- void* getRenderFormat() const { return maSysData.pRenderFormat; }
- long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
- };
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */