2006-09-17 02:17:37 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: cairo_cairo.cxx,v $
|
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* $Revision: 1.7 $
|
2006-09-17 02:17:37 +00:00
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* last change: $Author: kz $ $Date: 2008-04-02 09:40:35 $
|
2006-09-17 02:17:37 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_canvas.hxx"
|
2008-04-02 08:40:35 +00:00
|
|
|
|
|
|
|
/****************************************************************************************
|
|
|
|
* Platform independent part of surface backends for OpenOffice.org Cairo Canvas *
|
|
|
|
* For rest of the functions, see platform specific cairo_<platform>_cairo.cxx *
|
|
|
|
****************************************************************************************/
|
|
|
|
|
2006-02-28 09:32:45 +00:00
|
|
|
#include "cairo_cairo.hxx"
|
|
|
|
|
|
|
|
namespace cairo
|
|
|
|
{
|
|
|
|
|
2008-04-02 08:40:35 +00:00
|
|
|
/**
|
|
|
|
* Surface::getCairo: Create Cairo for the Canvas surface
|
2007-07-17 13:19:36 +00:00
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* @return new Cairo or NULL
|
2007-07-17 13:19:36 +00:00
|
|
|
**/
|
2008-04-02 08:40:35 +00:00
|
|
|
Cairo* Surface::getCairo()
|
2006-02-28 09:32:45 +00:00
|
|
|
{
|
2008-04-02 08:40:35 +00:00
|
|
|
Cairo *cr = NULL;
|
|
|
|
if (mpSurface) {
|
|
|
|
cr = cairo_create( mpSurface );
|
|
|
|
}
|
|
|
|
return cr;
|
2006-02-28 09:32:45 +00:00
|
|
|
}
|
|
|
|
|
2007-07-17 13:19:36 +00:00
|
|
|
|
2008-04-02 08:40:35 +00:00
|
|
|
// This is needed to distinguish support for Cairo versions < 1.2.
|
|
|
|
#if !defined (USE_CAIRO10_APIS)
|
2006-02-28 09:32:45 +00:00
|
|
|
|
2007-07-17 13:19:36 +00:00
|
|
|
/**
|
|
|
|
* Surface::~Surface: Destroy the Canvas surface
|
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* Cairo itself takes care of freeing any resources, such as
|
|
|
|
* image data and other references related to the surface.
|
2007-07-17 13:19:36 +00:00
|
|
|
*
|
|
|
|
**/
|
2006-02-28 09:32:45 +00:00
|
|
|
Surface::~Surface()
|
|
|
|
{
|
|
|
|
if( mpSurface )
|
|
|
|
{
|
|
|
|
cairo_surface_destroy( mpSurface );
|
|
|
|
mpSurface = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-17 13:19:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* Creates a new Canvas surface. This should create platform native surface, even though
|
2007-07-17 13:19:36 +00:00
|
|
|
* generic function is used.
|
|
|
|
*
|
|
|
|
* Cairo surface from aContent (cairo_content_t)
|
|
|
|
*
|
|
|
|
* @return new surface or NULL
|
|
|
|
**/
|
2006-02-28 09:32:45 +00:00
|
|
|
Surface* Surface::getSimilar( Content aContent, int width, int height )
|
|
|
|
{
|
2008-04-02 08:40:35 +00:00
|
|
|
// This should create platform native Cairo surface on ALL platforms.
|
|
|
|
return new Surface( cairo_surface_create_similar( mpSurface, aContent, width, height ) );
|
2006-02-28 09:32:45 +00:00
|
|
|
|
2008-04-02 08:40:35 +00:00
|
|
|
// For example on Mac OS X, cairo_surface_create_similar() actually results in native surface,
|
|
|
|
// equivalent to cairo_quartz_surface_create()
|
2006-02-28 09:32:45 +00:00
|
|
|
}
|
2008-04-02 08:40:35 +00:00
|
|
|
#endif // !defined (USE_CAIRO10_APIS)
|
2006-03-22 09:58:48 +00:00
|
|
|
|
2007-07-17 13:19:36 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-02 08:40:35 +00:00
|
|
|
* Surface::createVirtualDevice: Create new VCL virtual device
|
2007-07-17 13:19:36 +00:00
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* Creates a new virtual device in VCL, with the current mpSurface contents as data.
|
|
|
|
* This is used by e.g. cairo_canvashelper_text.cxx to make VCL draw text on the cairo surface.
|
2007-07-17 13:19:36 +00:00
|
|
|
*
|
2008-04-02 08:40:35 +00:00
|
|
|
* @return new virtual device
|
2007-07-17 13:19:36 +00:00
|
|
|
**/
|
2008-04-02 08:40:35 +00:00
|
|
|
VirtualDevice* Surface::createVirtualDevice()
|
2006-03-22 09:58:48 +00:00
|
|
|
{
|
2008-04-02 08:40:35 +00:00
|
|
|
// struct SystemGraphicsData in vcl/inc/sysdata.hxx
|
|
|
|
SystemGraphicsData aSystemGraphicsData;
|
|
|
|
|
|
|
|
aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
|
|
|
|
fillSystemGraphicsData( aSystemGraphicsData );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contrary to the description of
|
|
|
|
* VirtualDevice(SystemGraphicsData*, nBitCount); (in vcl/inc/virdev.hxx)
|
|
|
|
* at least X11 behaves differently, i.e. nBitCount is color depth, not just 1 or 0.
|
|
|
|
**/
|
|
|
|
return new VirtualDevice( &aSystemGraphicsData,
|
|
|
|
sal::static_int_cast<USHORT>(getDepth()) );
|
2006-03-22 09:58:48 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 08:40:35 +00:00
|
|
|
} // namespace cairo
|
2007-07-17 13:19:36 +00:00
|
|
|
|
2006-03-22 09:58:48 +00:00
|
|
|
|