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>
This commit is contained in:
Caolán McNamara
2015-03-19 14:43:08 +00:00
parent 2b838285e2
commit e510a208b0
48 changed files with 584 additions and 403 deletions

View File

@@ -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:

View File

@@ -22,7 +22,7 @@
#include <canvas/base/cachedprimitivebase.hxx>
#include "cairo_cairo.hxx"
#include <vcl/cairo.hxx>
/* Definition of CachedBitmap class */

View File

@@ -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 );
}

View File

@@ -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;

View File

@@ -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:

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 );

View File

@@ -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();
}

View File

@@ -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:

View File

@@ -22,7 +22,7 @@
#include <rtl/ref.hxx>
#include "cairo_cairo.hxx"
#include <vcl/cairo.hxx>
namespace cairocanvas
{

View File

@@ -22,7 +22,7 @@
#include <canvas/base/sprite.hxx>
#include "cairo_cairo.hxx"
#include <vcl/cairo.hxx>
namespace cairocanvas
{

View File

@@ -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 );
}

View File

@@ -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;

View File

@@ -25,7 +25,7 @@
#include <canvas/spriteredrawmanager.hxx>
#include "cairo_cairo.hxx"
#include <vcl/cairo.hxx>
#include "cairo_canvashelper.hxx"
namespace basegfx

View File

@@ -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.

View File

@@ -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();

View File

@@ -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;

View File

@@ -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>

View File

@@ -32,7 +32,7 @@
#include <boost/utility.hpp>
#include "cairo_cairo.hxx"
#include <vcl/cairo.hxx>
#include "cairo_canvasfont.hxx"

View File

@@ -0,0 +1,6 @@
#ifndef CONFIG_CAIRO_CANVAS_H
#define CONFIG_CAIRO_CANVAS_H
#define ENABLE_CAIRO_CANVAS 0
#endif

View File

@@ -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])

View File

@@ -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

View File

@@ -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();

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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();

View File

@@ -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: */

36
vcl/inc/cairo_cairo.hxx Normal file
View File

@@ -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: */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 { };

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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: */

View File

@@ -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

View File

@@ -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

View File

@@ -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
{

View File

@@ -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: */

View File

@@ -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;

View File

@@ -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 )
{

View File

@@ -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: */

View File

@@ -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;

View File

@@ -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()