summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobody <nobody@gnome.org>2005-07-07 09:40:00 +0000
committernobody <nobody@gnome.org>2005-07-07 09:40:00 +0000
commit45391e557fa8271fbfd067ecf2a609948c064a26 (patch)
treec9264dd48ea1768292d2e926b08db68231710f4c
parent12a858436ca802d9500efef6fbf8a6f6a988bd7a (diff)
This commit was manufactured by cvs2svn to create tagOOO_BUILD_1_9_114
'OOO_BUILD_1_9_114'.
-rw-r--r--scratch/canvas-cairo/POSITION1
-rw-r--r--scratch/canvas-cairo/cairo_backbuffer.cxx128
-rw-r--r--scratch/canvas-cairo/cairo_backbuffer.hxx100
-rw-r--r--scratch/canvas-cairo/cairo_bitmapbackbuffer.cxx190
-rw-r--r--scratch/canvas-cairo/cairo_bitmapbackbuffer.hxx135
-rw-r--r--scratch/canvas-cairo/cairo_cachedbitmap.cxx171
-rw-r--r--scratch/canvas-cairo/cairo_cachedbitmap.hxx148
-rw-r--r--scratch/canvas-cairo/cairo_cairo.hxx16
-rw-r--r--scratch/canvas-cairo/cairo_canvasbitmap.cxx168
-rw-r--r--scratch/canvas-cairo/cairo_canvasbitmap.hxx158
-rw-r--r--scratch/canvas-cairo/cairo_canvasbitmaphelper.cxx231
-rw-r--r--scratch/canvas-cairo/cairo_canvasbitmaphelper.hxx132
-rw-r--r--scratch/canvas-cairo/cairo_canvascustomsprite.cxx693
-rw-r--r--scratch/canvas-cairo/cairo_canvascustomsprite.hxx236
-rw-r--r--scratch/canvas-cairo/cairo_canvasfont.cxx192
-rw-r--r--scratch/canvas-cairo/cairo_canvasfont.hxx149
-rw-r--r--scratch/canvas-cairo/cairo_canvashelper.cxx916
-rw-r--r--scratch/canvas-cairo/cairo_canvashelper.hxx339
-rw-r--r--scratch/canvas-cairo/cairo_canvashelper_texturefill.cxx220
-rw-r--r--scratch/canvas-cairo/cairo_helper.cxx149
-rw-r--r--scratch/canvas-cairo/cairo_helper.hxx14
-rw-r--r--scratch/canvas-cairo/cairo_impltools.cxx443
-rw-r--r--scratch/canvas-cairo/cairo_impltools.hxx258
-rw-r--r--scratch/canvas-cairo/cairo_linepolypolygon.cxx114
-rw-r--r--scratch/canvas-cairo/cairo_linepolypolygon.hxx100
-rw-r--r--scratch/canvas-cairo/cairo_outdevprovider.hxx92
-rw-r--r--scratch/canvas-cairo/cairo_parametricpolypolygon.cxx899
-rw-r--r--scratch/canvas-cairo/cairo_parametricpolypolygon.hxx223
-rw-r--r--scratch/canvas-cairo/cairo_redrawmanager.cxx553
-rw-r--r--scratch/canvas-cairo/cairo_redrawmanager.hxx201
-rw-r--r--scratch/canvas-cairo/cairo_repainttarget.hxx97
-rw-r--r--scratch/canvas-cairo/cairo_sprite.hxx131
-rw-r--r--scratch/canvas-cairo/cairo_spritecanvas.cxx559
-rw-r--r--scratch/canvas-cairo/cairo_spritecanvas.hxx234
-rw-r--r--scratch/canvas-cairo/cairo_spritesurface.hxx106
-rw-r--r--scratch/canvas-cairo/cairo_textlayout.cxx418
-rw-r--r--scratch/canvas-cairo/cairo_textlayout.hxx157
-rw-r--r--scratch/canvas-cairo/cairo_windowgraphicdevice.cxx486
-rw-r--r--scratch/canvas-cairo/cairo_windowgraphicdevice.hxx205
-rw-r--r--scratch/canvas-cairo/exports.dxp3
-rw-r--r--scratch/canvas-cairo/exports.map9
-rw-r--r--scratch/canvas-cairo/makefile.mk127
42 files changed, 0 insertions, 9901 deletions
diff --git a/scratch/canvas-cairo/POSITION b/scratch/canvas-cairo/POSITION
deleted file mode 100644
index b720dcd47..000000000
--- a/scratch/canvas-cairo/POSITION
+++ /dev/null
@@ -1 +0,0 @@
-canvas/source/cairo
diff --git a/scratch/canvas-cairo/cairo_backbuffer.cxx b/scratch/canvas-cairo/cairo_backbuffer.cxx
deleted file mode 100644
index bc219de47..000000000
--- a/scratch/canvas-cairo/cairo_backbuffer.cxx
+++ /dev/null
@@ -1,128 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include "cairo_backbuffer.hxx"
-#include "cairo_cairo.hxx"
-
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- BackBuffer::BackBuffer( WindowGraphicDevice::ImplRef xGraphicDevice, Format aFormat ) : mxGraphicDevice( xGraphicDevice ), mpSurface( NULL ), mpCairo( NULL ), maSize( xGraphicDevice->getSurfaceSize() ), maFormat( aFormat )
- {
- printf("BackBuffer constructor\n");
- }
-
- BackBuffer::~BackBuffer()
- {
- printf("BackBuffer destructor\n");
- if( mpCairo )
- cairo_destroy( mpCairo );
- if( mpSurface )
- cairo_surface_destroy( mpSurface );
- mxGraphicDevice.reset();
- }
-
- void BackBuffer::setSize( const ::Size& rNewSize )
- {
- printf("BackBuffer::setSize called\n");
- if( rNewSize != maSize ) {
- maSize = rNewSize;
- printf ("back buffer (%p) size: %d x %d\n", this, maSize.Width(), maSize.Height() );
- if( mpSurface )
- createSurface();
- }
- }
-
- Surface* BackBuffer::getSurface()
- {
- if( !mpSurface ) {
- printf ("back buffer size: %d x %d\n", maSize.Width(), maSize.Height() );
- createSurface();
- }
- return mpSurface;
- }
-
- void BackBuffer::createSurface()
- {
- Surface* pNewSurface = mxGraphicDevice->getSimilarSurface( maSize, maFormat );
-
- if( mpSurface )
- cairo_surface_destroy( mpSurface );
- if( mpCairo )
- cairo_destroy( mpCairo );
-
- mpSurface = pNewSurface;
- mpCairo = cairo_create( mpSurface );
- }
-
- Cairo* BackBuffer::getCairo()
- {
- if( !mpCairo )
- getSurface();
- return mpCairo;
- }
-
- Size BackBuffer::getSize()
- {
- return maSize;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_backbuffer.hxx b/scratch/canvas-cairo/cairo_backbuffer.hxx
deleted file mode 100644
index c7c485f28..000000000
--- a/scratch/canvas-cairo/cairo_backbuffer.hxx
+++ /dev/null
@@ -1,100 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _CAIRO_CANVAS_BACKBUFFER_HXX_
-#define _CAIRO_CANVAS_BACKBUFFER_HXX_
-
-#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
-#include <boost/shared_ptr.hpp>
-#endif
-
-#include "cairo_windowgraphicdevice.hxx"
-
-namespace vclcanvas
-{
- /// OutDevProvider implementation for backbuffer VDev
- class BackBuffer
- {
- public:
- BackBuffer( WindowGraphicDevice::ImplRef xGraphicDevice,
- ::cairo::Format aFormat = ::cairo::CAIRO_FORMAT_ARGB32 );
- ~BackBuffer();
-
- Size getSize();
- void setSize( const ::Size& rNewSize );
- ::cairo::Surface* getSurface();
- ::cairo::Cairo* getCairo();
-
- private:
- void createSurface();
-
- WindowGraphicDevice::ImplRef mxGraphicDevice;
- Size maSize;
- ::cairo::Surface* mpSurface;
- ::cairo::Cairo* mpCairo;
- ::cairo::Format maFormat;
- };
-
- typedef ::boost::shared_ptr< BackBuffer > BackBufferSharedPtr;
-
-}
-
-#endif /* #ifndef _CAIRO_CANVAS_BACKBUFFER_HXX_ */
diff --git a/scratch/canvas-cairo/cairo_bitmapbackbuffer.cxx b/scratch/canvas-cairo/cairo_bitmapbackbuffer.cxx
deleted file mode 100644
index 5e5c83c43..000000000
--- a/scratch/canvas-cairo/cairo_bitmapbackbuffer.cxx
+++ /dev/null
@@ -1,190 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include "cairo_bitmapbackbuffer.hxx"
-
-#ifndef _OSL_MUTEX_HXX_
-#include <osl/mutex.hxx>
-#endif
-#ifndef _VOS_MUTEX_HXX_
-#include <vos/mutex.hxx>
-#endif
-
-#ifndef _SV_SVAPP_HXX
-#include <vcl/svapp.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-
-
-namespace vclcanvas
-{
- BitmapBackBuffer::BitmapBackBuffer( const BitmapEx& rBitmap,
- const OutputDevice& rRefDevice ) :
- maBitmap( rBitmap ),
- mpVDev( NULL ),
- mrRefDevice( rRefDevice ),
- mbBitmapContentIsCurrent( false ),
- mbVDevContentIsCurrent( false )
- {
- }
-
- BitmapBackBuffer::~BitmapBackBuffer()
- {
- // make sure solar mutex is held on deletion (other methods
- // are supposed to be called with already locked solar mutex)
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- if( mpVDev )
- delete mpVDev;
- }
-
- OutputDevice& BitmapBackBuffer::getOutDev()
- {
- createVDev();
- updateVDev();
- return *mpVDev;
- }
-
- const OutputDevice& BitmapBackBuffer::getOutDev() const
- {
- createVDev();
- updateVDev();
- return *mpVDev;
- }
-
- VirtualDevice& BitmapBackBuffer::getVirDev()
- {
- createVDev();
- updateVDev();
- return *mpVDev;
- }
-
- const VirtualDevice& BitmapBackBuffer::getVirDev() const
- {
- createVDev();
- updateVDev();
- return *mpVDev;
- }
-
- BitmapEx& BitmapBackBuffer::getBitmapReference()
- {
- OSL_ENSURE( !mbBitmapContentIsCurrent || !mbVDevContentIsCurrent,
- "BitmapBackBuffer::getBitmapReference(): Both bitmap and VDev are valid?!" );
-
- if( mbVDevContentIsCurrent && mpVDev )
- {
- // VDev content is more current than bitmap - copy contents before!
- mpVDev->EnableMapMode( FALSE );
- const Point aEmptyPoint;
- *maBitmap = mpVDev->GetBitmapEx( aEmptyPoint,
- mpVDev->GetOutputSizePixel() );
- }
-
- // client queries bitmap, and will possibly alter content -
- // next time, VDev needs to be updated
- mbBitmapContentIsCurrent = true;
- mbVDevContentIsCurrent = false;
-
- return *maBitmap;
- }
-
- void BitmapBackBuffer::createVDev() const
- {
- if( !mpVDev )
- {
- // VDev not yet created, do it now. Create an alpha-VDev,
- // if bitmap has transparency.
- mpVDev = maBitmap->IsTransparent() ?
- new VirtualDevice( mrRefDevice, 0, 0 ) :
- new VirtualDevice( mrRefDevice );
-
- OSL_ENSURE( mpVDev,
- "BitmapBackBuffer::createVDev(): Unable to create VirtualDevice" );
-
- mpVDev->SetOutputSizePixel( maBitmap->GetSizePixel() );
- }
- }
-
- void BitmapBackBuffer::updateVDev() const
- {
- OSL_ENSURE( !mbBitmapContentIsCurrent || !mbVDevContentIsCurrent,
- "BitmapBackBuffer::updateVDev(): Both bitmap and VDev are valid?!" );
-
- if( mpVDev && mbBitmapContentIsCurrent )
- {
- // fill with bitmap content
- mpVDev->EnableMapMode( FALSE );
- const Point aEmptyPoint;
- mpVDev->DrawBitmapEx( aEmptyPoint, *maBitmap );
- }
-
- // canvas queried the VDev, and will possibly paint into
- // it. Next time, bitmap must be updated
- mbBitmapContentIsCurrent = false;
- mbVDevContentIsCurrent = true;
- }
-
-}
diff --git a/scratch/canvas-cairo/cairo_bitmapbackbuffer.hxx b/scratch/canvas-cairo/cairo_bitmapbackbuffer.hxx
deleted file mode 100644
index b5f69247a..000000000
--- a/scratch/canvas-cairo/cairo_bitmapbackbuffer.hxx
+++ /dev/null
@@ -1,135 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_BITMAPBACKBUFFER_HXX_
-#define _VCLCANVAS_BITMAPBACKBUFFER_HXX_
-
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-#include "cairo_outdevprovider.hxx"
-
-
-namespace vclcanvas
-{
- /** OutDevProvider implementation for canvas bitmap.
-
- This class implements the OutDevProvider interface for the
- bitmap canvas. The actual VirtualDevice is only created when
- necessary, which makes read-only bitmaps a lot smaller.
- */
- class BitmapBackBuffer : public OutDevProvider
- {
- public:
- /** Create a backbuffer for given reference device
- */
- BitmapBackBuffer( const BitmapEx& rBitmap,
- const OutputDevice& rRefDevice );
-
- ~BitmapBackBuffer();
-
- virtual OutputDevice& getOutDev();
- virtual const OutputDevice& getOutDev() const;
-
- VirtualDevice& getVirDev();
- const VirtualDevice& getVirDev() const;
-
- /** Exposing our internal bitmap. Only to be used from
- CanvasBitmapHelper
-
- @internal
- */
- BitmapEx& getBitmapReference();
-
- private:
- void createVDev() const;
- void updateVDev() const;
-
- ::canvas::vcltools::VCLObject<BitmapEx> maBitmap;
- mutable VirtualDevice* mpVDev; // created only on demand
-
- const OutputDevice& mrRefDevice;
-
- /** When true, the bitmap contains the last valid
- content. When false, and mbVDevContentIsCurrent is true,
- the VDev contains the last valid content (which must be
- copied back to the bitmap, when getBitmapReference() is
- called). When both are false, this object is just
- initialized.
- */
- mutable bool mbBitmapContentIsCurrent;
-
- /** When true, and mpVDev is non-NULL, the VDev contains the
- last valid content. When false, and
- mbBitmapContentIsCurrent is true, the bitmap contains the
- last valid content. When both are false, this object is
- just initialized.
- */
- mutable bool mbVDevContentIsCurrent;
- };
-
- typedef ::boost::shared_ptr< BitmapBackBuffer > BitmapBackBufferSharedPtr;
-
-}
-
-#endif /* #ifndef _VCLCANVAS_BITMAPBACKBUFFER_HXX_ */
diff --git a/scratch/canvas-cairo/cairo_cachedbitmap.cxx b/scratch/canvas-cairo/cairo_cachedbitmap.cxx
deleted file mode 100644
index 51ffde76b..000000000
--- a/scratch/canvas-cairo/cairo_cachedbitmap.cxx
+++ /dev/null
@@ -1,171 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#include "cairo_cachedbitmap.hxx"
-#include "cairo_repainttarget.hxx"
-
-#ifndef _COM_SUN_STAR_RENDERING_REPAINTRESULT_HPP_
-#include <com/sun/star/rendering/RepaintResult.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XPOLYPOLYGON2D_HPP_
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#endif
-
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-
-
-using namespace ::com::sun::star;
-
-
-#define IMPLEMENTATION_NAME "CairoCanvas::CachedBitmap"
-#define SERVICE_NAME "com.sun.star.rendering.CachedBitmap"
-
-namespace vclcanvas
-{
- CachedBitmap::CachedBitmap( const GraphicObjectSharedPtr& rGraphicObject,
- const ::Point& rPoint,
- const ::Size& rSize,
- const GraphicAttr& rAttr,
- const rendering::ViewState& rUsedViewState,
- const uno::Reference< rendering::XCanvas >& rTarget ) :
- CachedBitmap_Base( m_aMutex ),
- mpGraphicObject( rGraphicObject ),
- maPoint( rPoint ),
- maSize( rSize ),
- maAttributes( rAttr ),
- maUsedViewState( rUsedViewState ),
- mxTarget( rTarget )
- {
- }
-
- CachedBitmap::~CachedBitmap()
- {
- }
-
- void SAL_CALL CachedBitmap::disposing()
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- maUsedViewState.Clip.clear();
- mpGraphicObject.reset();
- mxTarget.clear();
- }
-
- sal_Int8 SAL_CALL CachedBitmap::redraw( const rendering::ViewState& aState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- ::basegfx::B2DHomMatrix aUsedTransformation;
- ::basegfx::B2DHomMatrix aNewTransformation;
-
- ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
- maUsedViewState.AffineTransform );
- ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
- aState.AffineTransform );
-
- if( aUsedTransformation != aNewTransformation )
- {
- // differing transformations, don't try to draft the
- // output, just plain fail here.
- return rendering::RepaintResult::FAILED;
- }
-
- RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(mxTarget.get());
-
- ENSURE_AND_THROW( pTarget,
- "CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
-
-
- if( !pTarget->repaint( mpGraphicObject,
- maPoint,
- maSize,
- maAttributes ) )
- {
- // target failed to repaint
- return rendering::RepaintResult::FAILED;
- }
-
- return rendering::RepaintResult::REDRAWN;
- }
-
- ::rtl::OUString SAL_CALL CachedBitmap::getImplementationName( ) throw (uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL CachedBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL CachedBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException)
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_cachedbitmap.hxx b/scratch/canvas-cairo/cairo_cachedbitmap.hxx
deleted file mode 100644
index 85c55c2e2..000000000
--- a/scratch/canvas-cairo/cairo_cachedbitmap.hxx
+++ /dev/null
@@ -1,148 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_CACHEDBITMAP_HXX
-#define _VCLCANVAS_CACHEDBITMAP_HXX
-
-#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
-#include <com/sun/star/uno/Reference.hxx>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP_
-#include <com/sun/star/rendering/XCanvas.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XCACHEDPRIMITIVE_HPP_
-#include <com/sun/star/rendering/XCachedPrimitive.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_VIEWSTATE_HPP__
-#include <com/sun/star/rendering/ViewState.hpp>
-#endif
-
-#ifndef _CPPUHELPER_COMPBASE2_HXX_
-#include <cppuhelper/compbase2.hxx>
-#endif
-#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
-#include <comphelper/broadcasthelper.hxx>
-#endif
-
-#ifndef _GRFMGR_HXX
-#include <goodies/grfmgr.hxx>
-#endif
-
-#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
-#include <boost/shared_ptr.hpp>
-#endif
-
-
-/* Definition of CachedBitmap class */
-
-namespace vclcanvas
-{
- typedef ::boost::shared_ptr< GraphicObject > GraphicObjectSharedPtr;
-
- typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive,
- ::com::sun::star::lang::XServiceInfo > CachedBitmap_Base;
-
- class CachedBitmap : public ::comphelper::OBaseMutex, public CachedBitmap_Base
- {
- public:
-
- /** Create an XCachedPrimitive for given GraphicObject
- */
- CachedBitmap( const GraphicObjectSharedPtr& rGraphicObject,
- const ::Point& rPoint,
- const ::Size& rSize,
- const GraphicAttr& rAttr,
- const ::com::sun::star::rendering::ViewState& rUsedViewState,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvas >& rTarget );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XCachedPrimitive
- virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
-
- protected:
- ~CachedBitmap(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- CachedBitmap(const CachedBitmap&);
- CachedBitmap& operator=( const CachedBitmap& );
-
- GraphicObjectSharedPtr mpGraphicObject;
- const ::Point maPoint;
- const ::Size maSize;
- const GraphicAttr maAttributes;
- ::com::sun::star::rendering::ViewState maUsedViewState;
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget;
- };
-}
-
-#endif /* _VCLCANVAS_CACHEDBITMAP_HXX */
diff --git a/scratch/canvas-cairo/cairo_cairo.hxx b/scratch/canvas-cairo/cairo_cairo.hxx
deleted file mode 100644
index 0f936edc3..000000000
--- a/scratch/canvas-cairo/cairo_cairo.hxx
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _CAIROCANVAS_CAIRO_HXX
-#define _CAIROCANVAS_CAIRO_HXX
-
-namespace cairo {
-#ifndef CAIRO_H
-#include <cairo.h>
-#endif
-
-typedef cairo_surface_t Surface;
-typedef cairo_t Cairo;
-typedef cairo_matrix_t Matrix;
-typedef cairo_format_t Format;
-
-}
-
-#endif
diff --git a/scratch/canvas-cairo/cairo_canvasbitmap.cxx b/scratch/canvas-cairo/cairo_canvasbitmap.cxx
deleted file mode 100644
index 02b11edc0..000000000
--- a/scratch/canvas-cairo/cairo_canvasbitmap.cxx
+++ /dev/null
@@ -1,168 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-#include "cairo_canvasbitmap.hxx"
-
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- CanvasBitmap::CanvasBitmap( const ::Size& rSize,
- bool bAlphaBitmap,
- const WindowGraphicDevice::ImplRef& rDevice )
- {
- WindowGraphicDevice::ImplRef xDevice = rDevice;
-
- printf("canvas bitmap constructor\n");
-
- mpCairo = cairo_create( xDevice->getSimilarSurface( rSize, bAlphaBitmap ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24 ) );
- maCanvasHelper.setCairo( mpCairo );
- maCanvasHelper.setDevice( rDevice );
- }
-
- CanvasBitmap::CanvasBitmap( const geometry::RealSize2D& rSize, Surface* pSrcSurface,
- const WindowGraphicDevice::ImplRef& rDevice )
- {
- WindowGraphicDevice::ImplRef xDevice = rDevice;
-
- printf("canvas bitmap constructor\n");
-
- mpCairo = cairo_create( xDevice->getSimilarSurface( ::vcl::unotools::sizeFromRealSize2D(rSize), CAIRO_FORMAT_RGB24 ) );
- maCanvasHelper.setCairo( mpCairo );
- maCanvasHelper.setDevice( rDevice );
-
- geometry::RealSize2D aSrcSize = xDevice->getSize();
-
- cairo_save( mpCairo );
- cairo_set_source_surface( mpCairo, pSrcSurface, 0, 0 );
- cairo_scale( mpCairo, rSize.Width/aSrcSize.Width, rSize.Height/aSrcSize.Height );
- cairo_set_operator( mpCairo, CAIRO_OPERATOR_SOURCE );
- cairo_paint( mpCairo );
- cairo_restore( mpCairo );
- }
-
- CanvasBitmap::~CanvasBitmap()
- {
- Surface *pSurface = cairo_get_target( mpCairo );
-
- printf("canvas bitmap destructor\n");
-
- cairo_destroy( mpCairo );
- cairo_surface_destroy( pSurface );
- }
-
- void SAL_CALL CanvasBitmap::disposing()
- {
- tools::LocalGuard aGuard;
-
- // forward to parent
- CanvasBitmap_Base::disposing();
- }
-
-#define SERVICE_NAME "com.sun.star.rendering.CanvasBitmap"
-
- ::rtl::OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASBITMAP_IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL CanvasBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException)
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
- bool CanvasBitmap::repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const
- {
- tools::LocalGuard aGuard;
-
- mbSurfaceDirty = true;
-
- return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
- }
-
- Cairo* CanvasBitmap::getCairo()
- {
- return mpCairo;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_canvasbitmap.hxx b/scratch/canvas-cairo/cairo_canvasbitmap.hxx
deleted file mode 100644
index 5d07629e6..000000000
--- a/scratch/canvas-cairo/cairo_canvasbitmap.hxx
+++ /dev/null
@@ -1,158 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_CANVASBITMAP_HXX
-#define _VCLCANVAS_CANVASBITMAP_HXX
-
-#ifndef _CPPUHELPER_COMPBASE3_HXX_
-#include <cppuhelper/compbase3.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XBITMAPCANVAS_HPP_
-#include <com/sun/star/rendering/XBitmapCanvas.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP_
-#include <com/sun/star/rendering/XIntegerBitmap.hpp>
-#endif
-
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include <canvas/bitmapcanvasbase.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_canvasbitmaphelper.hxx"
-#include "cairo_impltools.hxx"
-#include "cairo_repainttarget.hxx"
-
-
-#define CANVASBITMAP_IMPLEMENTATION_NAME "CairoCanvas::CanvasBitmap"
-
-/* Definition of CanvasBitmap class */
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::rendering::XBitmapCanvas,
- ::com::sun::star::rendering::XIntegerBitmap,
- ::com::sun::star::lang::XServiceInfo > CanvasBitmapBase_Base;
- typedef ::canvas::internal::BitmapCanvasBase< CanvasBitmapBase_Base, CanvasBitmapHelper, tools::LocalGuard > CanvasBitmap_Base;
-
- class CanvasBitmap : public CanvasBitmap_Base,
- public RepaintTarget
- {
- public:
- /** Must be called with locked Solar mutex
-
- @param rSize
- Size in pixel of the bitmap to generate
-
- @param bAlphaBitmap
- When true, bitmap will have an alpha channel
-
- @param rDevice
- Reference device, with which bitmap should be compatible
- */
- CanvasBitmap( const ::Size& rSize,
- bool bAlphaBitmap,
- const WindowGraphicDevice::ImplRef& rDevice );
-
- /// Must be called with locked Solar mutex
- CanvasBitmap::CanvasBitmap( const ::com::sun::star::geometry::RealSize2D& rSize, ::cairo::Surface* pSrcSurface,
- const WindowGraphicDevice::ImplRef& rDevice );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
-
- // RepaintTarget interface
- virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const;
-
- ::cairo::Cairo* getCairo();
-
- protected:
- ~CanvasBitmap(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- CanvasBitmap(const CanvasBitmap&);
- CanvasBitmap& operator=( const CanvasBitmap& );
-
- ::cairo::Cairo* mpCairo;
- };
-}
-
-#endif /* _VCLCANVAS_CANVASBITMAP_HXX */
diff --git a/scratch/canvas-cairo/cairo_canvasbitmaphelper.cxx b/scratch/canvas-cairo/cairo_canvasbitmaphelper.cxx
deleted file mode 100644
index a83a76e5a..000000000
--- a/scratch/canvas-cairo/cairo_canvasbitmaphelper.cxx
+++ /dev/null
@@ -1,231 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef _RTL_LOGFILE_HXX_
-#include <rtl/logfile.hxx>
-#endif
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _TL_POLY_HXX
-#include <tools/poly.hxx>
-#endif
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-
-#include "cairo_canvasbitmap.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace vclcanvas
-{
- CanvasBitmapHelper::CanvasBitmapHelper() :
- mpBackBuffer()
- {
- }
-
- void CanvasBitmapHelper::setDevice( const WindowGraphicDevice::ImplRef& rDevice )
- {
- ENSURE_AND_THROW( rDevice.is(),
- "CanvasBitmapHelper::setBitmap(): Invalid reference device" );
-
- mpBackBuffer.reset( new BackBuffer( rDevice ) );
-
- // forward new settings to base class
- setGraphicDevice( rDevice );
- }
-
- void CanvasBitmapHelper::disposing()
- {
- mpBackBuffer.reset();
-
- // forward to base class
- CanvasHelper::disposing();
- }
-
- geometry::IntegerSize2D SAL_CALL CanvasBitmapHelper::getSize()
- {
- if( !mpBackBuffer.get() )
- return geometry::IntegerSize2D();
-
- return ::vcl::unotools::integerSize2DFromSize( mpBackBuffer->getSize() );
- }
-
- uno::Reference< rendering::XBitmap > SAL_CALL CanvasBitmapHelper::getScaledBitmap( const geometry::RealSize2D& newSize,
- sal_Bool beFast )
- {
- printf ("CanvasBitmapHelper::getScaledBitmap TODO\n");
-
- RTL_LOGFILE_CONTEXT( aLog, "::cairocanvas::CanvasBitmapHelper::getScaledBitmap()" );
-
- if( !mpBackBuffer.get() )
- return uno::Reference< rendering::XBitmap >(); // we're disposed
-
- return uno::Reference< rendering::XBitmap >(); // we're disposed
- }
-
- uno::Sequence< sal_Int8 > SAL_CALL CanvasBitmapHelper::getData( const geometry::IntegerRectangle2D& rect )
- {
- printf ("CanvasBitmapHelper::getData TODO\n");
-
- RTL_LOGFILE_CONTEXT( aLog, "::cairocanvas::CanvasBitmapHelper::getData()" );
-
- if( !mpBackBuffer.get() )
- return uno::Sequence< sal_Int8 >(); // we're disposed
-
- return uno::Sequence< sal_Int8 >(); // we're disposed
- }
-
- void SAL_CALL CanvasBitmapHelper::setData( const uno::Sequence< sal_Int8 >& data,
- const geometry::IntegerRectangle2D& rect )
- {
- printf ("CanvasBitmapHelper::setData TODO\n");
-
- RTL_LOGFILE_CONTEXT( aLog, "::cairocanvas::CanvasBitmapHelper::setData()" );
-
- if( !mpBackBuffer.get() )
- return; // we're disposed
-
- return;
- }
-
- void SAL_CALL CanvasBitmapHelper::setPixel( const uno::Sequence< sal_Int8 >& color,
- const geometry::IntegerPoint2D& pos )
- {
- printf ("CanvasBitmapHelper::setPixel TODO\n");
-
- RTL_LOGFILE_CONTEXT( aLog, "::cairocanvas::CanvasBitmapHelper::setPixel()" );
-
- if( !mpBackBuffer.get() )
- return; // we're disposed
-
- return;
- }
-
- uno::Sequence< sal_Int8 > SAL_CALL CanvasBitmapHelper::getPixel( const geometry::IntegerPoint2D& pos )
- {
- printf ("CanvasBitmapHelper::getPixel TODO\n");
-
- RTL_LOGFILE_CONTEXT( aLog, "::cairocanvas::CanvasBitmapHelper::getPixel()" );
-
- if( !mpBackBuffer.get() )
- return uno::Sequence< sal_Int8 >(); // we're disposed
-
- return uno::Sequence< sal_Int8 >(); // we're disposed
- }
-
- uno::Reference< rendering::XBitmapPalette > SAL_CALL CanvasBitmapHelper::getPalette()
- {
- // TODO(F1): Provide palette support
- return uno::Reference< rendering::XBitmapPalette >();
- }
-
- rendering::IntegerBitmapLayout SAL_CALL CanvasBitmapHelper::getMemoryLayout()
- {
- // TODO(F1): finish that one
- rendering::IntegerBitmapLayout aLayout;
-
- if( !mpBackBuffer.get() )
- return aLayout; // we're disposed
-
- const Size aBmpSize( mpBackBuffer->getSize() );
-
- aLayout.ScanLines = aBmpSize.Height();
- aLayout.ScanLineBytes = aBmpSize.Width()*4;
- aLayout.ScanLineStride = aLayout.ScanLineBytes;
- aLayout.Format = 0;
- aLayout.NumComponents = 4;
- aLayout.ComponentMasks = uno::Sequence<sal_Int64>();
- aLayout.Endianness = 0;
- aLayout.IsPseudoColor = false;
-
- return aLayout;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_canvasbitmaphelper.hxx b/scratch/canvas-cairo/cairo_canvasbitmaphelper.hxx
deleted file mode 100644
index 8d56efba8..000000000
--- a/scratch/canvas-cairo/cairo_canvasbitmaphelper.hxx
+++ /dev/null
@@ -1,132 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_CANVASBITMAPHELPER_HXX_
-#define _VCLCANVAS_CANVASBITMAPHELPER_HXX_
-
-#include "cairo_canvashelper.hxx"
-
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include "cairo_backbuffer.hxx"
-
-
-namespace vclcanvas
-{
- /** Helper class for basic canvasbitmap functionality. Extends
- CanvasHelper with some CanvasBitmap specialities, such as alpha
- support.
-
- Note that a plain CanvasHelper, although it does support the
- XBitmap interface, has no provision for alpha channel on VCL
- (at least no efficient one. If the alpha VDev one day gets
- part of SAL, we might change that).
- */
- class CanvasBitmapHelper : public CanvasHelper
- {
- public:
- CanvasBitmapHelper();
-
- void setDevice( const WindowGraphicDevice::ImplRef& rDevice );
-
- // Overridden CanvasHelper functionality
- // =====================================
-
- void disposing();
-
- ::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > SAL_CALL queryBitmapCanvas();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL
- getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize,
- sal_Bool beFast );
-
- ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
- getData( const ::com::sun::star::geometry::IntegerRectangle2D& rect );
-
- void SAL_CALL setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data,
- const ::com::sun::star::geometry::IntegerRectangle2D& rect );
-
- void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color,
- const ::com::sun::star::geometry::IntegerPoint2D& pos );
-
- ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
- getPixel( const ::com::sun::star::geometry::IntegerPoint2D& pos );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > SAL_CALL getPalette();
-
- ::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout();
-
- private:
- // default: disabled copy/assignment
- CanvasBitmapHelper(const CanvasBitmapHelper&);
- CanvasBitmapHelper& operator=( const CanvasBitmapHelper& );
-
- BackBufferSharedPtr mpBackBuffer;
- };
-}
-
-#endif /* _VCLCANVAS_CANVASBITMAPHELPER_HXX_ */
diff --git a/scratch/canvas-cairo/cairo_canvascustomsprite.cxx b/scratch/canvas-cairo/cairo_canvascustomsprite.cxx
deleted file mode 100644
index 2336f6088..000000000
--- a/scratch/canvas-cairo/cairo_canvascustomsprite.cxx
+++ /dev/null
@@ -1,693 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-#include <canvas/verbosetrace.hxx>
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _SV_OUTDEV_HXX
-#include <vcl/outdev.hxx>
-#endif
-#ifndef _SV_BITMAP_HXX
-#include <vcl/bitmap.hxx>
-#endif
-#ifndef _SV_ALPHA_HXX
-#include <vcl/alpha.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_SYSDATA_HXX
-#include <vcl/sysdata.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
-#include <basegfx/polygon/b2dpolygon.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-
-#include "cairo_canvascustomsprite.hxx"
-
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
-
- CanvasCustomSprite::CanvasCustomSprite( const geometry::RealSize2D& rSpriteSize,
- const WindowGraphicDevice::ImplRef& rDevice,
- const SystemEnvData* pSysData,
- const SpriteCanvas::ImplRef& rSpriteCanvas ) :
- mpBackBuffer(),
- mpBackBufferMask(),
- mpSpriteCanvas( rSpriteCanvas ),
- maContent(),
- maCurrClipBounds(),
- maPosition(0.0, 0.0),
- maSize( static_cast< sal_Int32 >(
- ::std::max( 1.0,
- ceil( rSpriteSize.Width ) ) ), // round up to nearest int,
- // enforce sprite to have at
- // least (1,1) pixel size
- static_cast< sal_Int32 >(
- ::std::max( 1.0,
- ceil( rSpriteSize.Height ) ) ) ),
- maTransform(),
- mxClipPoly(),
- mfAlpha(0.0),
- mbActive(false),
- mbIsCurrClipRectangle(true),
- mbIsContentFullyOpaque( false ),
- mbTransformDirty( true )
- {
- ENSURE_AND_THROW( rDevice.get() && rSpriteCanvas.get(),
- "CanvasBitmap::CanvasBitmap(): Invalid device or sprite canvas" );
-
- printf("going to create canvas custom sprite\n");
-
- // setup graphic device
- maCanvasHelper.setGraphicDevice( rDevice );
-
-
- // setup back buffer
- // -----------------
-
- // create content backbuffer in screen depth
- mpBackBuffer.reset( new BackBuffer( rDevice ) );
- mpBackBuffer->setSize( maSize );
-
- // create mask backbuffer, with one bit color depth
- mpBackBufferMask.reset( new BackBuffer( rDevice ) );
- mpBackBufferMask->setSize( maSize );
-
- // setup canvas helper
- // -------------------
-
- // always render into back buffer, don't preserve state
- // (it's our private VDev, after all)
- maCanvasHelper.setCairo( mpBackBuffer->getCairo() );
- // rodo TODO maCanvasHelper.setBackgroundOutDev( mpBackBufferMask );
- }
-
- CanvasCustomSprite::~CanvasCustomSprite()
- {
- }
-
- void SAL_CALL CanvasCustomSprite::disposing()
- {
- tools::LocalGuard aGuard;
-
- mpSpriteCanvas.clear();
-
- // forward to parent
- CanvasCustomSprite_Base::disposing();
- }
-
- void SAL_CALL CanvasCustomSprite::setAlpha( double alpha ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( !mpSpriteCanvas.get() )
- return; // we're disposed
-
- ::canvas::tools::checkRange(alpha, 0.0, 1.0);
-
- if( alpha != mfAlpha )
- {
- mfAlpha = alpha;
-
- if( mbActive )
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- getSpriteRect() );
- }
- }
-
- void SAL_CALL CanvasCustomSprite::move( const geometry::RealPoint2D& aNewPos,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- printf ("custom sprite move to new pos %f, %f\n", aNewPos.X, aNewPos.Y);
-
- if( !mpSpriteCanvas.get() )
- return; // we're disposed
-
- ::basegfx::B2DHomMatrix aTransform;
- ::canvas::tools::mergeViewAndRenderTransform(aTransform,
- viewState,
- renderState);
-
- ::basegfx::B2DPoint aPoint( ::basegfx::unotools::b2DPointFromRealPoint2D(aNewPos) );
- aPoint *= aTransform;
-
- if( aPoint != maPosition )
- {
- const ::Rectangle& rBounds( getFullSpriteRect() );
- const ::basegfx::B2DPoint& rOutPos(
- ::vcl::unotools::b2DPointFromPoint( rBounds.TopLeft() ) );
-
- if( mbActive )
- mpSpriteCanvas->moveSprite( Sprite::ImplRef( this ),
- rBounds.TopLeft(),
- ::vcl::unotools::pointFromB2DPoint(
- rOutPos - maPosition + aPoint ),
- rBounds.GetSize() );
-
- maPosition = aPoint;
- }
- }
-
- void SAL_CALL CanvasCustomSprite::transform( const geometry::AffineMatrix2D& aTransformation ) throw (lang::IllegalArgumentException,
- uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- ::basegfx::B2DHomMatrix aMatrix;
- ::basegfx::unotools::homMatrixFromAffineMatrix(aMatrix,
- aTransformation);
-
- if( maTransform != aMatrix )
- {
- // retrieve bounds before and after transformation change,
- // and calc union of them, as the resulting update area.
- Rectangle aPrevBounds(
- getSpriteRect() );
-
- maTransform = aMatrix;
-
- aPrevBounds.Union( getSpriteRect() );
-
- if( mbActive )
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- aPrevBounds );
-
- mbTransformDirty = true;
- }
- }
-
- namespace
- {
- /** This method computes the up to four rectangles that make
- up the set difference between two rectangles.
-
- @param a
- First rect
-
- @param b
- Second rect
-
- @param out
- Pointer to an array of at least four elements, herein, the
- resulting parts of the set difference are returned.
-
- @return
- The number of rectangles written to the out array.
- */
- unsigned int b2dRectComputeSetDifference( const ::basegfx::B2DRectangle& a,
- const ::basegfx::B2DRectangle& b,
- ::basegfx::B2DRectangle* out )
- {
- OSL_ENSURE( out != NULL,
- "b2dRectComputeSetDifference(): Invalid output array" );
-
- // special-casing the empty rect case (this will fail most
- // of the times below, because of the DBL_MIN/MAX special
- // values denoting emptyness in the rectangle.
- if( a.isEmpty() )
- {
- *out = b;
- return 1;
- }
- if( b.isEmpty() )
- {
- *out = a;
- return 1;
- }
-
- unsigned int num_rectangles = 0;
-
- double ax(a.getMinX());
- double ay(a.getMinY());
- double aw(a.getWidth());
- double ah(a.getHeight());
- double bx(b.getMinX());
- double by(b.getMinY());
- double bw(b.getWidth());
- double bh(b.getHeight());
-
- double h0 = (by > ay) ? by - ay : 0.0;
- double h3 = (by + bh < ay + ah) ? ay + ah - by - bh : 0.0;
- double w1 = (bx > ax) ? bx - ax : 0.0;
- double w2 = (ax + aw > bx + bw) ? ax + aw - bx - bw : 0.0;
- double h12 = (h0 + h3 < ah) ? ah - h0 - h3 : 0.0;
-
- if (h0 > 0)
- out[num_rectangles++] = ::basegfx::B2DRectangle(ax,ay,ax+aw,ay+h0);
-
- if (w1 > 0 && h12 > 0)
- out[num_rectangles++] = ::basegfx::B2DRectangle(ax,ay+h0,ax+w1,ay+h0+h12);
-
- if (w2 > 0 && h12 > 0)
- out[num_rectangles++] = ::basegfx::B2DRectangle(bx+bw,ay+h0,bx+bw+w2,ay+h0+h12);
-
- if (h3 > 0)
- out[num_rectangles++] = ::basegfx::B2DRectangle(ax,ay+h0+h12,ax+aw,ay+h0+h12+h3);
-
- return num_rectangles;
- }
- }
-
- void SAL_CALL CanvasCustomSprite::clip( const uno::Reference< rendering::XPolyPolygon2D >& xClip ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- mxClipPoly = xClip;
-
- if( mbActive )
- {
- const sal_Int32 nNumClipPolygons( mxClipPoly->getNumberOfPolygons() );
-
- if( !mxClipPoly.is() ||
- nNumClipPolygons == 0 )
- {
- // empty clip polygon -> everything is visible now
- maCurrClipBounds.reset();
- mbIsCurrClipRectangle = true;
- }
- else
- {
- // new clip is not empty - determine actual update
- // area
- const ::basegfx::B2DPolyPolygon& rClipPath(
- tools::polyPolygonFromXPolyPolygon2D( mxClipPoly ) );
-
- // clip which is about to be set, expressed as a
- // b2drectangle
- const ::basegfx::B2DRectangle& rClipBounds(
- ::basegfx::tools::getRange( rClipPath ) );
-
- const ::basegfx::B2DRectangle aBounds( 0.0, 0.0,
- maSize.Width(),
- maSize.Height() );
-
- // rectangular area which is actually covered by the sprite.
- // coordinates are relative to the sprite origin.
- ::basegfx::B2DRectangle aSpriteRectPixel;
- ::canvas::tools::calcTransformedRectBounds( aSpriteRectPixel,
- aBounds,
- maTransform );
-
- // aClipBoundsA = new clip [set intersection] sprite
- ::basegfx::B2DRectangle aClipBoundsA(rClipBounds);
- aClipBoundsA.intersect( aSpriteRectPixel );
-
- if( nNumClipPolygons != 1 )
- {
- // new clip cannot be a single rectangle -> cannot
- // optimize update
- mbIsCurrClipRectangle = false;
- maCurrClipBounds = aClipBoundsA;
- }
- else
- {
- // new clip could be a single rectangle
- const bool bNewClipIsRect(
- ::basegfx::tools::isRectangle( rClipPath.getB2DPolygon(0) ) );
-
- // both new and old clip are truly rectangles
- // - can now take the optimized path
- const bool bUseOptimizedUpdate( bNewClipIsRect &&
- mbIsCurrClipRectangle );
-
- const ::basegfx::B2DRectangle aOldBounds( maCurrClipBounds );
-
- // store new current clip type
- maCurrClipBounds = aClipBoundsA;
- mbIsCurrClipRectangle = bNewClipIsRect;
-
- if( bUseOptimizedUpdate )
- {
- // aClipBoundsB = maCurrClipBounds, i.e. last clip [set intersection] sprite
- ::basegfx::B2DRectangle aClipDifference[4];
- const unsigned int num_rectangles(
- b2dRectComputeSetDifference(aClipBoundsA,
- aOldBounds,
- aClipDifference) );
-
- for(unsigned int i=0; i<num_rectangles; ++i)
- {
- // aClipDifference[i] now contains the final
- // update area, coordinates are still relative
- // to the sprite origin. before submitting
- // this area to 'updateSprite()' we need to
- // translate this area to the final position,
- // coordinates need to be relative to the
- // spritecanvas.
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- Rectangle( static_cast< sal_Int32 >( maPosition.getX() + aClipDifference[i].getMinX() ),
- static_cast< sal_Int32 >( maPosition.getY() + aClipDifference[i].getMinY() ),
- static_cast< sal_Int32 >( ceil( maPosition.getX() + aClipDifference[i].getMaxX() ) ),
- static_cast< sal_Int32 >( ceil( maPosition.getY() + aClipDifference[i].getMaxY() ) ) ) );
- }
-
- // early exit, needed to process the four
- // difference rects independently.
- return;
- }
- }
- }
-
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- getSpriteRect() );
- }
- }
-
- void SAL_CALL CanvasCustomSprite::setPriority( double nPriority ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F2): Implement sprite priority
- }
-
- void SAL_CALL CanvasCustomSprite::show() throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( !mpSpriteCanvas.get() )
- return; // we're disposed
-
- if( !mbActive )
- {
- mpSpriteCanvas->showSprite( Sprite::ImplRef( this ) );
- mbActive = true;
-
- if( mfAlpha != 0.0 )
- {
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- getSpriteRect() );
- }
- }
- }
-
- void SAL_CALL CanvasCustomSprite::hide() throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( !mpSpriteCanvas.get() )
- return; // we're disposed
-
- if( mbActive )
- {
- mpSpriteCanvas->hideSprite( Sprite::ImplRef( this ) );
- mbActive = false;
-
- if( mfAlpha != 0.0 )
- {
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- getSpriteRect() );
- }
- }
- }
-
- uno::Reference< rendering::XCanvas > SAL_CALL CanvasCustomSprite::getContentCanvas() throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( !mpSpriteCanvas.get() || !mpBackBuffer.get() )
- uno::Reference< rendering::XCanvas >(); // we're disposed
-
- if( mbActive )
- {
- // the client is about to render into the sprite. Thus,
- // potentially the whole sprite area has changed.
- mpSpriteCanvas->updateSprite( Sprite::ImplRef( this ),
- ::vcl::unotools::pointFromB2DPoint( maPosition ),
- getSpriteRect() );
- }
-
- // clear surface
-// Cairo* pCairo = mpBackBuffer->getCairo();
-// cairo_save( pCairo );
-// cairo_set_source_rgb( pCairo, 1, 1, 1 );
-// cairo_rectangle( pCairo, 0, 0, maSize.Width(), maSize.Height() );
-// cairo_fill( pCairo );
-// cairo_restore( pCairo );
-
- // rodo TODO
-// OutputDevice& rMaskOutDev( mpBackBufferMask->getOutDev() );
-// rMaskOutDev.SetDrawMode( DRAWMODE_DEFAULT );
-// rMaskOutDev.EnableMapMode( FALSE );
-// rMaskOutDev.SetFillColor( Color( COL_WHITE ) );
-// rMaskOutDev.SetLineColor();
-// rMaskOutDev.DrawRect( Rectangle(Point(), maSize) );
-// rMaskOutDev.SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
-// DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
-
- // surface content has changed (we cleared it, at least)
- mbSurfaceDirty = true;
-
- // just cleared content to fully transparent
- mbIsContentFullyOpaque = false;
-
- return this;
- }
-
-#define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
-
- ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASCUSTOMSPRITE_IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
- // Sprite
- void CanvasCustomSprite::redraw( Cairo* pCairo ) const
- {
- redraw( pCairo, maPosition );
- }
-
- void CanvasCustomSprite::redraw( Cairo* pCairo,
- const ::basegfx::B2DPoint& rOutputPos ) const
- {
- printf ("CanvasCustomSprite::redraw called\n");
- if( pCairo ) {
- Size aSize = mpBackBuffer->getSize();
- printf ("CanvasCustomSprite::redraw painting surface %p on %p cairo with surface %p on %f,%f size %d x %d\n",
- mpBackBuffer->getSurface(), pCairo, cairo_get_target( pCairo ), rOutputPos.getX(), rOutputPos.getY(),
- aSize.Width(), aSize.Height() );
- cairo_save( pCairo );
- cairo_rectangle( pCairo, rOutputPos.getX(), rOutputPos.getY(), aSize.Width(), aSize.Height() );
- cairo_clip( pCairo );
- cairo_set_source_surface( pCairo, mpBackBuffer->getSurface(), rOutputPos.getX(), rOutputPos.getY() );
- cairo_paint( pCairo );
- cairo_restore( pCairo );
- }
- }
-
- bool CanvasCustomSprite::isAreaUpdateOpaque( const Rectangle& rUpdateArea ) const
- {
- if( !mbIsCurrClipRectangle ||
- !mbIsContentFullyOpaque ||
- !::rtl::math::approxEqual(mfAlpha, 1.0) )
- {
- // sprite either transparent, or clip rect does not
- // represent exact bounds -> update might not be fully
- // opaque
- return false;
- }
- else
- {
- const Rectangle& rSpriteRect( getSpriteRect() );
-
- // make sure sprite rect covers update area fully -
- // although the update area originates from the sprite,
- // it's by no means guaranteed that it's limited to this
- // sprite's update area - after all, other sprites might
- // have been merged, or this sprite is moving.
-
- // Note: as Rectangle::IsInside() checks for _strict_
- // insidedness (i.e. all rect edges must be strictly
- // inside, not equal to one of the spriteRect's edges),
- // need the check for equality here.
- return rSpriteRect == rUpdateArea || rSpriteRect.IsInside( rUpdateArea );
- }
- }
-
- ::basegfx::B2DPoint CanvasCustomSprite::getSpritePos() const
- {
- tools::LocalGuard aGuard;
-
- return maPosition;
- }
-
- ::basegfx::B2DSize CanvasCustomSprite::getSpriteSize() const
- {
- tools::LocalGuard aGuard;
-
- // TODO(Q1): Use AW's wrappers once resynced
- return ::basegfx::B2DSize( maSize.Width(),
- maSize.Height() );
- }
-
- bool CanvasCustomSprite::repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const
- {
- tools::LocalGuard aGuard;
-
- mbSurfaceDirty = true;
-
- return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
- }
-
- Rectangle CanvasCustomSprite::getSpriteRect( const ::basegfx::B2DRectangle& rBounds ) const
- {
- // Internal! Only call with locked object mutex!
- ::basegfx::B2DHomMatrix aTransform( maTransform );
- aTransform.translate( maPosition.getX(),
- maPosition.getY() );
-
- // transform bounds at origin, as the sprite transformation is
- // formulated that way
- ::basegfx::B2DRectangle aTransformedBounds;
- ::canvas::tools::calcTransformedRectBounds( aTransformedBounds,
- rBounds,
- aTransform );
-
- // return integer rect, rounded away from the center
- return Rectangle( static_cast< sal_Int32 >( aTransformedBounds.getMinX() ),
- static_cast< sal_Int32 >( aTransformedBounds.getMinY() ),
- static_cast< sal_Int32 >( aTransformedBounds.getMaxX() )+1,
- static_cast< sal_Int32 >( aTransformedBounds.getMaxY() )+1 );
- }
-
- Rectangle CanvasCustomSprite::getSpriteRect() const
- {
- // Internal! Only call with locked object mutex!
-
- // return effective sprite rect, i.e. take active clip into
- // account
- if( maCurrClipBounds.isEmpty() )
- return getSpriteRect( ::basegfx::B2DRectangle( 0.0, 0.0,
- maSize.Width(),
- maSize.Height() ) );
- else
- // return integer rect, rounded away from the center
- return Rectangle( static_cast< sal_Int32 >( maPosition.getX() + maCurrClipBounds.getMinX() ),
- static_cast< sal_Int32 >( maPosition.getY() + maCurrClipBounds.getMinY() ),
- static_cast< sal_Int32 >( ceil( maPosition.getX() + maCurrClipBounds.getMaxX() ) ),
- static_cast< sal_Int32 >( ceil( maPosition.getY() + maCurrClipBounds.getMaxY() ) ) );
- }
-
- Rectangle CanvasCustomSprite::getFullSpriteRect() const
- {
- // Internal! Only call with locked object mutex!
- return getSpriteRect( ::basegfx::B2DRectangle( 0.0, 0.0,
- maSize.Width(),
- maSize.Height() ) );
- }
-}
diff --git a/scratch/canvas-cairo/cairo_canvascustomsprite.hxx b/scratch/canvas-cairo/cairo_canvascustomsprite.hxx
deleted file mode 100644
index 10302a66f..000000000
--- a/scratch/canvas-cairo/cairo_canvascustomsprite.hxx
+++ /dev/null
@@ -1,236 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_CANVASCUSTOMSPRITE_HXX
-#define _VCLCANVAS_CANVASCUSTOMSPRITE_HXX
-
-#ifndef _CPPUHELPER_COMPBASE3_HXX_
-#include <cppuhelper/compbase3.hxx>
-#endif
-
-#ifndef _COMPHELPER_UNO3_HXX
-#include <comphelper/uno3.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XCUSTOMSPRITE_HPP_
-#include <com/sun/star/rendering/XCustomSprite.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XPOLYPOLYGON2D_HPP_
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#endif
-
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-#include <canvas/bitmapcanvasbase.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_canvashelper.hxx"
-#include "cairo_backbuffer.hxx"
-#include "cairo_impltools.hxx"
-#include "cairo_spritecanvas.hxx"
-#include "cairo_sprite.hxx"
-#include "cairo_repainttarget.hxx"
-
-
-#define CANVASCUSTOMSPRITE_IMPLEMENTATION_NAME "CairoCanvas::CanvasCustomSprite"
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::rendering::XCustomSprite,
- ::com::sun::star::rendering::XBitmapCanvas,
- ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
- typedef ::canvas::internal::BitmapCanvasBase< CanvasCustomSpriteBase_Base, CanvasHelper, tools::LocalGuard > CanvasCustomSprite_Base;
-
- /* Definition of CanvasCustomSprite class */
-
- class CanvasCustomSprite : public Sprite,
- public CanvasCustomSprite_Base,
- public RepaintTarget
- {
- public:
- CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
- const WindowGraphicDevice::ImplRef& rDevice,
- const SystemEnvData* pSysData,
- const SpriteCanvas::ImplRef& rSpriteCanvas );
-
- // XInterface
-
- // Need to employ this macro, because Sprite comes with an
- // unimplemented version of XInterface.
-
- // Forwarding the XInterface implementation to the
- // cppu::ImplHelper templated base, which does the refcounting and
- // queryInterface for us: Classname Base doing refcount and handling queryInterface
- // | |
- // V V
- DECLARE_UNO3_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base );
-
- virtual void SAL_CALL disposing();
-
- // XSprite
- virtual void SAL_CALL setAlpha( double alpha ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL move( const ::com::sun::star::geometry::RealPoint2D& aNewPos, const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL transform( const ::com::sun::star::geometry::AffineMatrix2D& aTransformation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL clip( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& aClip ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPriority( double nPriority ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL show( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL hide( ) throw (::com::sun::star::uno::RuntimeException);
-
- // XCustomSprite
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > SAL_CALL
- getContentCanvas( ) throw (::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
-
- // Sprite
- virtual void redraw( ::cairo::Cairo* pCairo ) const;
- virtual void redraw( ::cairo::Cairo* pCairo,
- const ::basegfx::B2DPoint& rOutputPos ) const;
- virtual bool isAreaUpdateOpaque( const Rectangle& rUpdateArea ) const;
- virtual ::basegfx::B2DPoint getSpritePos() const;
- virtual ::basegfx::B2DSize getSpriteSize() const;
-
- // RepaintTarget
- virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const;
-
- protected:
- ~CanvasCustomSprite(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- CanvasCustomSprite(const CanvasCustomSprite&);
- CanvasCustomSprite& operator=( const CanvasCustomSprite& );
-
- Rectangle getSpriteRect( const ::basegfx::B2DRectangle& rBounds ) const;
- Rectangle getFullSpriteRect() const;
- Rectangle getSpriteRect() const;
-
- // for the integrated bitmap canvas implementation
- BackBufferSharedPtr mpBackBuffer;
- BackBufferSharedPtr mpBackBufferMask;
-
- SpriteCanvas::ImplRef mpSpriteCanvas;
-
- mutable ::canvas::vcltools::VCLObject<BitmapEx> maContent;
-
- /** Currently active clip area.
-
- This member is either empty, denoting that the current
- clip shows the full sprite content, or contains a
- rectangular subarea of the sprite, outside of which
- the sprite content is fully clipped.
-
- @see mbIsCurrClipRectangle
- */
- ::basegfx::B2DRectangle maCurrClipBounds;
-
- // sprite state
- ::basegfx::B2DPoint maPosition;
- Size maSize;
- ::basegfx::B2DHomMatrix maTransform;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D > mxClipPoly;
- double mfAlpha;
- bool mbActive;
-
- /** If true, denotes that the current sprite clip is a true
- rectangle, i.e. maCurrClipBounds <em>exactly</em>
- describes the visible area of the sprite.
-
- @see maCurrClipBounds
- */
- bool mbIsCurrClipRectangle;
-
- /** OutDev render speedup.
-
- When true, this flag denotes that the current
- mpBackBufferMask content is fully opaque, thus, that blits
- to the screen can use a plain Bitmap instead of the
- BitmapEx.
- */
- mutable bool mbIsContentFullyOpaque;
-
- /// True, iff maTransform has changed
- mutable bool mbTransformDirty;
-
- };
-}
-
-#endif /* _VCLCANVAS_CANVASCUSTOMSPRITE_HXX */
diff --git a/scratch/canvas-cairo/cairo_canvasfont.cxx b/scratch/canvas-cairo/cairo_canvasfont.cxx
deleted file mode 100644
index 8c7f09f0b..000000000
--- a/scratch/canvas-cairo/cairo_canvasfont.cxx
+++ /dev/null
@@ -1,192 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#ifndef _SV_METRIC_HXX
-#include <vcl/metric.hxx>
-#endif
-
-#include "cairo_outdevprovider.hxx"
-#include "cairo_canvasfont.hxx"
-#include "cairo_textlayout.hxx"
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- CanvasFont::CanvasFont( const rendering::FontRequest& rFontRequest,
- const uno::Sequence< beans::PropertyValue >& rExtraFontProperties,
- const geometry::Matrix2D& rFontMatrix,
- Cairo* pCairo) :
- CanvasFont_Base( m_aMutex ),
- maFont( Font( rFontRequest.FontDescription.FamilyName,
- rFontRequest.FontDescription.StyleName,
- Size( 0, ::basegfx::fround(rFontRequest.CellSize) ) ) ),
- maFontRequest( rFontRequest ),
- mpCairo( pCairo )
- {
- maFont->SetAlign( ALIGN_BASELINE );
- maFont->SetCharSet( (rFontRequest.FontDescription.IsSymbolFont==com::sun::star::util::TriState_YES) ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
- maFont->SetVertical( (rFontRequest.FontDescription.IsVertical==com::sun::star::util::TriState_YES) ? TRUE : FALSE );
-
- // TODO(F2): improve panose->vclenum conversion
- maFont->SetWeight( static_cast<FontWeight>(rFontRequest.FontDescription.FontDescription.Weight) );
- maFont->SetItalic( (rFontRequest.FontDescription.FontDescription.Letterform<=8) ? ITALIC_NONE : ITALIC_NORMAL );
-
- // adjust to stretched font
-// if( !::rtl::math::approxEqual( rFontMatrix.m00, rFontMatrix.m11) )
-// {
-// const OutputDevice& rOutDev( mpRefDevice->getOutDev() );
-// const Size aSize = rOutDev.GetFontMetric( *maFont ).GetSize();
-
-// const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
-// double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
-
-// if( !::basegfx::fTools::equalZero( fDividend) )
-// fStretch /= fDividend;
-
-// const long nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
-
-// maFont->SetWidth( nNewWidth );
-// }
- }
-
- CanvasFont::~CanvasFont()
- {
- }
-
- void SAL_CALL CanvasFont::disposing()
- {
- tools::LocalGuard aGuard;
- }
-
- uno::Reference< rendering::XTextLayout > SAL_CALL CanvasFont::createTextLayout( const rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return new TextLayout( aText, nDirection, nRandomSeed, ImplRef( this ), mpCairo );
- }
-
- rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return maFontRequest;
- }
-
- rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return rendering::FontMetrics();
- }
-
- uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Sequence< double >();
- }
-
- uno::Sequence< beans::PropertyValue > SAL_CALL CanvasFont::getExtraFontProperties( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Sequence< beans::PropertyValue >();
- }
-
-#define SERVICE_NAME "com.sun.star.rendering.CanvasFont"
-
- ::rtl::OUString SAL_CALL CanvasFont::getImplementationName() throw( uno::RuntimeException )
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CANVASFONT_IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL CanvasFont::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL CanvasFont::getSupportedServiceNames() throw( uno::RuntimeException )
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
- ::Font CanvasFont::getVCLFont() const
- {
- return *maFont;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_canvasfont.hxx b/scratch/canvas-cairo/cairo_canvasfont.hxx
deleted file mode 100644
index a4708cebe..000000000
--- a/scratch/canvas-cairo/cairo_canvasfont.hxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _CANVASFONT_HXX
-#define _CANVASFONT_HXX
-
-#ifndef _COMPHELPER_IMPLEMENTATIONREFERENCE_HXX
-#include <comphelper/implementationreference.hxx>
-#endif
-
-#ifndef _CPPUHELPER_COMPBASE2_HXX_
-#include <cppuhelper/compbase2.hxx>
-#endif
-#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
-#include <comphelper/broadcasthelper.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_XCANVASFONT_HPP_
-#include <com/sun/star/rendering/XCanvasFont.hpp>
-#endif
-
-#ifndef _SV_FONT_HXX
-#include <vcl/font.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_canvashelper.hxx"
-#include "cairo_impltools.hxx"
-
-
-#define CANVASFONT_IMPLEMENTATION_NAME "CairoCanvas::CanvasFont"
-
-/* Definition of CanvasFont class */
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCanvasFont,
- ::com::sun::star::lang::XServiceInfo > CanvasFont_Base;
-
- class CanvasFont : public ::comphelper::OBaseMutex, public CanvasFont_Base
- {
- public:
- typedef ::comphelper::ImplementationReference<
- CanvasFont,
- ::com::sun::star::rendering::XCanvasFont > ImplRef;
-
- CanvasFont( const ::com::sun::star::rendering::FontRequest& fontRequest,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& extraFontProperties,
- const ::com::sun::star::geometry::Matrix2D& rFontMatrix,
- ::cairo::Cairo* pCairo );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XCanvasFont
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XTextLayout > SAL_CALL createTextLayout( const ::com::sun::star::rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::rendering::FontRequest SAL_CALL getFontRequest( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::rendering::FontMetrics SAL_CALL getFontMetrics( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getAvailableSizes( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getExtraFontProperties( ) throw (::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
-
- ::Font getVCLFont() const;
-
- protected:
- ~CanvasFont(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- CanvasFont(const CanvasFont&);
- CanvasFont& operator=( const CanvasFont& );
-
- ::canvas::vcltools::VCLObject<Font> maFont;
- ::com::sun::star::rendering::FontRequest maFontRequest;
-
- ::cairo::Cairo* mpCairo;
- };
-
-}
-
-#endif /* _CANVASFONT_HXX */
diff --git a/scratch/canvas-cairo/cairo_canvashelper.cxx b/scratch/canvas-cairo/cairo_canvashelper.cxx
deleted file mode 100644
index 01c2928ec..000000000
--- a/scratch/canvas-cairo/cairo_canvashelper.cxx
+++ /dev/null
@@ -1,916 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_TEXTDIRECTION_HPP__
-#include <com/sun/star/rendering/TextDirection.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_TEXTURINGMODE_HPP_
-#include <com/sun/star/rendering/TexturingMode.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_PATHCAPTYPE_HPP_
-#include <com/sun/star/rendering/PathCapType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_PATHJOINTYPE_HPP_
-#include <com/sun/star/rendering/PathJoinType.hpp>
-#endif
-
-#ifndef _TL_POLY_HXX
-#include <tools/poly.hxx>
-#endif
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
-#include <basegfx/range/b2drectangle.hxx>
-#endif
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_VECTOR_B2DSIZE_HXX
-#include <basegfx/vector/b2dsize.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
-#include <basegfx/polygon/b2dpolygon.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DLINEGEOMETRY_HXX
-#include <basegfx/polygon/b2dlinegeometry.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#include <utility>
-
-#include <comphelper/sequence.hxx>
-#include <canvas/canvastools.hxx>
-
-#include "cairo_textlayout.hxx"
-#include "cairo_parametricpolypolygon.hxx"
-#include "cairo_canvashelper.hxx"
-#include "cairo_canvasbitmap.hxx"
-#include "cairo_impltools.hxx"
-#include "cairo_canvasfont.hxx"
-#include "cairo_linepolypolygon.hxx"
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- namespace
- {
- ::basegfx::tools::B2DLineJoin b2DJoineFromJoin( sal_Int8 nJoinType )
- {
- switch( nJoinType )
- {
- case rendering::PathJoinType::NONE:
- return ::basegfx::tools::B2DLINEJOIN_NONE;
-
- case rendering::PathJoinType::MITER:
- return ::basegfx::tools::B2DLINEJOIN_MITER;
-
- case rendering::PathJoinType::ROUND:
- return ::basegfx::tools::B2DLINEJOIN_ROUND;
-
- case rendering::PathJoinType::BEVEL:
- return ::basegfx::tools::B2DLINEJOIN_BEVEL;
-
- default:
- ENSURE_AND_THROW( false,
- "b2DJoineFromJoin(): Unexpected join type" );
- }
-
- return ::basegfx::tools::B2DLINEJOIN_NONE;
- }
- }
-
- CanvasHelper::CanvasHelper() :
- mxDevice(),
- mpCairo( NULL ),
- mpTextures( NULL ),
- mp2ndOutDev()
- {
- }
-
- void CanvasHelper::disposing()
- {
- printf("canvas helper disposing\n");
- mxDevice.reset();
- mp2ndOutDev.reset();
- }
-
- void CanvasHelper::setGraphicDevice( const WindowGraphicDevice::ImplRef& rDevice )
- {
- mxDevice = rDevice;
- }
-
- void CanvasHelper::setCairo( Cairo* pCairo )
- {
- mpCairo = pCairo;
- }
-
- void CanvasHelper::setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev )
- {
- mp2ndOutDev = rOutDev;
- }
-
- void CanvasHelper::drawPoint( const rendering::XCanvas& rCanvas,
- const geometry::RealPoint2D& aPoint,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- // rodo TODO
-// // are we disposed?
-// if( mpCairo )
-// {
-// // nope, render
-// setupOutDevState( viewState, renderState, LINE_COLOR );
-
-// const Point aOutPoint( tools::mapRealPoint2D( aPoint,
-// viewState, renderState ) );
-// // TODO(F1): alpha
-// mpOutDev->getOutDev().DrawPixel( aOutPoint );
-
-// if( mp2ndOutDev.get() )
-// mp2ndOutDev->getOutDev().DrawPixel( aOutPoint );
-// }
- }
-
- void CanvasHelper::useStates( const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- bool setColor )
- {
- Matrix aViewMatrix;
- Matrix aRenderMatrix;
- Matrix aCombinedMatrix;
-
- cairo_matrix_init( &aViewMatrix,
- viewState.AffineTransform.m00, viewState.AffineTransform.m10, viewState.AffineTransform.m01,
- viewState.AffineTransform.m11, viewState.AffineTransform.m02, viewState.AffineTransform.m12);
- cairo_matrix_init( &aRenderMatrix,
- renderState.AffineTransform.m00, renderState.AffineTransform.m10, renderState.AffineTransform.m01,
- renderState.AffineTransform.m11, renderState.AffineTransform.m02, renderState.AffineTransform.m12);
- cairo_matrix_multiply( &aCombinedMatrix, &aRenderMatrix, &aViewMatrix);
-
- if( viewState.Clip.is() ) {
- printf ("view clip\n");
-
- cairo_set_matrix( mpCairo, &aViewMatrix );
- drawPolyPolygonPath( viewState.Clip, Clip );
- }
-
- cairo_set_matrix( mpCairo, &aCombinedMatrix );
-
- if( renderState.Clip.is() ) {
- printf ("render clip\n");
-
- drawPolyPolygonPath( renderState.Clip, Clip );
- }
-
- if (setColor) {
- if (renderState.DeviceColor.getLength() > 3)
- cairo_set_source_rgba( mpCairo,
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2],
- renderState.DeviceColor [3] );
- else if (renderState.DeviceColor.getLength() == 3)
- cairo_set_source_rgb( mpCairo,
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2] );
- }
- }
-
- void CanvasHelper::drawLine( const rendering::XCanvas& rCanvas,
- const geometry::RealPoint2D& aStartRealPoint2D,
- const geometry::RealPoint2D& aEndRealPoint2D,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- if(mpCairo) {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
-
- cairo_set_line_width( mpCairo, 1 );
- cairo_move_to( mpCairo, aStartRealPoint2D.X, aStartRealPoint2D.Y );
- cairo_line_to( mpCairo, aEndRealPoint2D.X, aEndRealPoint2D.Y );
- cairo_stroke( mpCairo );
-
- cairo_restore( mpCairo );
- }
- }
-
- void CanvasHelper::drawBezier( const rendering::XCanvas& rCanvas,
- const geometry::RealBezierSegment2D& aBezierSegment,
- const geometry::RealPoint2D& _aEndPoint,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- if( mpCairo )
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
- cairo_set_line_width( mpCairo, 1 );
- cairo_move_to( mpCairo, aBezierSegment.Px, aBezierSegment.Py );
- cairo_curve_to( mpCairo, aBezierSegment.C1x, aBezierSegment.C1y, aBezierSegment.C2x, aBezierSegment.C2y, _aEndPoint.X, _aEndPoint.Y );
- cairo_stroke( mpCairo );
-
- cairo_restore( mpCairo );
- }
-
- void CanvasHelper::doOperation( Operation aOperation )
- {
- switch( aOperation ) {
- case Fill:
- if( mpTextures ) {
- ::com::sun::star::rendering::Texture aTexture ( (*mpTextures)[mnPolygonIndex] );
- if( aTexture.Bitmap.is() ) {
- unsigned char* data;
- Surface* pSurface = tools::surfaceFromXBitmap( (*mpTextures)[mnPolygonIndex].Bitmap, mxDevice, data );
-
- if( pSurface ) {
- cairo_pattern_t *pPattern;
-
- cairo_save( mpCairo );
-
- ::com::sun::star::geometry::AffineMatrix2D aTransform( aTexture.AffineTransform );
- Matrix aScaleMatrix, aTextureMatrix, aScaledTextureMatrix, aOrigMatrix, aNewMatrix;
-
- cairo_matrix_init( &aTextureMatrix,
- aTransform.m00, aTransform.m10, aTransform.m01,
- aTransform.m11, aTransform.m02, aTransform.m12);
-
- geometry::IntegerSize2D aSize = aTexture.Bitmap->getSize();
-
- cairo_matrix_init_scale( &aScaleMatrix, 1.0/aSize.Width, 1.0/aSize.Height );
- cairo_matrix_multiply( &aScaledTextureMatrix, &aTextureMatrix, &aScaleMatrix );
- cairo_matrix_invert( &aScaledTextureMatrix );
-
-#if 0
- // workaround for X/glitz and/or cairo bug
- // we create big enough temporary surface, copy texture bitmap there and use it for the pattern
- // it only happens on enlargening matrices with REPEAT mode enabled
- Surface* pTmpSurface = mxDevice->getSimilarSurface();
- Cairo* pTmpCairo = cairo_create( pTmpSurface );
- cairo_set_source_surface( pTmpCairo, pSurface, 0, 0 );
- cairo_paint( pTmpCairo );
-#endif
-
- // use pTmpSurface to enable the workaround
- // we don't care about repeat mode yet, so the workaround is disabled for now
- pPattern = cairo_pattern_create_for_surface( pSurface );
- cairo_pattern_set_matrix( pPattern, &aScaledTextureMatrix );
- //cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_REPEAT );
-
- cairo_set_source( mpCairo, pPattern );
- cairo_fill( mpCairo );
-
- cairo_restore( mpCairo );
-
- cairo_pattern_destroy( pPattern );
- cairo_surface_destroy( pSurface );
-
-#if 0
- cairo_destroy( pTmpCairo );
- cairo_surface_destroy( pTmpSurface );
-#endif
- }
-
- if( data )
- free( data );
- }
- } else
- cairo_fill( mpCairo );
- break;
- case Stroke:
- cairo_stroke( mpCairo );
- break;
- case Clip:
- cairo_clip( mpCairo );
- break;
- }
- }
-
- void CanvasHelper::drawPolyPolygonImplementation( ::basegfx::B2DPolyPolygon aPolyPolygon, Operation aOperation )
- {
- for( mnPolygonIndex = 0; mnPolygonIndex < aPolyPolygon.count(); mnPolygonIndex++ ) {
- ::basegfx::B2DPolygon aPolygon = aPolyPolygon.getB2DPolygon( mnPolygonIndex );
- bool bIsBezier = aPolygon.areControlPointsUsed();
- ::basegfx::B2DPoint aA, aB, aP;
-
- aP = aPolygon.getB2DPoint( 0 );
- cairo_move_to( mpCairo, aP.getX(), aP.getY() );
- printf( "move to %d,%d\n", aP.getX(), aP.getY() );
-
- if( bIsBezier ) {
- aA = aPolygon.getControlPointA( 0 );
- aB = aPolygon.getControlPointB( 0 );
- }
-
- for( sal_uInt32 j = 1; j < aPolygon.count(); j++ ) {
- aP = aPolygon.getB2DPoint( j );
-
- if( bIsBezier ) {
- cairo_curve_to( mpCairo, aA.getX(), aA.getY(), aB.getX(), aB.getY(), aP.getX(), aP.getY() );
-
- aA = aPolygon.getControlPointA( j );
- aB = aPolygon.getControlPointB( j );
- } else {
- cairo_line_to( mpCairo, aP.getX(), aP.getY() );
- printf( "line to %d,%d\n", aP.getX(), aP.getY() );
- }
- }
-
- if( aPolygon.isClosed() )
- cairo_close_path( mpCairo );
-
- doOperation( aOperation );
- }
- }
-
- void CanvasHelper::drawPolyPolygonFallback( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, Operation aOperation )
- {
- const sal_Int32 nPolys( xPolyPolygon->getNumberOfPolygons() );
-
- uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly( xPolyPolygon, uno::UNO_QUERY );
- if( xLinePoly.is() ) {
-
- uno::Sequence< uno::Sequence< ::com::sun::star::geometry::RealPoint2D > > aPoints = xLinePoly->getPoints( 0, nPolys, 0, -1 );
-
- for( mnPolygonIndex = 0; mnPolygonIndex < nPolys; mnPolygonIndex++ ) {
- cairo_move_to( mpCairo, aPoints[mnPolygonIndex][0].X, aPoints[mnPolygonIndex][0].Y );
-
- for( sal_Int32 j = 0; j < aPoints[mnPolygonIndex].getLength(); j ++ )
- cairo_line_to( mpCairo, aPoints[mnPolygonIndex][j].X, aPoints[mnPolygonIndex][j].Y );
-
- if( xPolyPolygon->isClosed( mnPolygonIndex ) )
- cairo_close_path( mpCairo );
-
- doOperation( aOperation );
- }
- } else {
-
- uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly( xPolyPolygon, uno::UNO_QUERY );
- if( xBezierPoly.is() ) {
-
- uno::Sequence< uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > > aSegments = xBezierPoly->getBezierSegments( 0, nPolys, 0, -1 );
- double nC1x, nC1y, nC2x, nC2y;
-
- for( mnPolygonIndex = 0; mnPolygonIndex < nPolys; mnPolygonIndex++ ) {
- cairo_move_to( mpCairo, aSegments[mnPolygonIndex][0].Px, aSegments[mnPolygonIndex][0].Py );
-
- for( sal_Int32 j = 1; j < aSegments[mnPolygonIndex].getLength(); j ++ ) {
- cairo_curve_to( mpCairo,
- aSegments[mnPolygonIndex][j - 1].C1x, aSegments[mnPolygonIndex][j - 1].C1y,
- aSegments[mnPolygonIndex][j - 1].C2x, aSegments[mnPolygonIndex][j - 1].C2y,
- aSegments[mnPolygonIndex][j].Px, aSegments[mnPolygonIndex][j].Py );
- }
- if( xPolyPolygon->isClosed( mnPolygonIndex ) )
- cairo_close_path( mpCairo );
-
- doOperation( aOperation );
- }
- }
- }
- }
-
- void CanvasHelper::drawPolyPolygonPath( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, Operation aOperation )
- {
- LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPolyPolygon.get() );
-
- if( pPolyImpl )
- drawPolyPolygonImplementation( pPolyImpl->getPolyPolygon(), aOperation );
- else
- drawPolyPolygonFallback( xPolyPolygon, aOperation );
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- if( mpCairo ) {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
- cairo_set_line_width( mpCairo, 1 );
- drawPolyPolygonPath( xPolyPolygon, Stroke );
-
- cairo_restore( mpCairo );
- }
-
- // TODO(P1): Provide caching here.
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokePolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const rendering::StrokeAttributes& strokeAttributes )
- {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
-
- cairo_set_line_width( mpCairo, strokeAttributes.StrokeWidth );
- cairo_set_miter_limit( mpCairo, strokeAttributes.MiterLimit );
-
- // FIXME: cairo doesn't handle end cap so far (rodo)
- switch( strokeAttributes.StartCapType ) {
- case rendering::PathCapType::BUTT:
- cairo_set_line_cap( mpCairo, CAIRO_LINE_CAP_BUTT );
- break;
- case rendering::PathCapType::ROUND:
- cairo_set_line_cap( mpCairo, CAIRO_LINE_CAP_ROUND );
- break;
- case rendering::PathCapType::SQUARE:
- cairo_set_line_cap( mpCairo, CAIRO_LINE_CAP_SQUARE );
- break;
- }
-
- switch( strokeAttributes.JoinType ) {
- // cairo doesn't have join type NONE so we use MITTER as it's pretty close
- case rendering::PathJoinType::NONE:
- case rendering::PathJoinType::MITER:
- cairo_set_line_join( mpCairo, CAIRO_LINE_JOIN_MITER );
- break;
- case rendering::PathJoinType::ROUND:
- cairo_set_line_join( mpCairo, CAIRO_LINE_JOIN_ROUND );
- break;
- case rendering::PathJoinType::BEVEL:
- cairo_set_line_join( mpCairo, CAIRO_LINE_JOIN_BEVEL );
- break;
- }
-
- if( strokeAttributes.DashArray.getLength() > 0 ) {
- double* pDashArray = new double[ strokeAttributes.DashArray.getLength() ];
- for( sal_Int32 i=0; i<strokeAttributes.DashArray.getLength(); i++ )
- pDashArray[i]=strokeAttributes.DashArray[i];
- cairo_set_dash( mpCairo, pDashArray, strokeAttributes.DashArray.getLength(), 0 );
- delete[] pDashArray;
- }
-
- // TODO(rodo) use LineArray of strokeAttributes
-
- drawPolyPolygonPath( xPolyPolygon, Stroke );
-
- cairo_restore( mpCairo );
-
- // TODO(P1): Provide caching here.
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTexturedPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const uno::Sequence< rendering::Texture >& textures,
- const rendering::StrokeAttributes& strokeAttributes )
- {
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTextureMappedPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const uno::Sequence< rendering::Texture >& textures,
- const uno::Reference< geometry::XMapping2D >& xMapping,
- const rendering::StrokeAttributes& strokeAttributes )
- {
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XPolyPolygon2D > CanvasHelper::queryStrokeShapes( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const rendering::StrokeAttributes& strokeAttributes )
- {
- return uno::Reference< rendering::XPolyPolygon2D >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- if( mpCairo ) {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
- drawPolyPolygonPath( xPolyPolygon, Fill );
-
- cairo_restore( mpCairo );
- }
-
- // TODO(P1): Provide caching here.
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTextureMappedPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const uno::Sequence< rendering::Texture >& textures,
- const uno::Reference< geometry::XMapping2D >& xMapping )
- {
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCanvasFont > CanvasHelper::createFont( const rendering::XCanvas& rCanvas,
- const rendering::FontRequest& fontRequest,
- const uno::Sequence< beans::PropertyValue >& extraFontProperties,
- const geometry::Matrix2D& fontMatrix )
- {
- // rodo TODO
- if( mpCairo )
- {
- // TODO(F2): font properties and font matrix
- return uno::Reference< rendering::XCanvasFont >(
- new CanvasFont( fontRequest, extraFontProperties, fontMatrix, mpCairo ) );
- }
-
- return uno::Reference< rendering::XCanvasFont >();
- }
-
- uno::Sequence< rendering::FontInfo > CanvasHelper::queryAvailableFonts( const rendering::XCanvas& rCanvas,
- const rendering::FontInfo& aFilter,
- const uno::Sequence< beans::PropertyValue >& aFontProperties )
- {
- // TODO
- return uno::Sequence< rendering::FontInfo >();
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas& rCanvas,
- const rendering::StringContext& text,
- const uno::Reference< rendering::XCanvasFont >& xFont,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 textDirection )
- {
- if (mpCairo) {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
-
- // fixme (rodo) - use xFont
- cairo_select_font_face( mpCairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
- cairo_show_text( mpCairo, ::rtl::OUStringToOString( text.Text, RTL_TEXTENCODING_UTF8 ) );
-
- cairo_restore( mpCairo );
- }
-
-
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawTextLayout( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XTextLayout >& xLayoutedText,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- CHECK_AND_THROW( xLayoutedText.is(),
- "CanvasHelper::drawTextLayout(): layout is NULL");
-
- if (mpCairo) {
- cairo_save( mpCairo );
-
- uno::Reference< lang::XServiceInfo > xRef( xLayoutedText,
- uno::UNO_QUERY );
-
- TextLayout* pTextLayout = NULL;
-
- if( xRef.is() &&
- xRef->getImplementationName().equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(TEXTLAYOUT_IMPLEMENTATION_NAME))) ) {
- // TODO(P2): Maybe use dynamic_cast here (saves us a queryInterface)
- pTextLayout = static_cast<TextLayout*>(xLayoutedText.get());
- } else {
- CHECK_AND_THROW( false,
- "CanvasHelper::drawTextLayout(): TextLayout not compatible with this canvas" );
- }
-
- useStates( viewState, renderState, true );
-
- pTextLayout->draw( mpCairo );
-
- cairo_restore( mpCairo );
- }
-
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::implDrawBitmap( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XBitmap >& xBitmap,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- bool bModulateColors )
- {
- unsigned char* data;
- Surface* pSurface = tools::surfaceFromXBitmap( xBitmap, mxDevice, data );
-
- if( mpCairo && pSurface )
- {
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
-
- cairo_set_source_surface( mpCairo, pSurface, 0, 0 );
- cairo_paint( mpCairo );
- cairo_restore( mpCairo );
- }
-
- if( pSurface )
- cairo_surface_destroy( pSurface );
-
- if( data )
- free( data );
-
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmap( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XBitmap >& xBitmap,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- return implDrawBitmap( rCanvas,
- xBitmap,
- viewState,
- renderState,
- false );
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XBitmap >& xBitmap,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- return implDrawBitmap( rCanvas,
- xBitmap,
- viewState,
- renderState,
- true );
- }
-
- uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
- {
- return mxDevice.get();
- }
-
- void CanvasHelper::copyRect( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XBitmapCanvas >& sourceCanvas,
- const geometry::RealRectangle2D& sourceRect,
- const rendering::ViewState& sourceViewState,
- const rendering::RenderState& sourceRenderState,
- const geometry::RealRectangle2D& destRect,
- const rendering::ViewState& destViewState,
- const rendering::RenderState& destRenderState )
- {
- // TODO(F1)
- }
-
- geometry::IntegerSize2D CanvasHelper::getSize()
- {
- if( !mxDevice.get() )
- return geometry::IntegerSize2D(); // we're disposed
-
- geometry::RealSize2D aSize = mxDevice->getSize();
-
- return geometry::IntegerSize2D( (sal_Int32) aSize.Width, (sal_Int32) aSize.Height );
- }
-
- uno::Reference< rendering::XBitmap > CanvasHelper::getScaledBitmap( const geometry::RealSize2D& newSize,
- sal_Bool beFast )
- {
- // rodo FIXME
- printf ("called CanvasHelper::getScaledBitmap, we return NULL, TODO\n");
-
- Surface *pSurface = cairo_get_target( mpCairo );
- return uno::Reference< rendering::XBitmap >( new CanvasBitmap( newSize, pSurface, mxDevice ) );
-
- return uno::Reference< rendering::XBitmap >(); // we're disposed
-// if( !mpOutDev.get() )
-// return uno::Reference< rendering::XBitmap >(); // we're disposed
-
-// // TODO(F2): Support alpha vdev canvas here
-// const Point aEmptyPoint(0,0);
-// const Size aBmpSize( mpOutDev->getOutDev().GetOutputSizePixel() );
-
-// Bitmap aBitmap( mpOutDev->getOutDev().GetBitmap(aEmptyPoint, aBmpSize) );
-
-// aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
-// beFast ? BMP_SCALE_FAST : BMP_SCALE_INTERPOLATE );
-
-// return uno::Reference< rendering::XBitmap >( new CanvasBitmap( aBitmap,
-// mxDevice ) );
- }
-
- uno::Sequence< sal_Int8 > CanvasHelper::getData( const geometry::IntegerRectangle2D& rect )
- {
- printf ("CanvasHelper::getData returns empty sequence, TODO\n");
-
- return uno::Sequence< sal_Int8 >();
- }
-
- void CanvasHelper::setData( const uno::Sequence< sal_Int8 >& data,
- const geometry::IntegerRectangle2D& rect )
- {
- printf ("canvas helper set data called, TODO\n");
- }
-
- void CanvasHelper::setPixel( const uno::Sequence< sal_Int8 >& color,
- const geometry::IntegerPoint2D& pos )
- {
- // rodo TODO
- printf ("CanvasHelper::setPixel called TODO\n");
-// if( !mpOutDev.get() )
-// return; // we're disposed
-
-// OutputDevice& rOutDev( mpOutDev->getOutDev() );
-
-// const Size aBmpSize( rOutDev.GetOutputSizePixel() );
-
-// CHECK_AND_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
-// "CanvasHelper::setPixel: X coordinate out of bounds" );
-// CHECK_AND_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
-// "CanvasHelper::setPixel: Y coordinate out of bounds" );
-// CHECK_AND_THROW( color.getLength() > 3,
-// "CanvasHelper::setPixel: not enough color components" );
-
-// tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
-// rOutDev.EnableMapMode( FALSE );
-
-// // TODO(F2): Support alpha canvas here
-// rOutDev.DrawPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ),
-// ::vcl::unotools::sequenceToColor(
-// mxDevice.getRef(),
-// color ) );
- }
-
- uno::Sequence< sal_Int8 > CanvasHelper::getPixel( const geometry::IntegerPoint2D& pos )
- {
- printf ("CanvasHelper::getPixel called TODO\n");
- return uno::Sequence< sal_Int8 >();
-
-// if( !mpOutDev.get() )
-// return uno::Sequence< sal_Int8 >(); // we're disposed
-
-// OutputDevice& rOutDev( mpOutDev->getOutDev() );
-
-// const Size aBmpSize( rOutDev.GetOutputSizePixel() );
-
-// CHECK_AND_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
-// "CanvasHelper::getPixel: X coordinate out of bounds" );
-// CHECK_AND_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
-// "CanvasHelper::getPixel: Y coordinate out of bounds" );
-
-// tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
-
-// rOutDev.EnableMapMode( FALSE );
-
-// // TODO(F2): Support alpha canvas here
-// return ::vcl::unotools::colorToIntSequence( mxDevice.getRef(),
-// rOutDev.GetPixel(
-// ::vcl::unotools::pointFromIntegerPoint2D( pos ) ) );
- }
-
- uno::Reference< rendering::XBitmapPalette > CanvasHelper::getPalette()
- {
- // TODO(F1): Provide palette support
- return uno::Reference< rendering::XBitmapPalette >();
- }
-
- rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout()
- {
- // TODO(F1): finish that one
- rendering::IntegerBitmapLayout aLayout;
-
- printf ("CanvasHelper::getMemoryLayout called, TODO\n");
-
- return aLayout;
-
-
-// if( !mpOutDev.get() )
-// return aLayout; // we're disposed
-
-// const Size aBmpSize( mpOutDev->getOutDev().GetOutputSizePixel() );
-
-// aLayout.ScanLines = aBmpSize.Height();
-// aLayout.ScanLineBytes = aBmpSize.Width()*4;
-// aLayout.ScanLineStride = aLayout.ScanLineBytes;
-// aLayout.Format = 0;
-// aLayout.NumComponents = 4;
-// aLayout.ComponentMasks = uno::Sequence<sal_Int64>();
-// aLayout.Endianness = 0;
-// aLayout.IsPseudoColor = false;
-
-// return aLayout;
- }
-
- bool CanvasHelper::repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const
- {
- ENSURE_AND_RETURN( rGrf,
- "CanvasHelper::repaint(): Invalid Graphic" );
-
- printf ("repaint called, TODO\n");
-
-// if( !mpOutDev )
-// return false; // disposed
-// else
-// return rGrf->Draw( &mpOutDev->getOutDev(), rPt, rSz, &rAttr );
- }
-}
diff --git a/scratch/canvas-cairo/cairo_canvashelper.hxx b/scratch/canvas-cairo/cairo_canvashelper.hxx
deleted file mode 100644
index b4be95d1c..000000000
--- a/scratch/canvas-cairo/cairo_canvashelper.hxx
+++ /dev/null
@@ -1,339 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_CANVASHELPER_HXX_
-#define _VCLCANVAS_CANVASHELPER_HXX_
-
-#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP_
-#include <com/sun/star/rendering/XCanvas.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP_
-#include <com/sun/star/rendering/XIntegerBitmap.hpp>
-#endif
-
-#ifndef _SV_OUTDEV_HXX
-#include <vcl/outdev.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_outdevprovider.hxx"
-#include "cairo_cachedbitmap.hxx"
-#include "cairo_windowgraphicdevice.hxx"
-
-
-namespace vclcanvas
-{
- /** Helper class for basic canvas functionality. Also offers
- optional backbuffer painting, when providing it with a second
- OutputDevice to render into.
- */
- class CanvasHelper
- {
- public:
- CanvasHelper();
-
- /// Release all references
- void disposing();
-
- void setGraphicDevice( const WindowGraphicDevice::ImplRef& rDevice );
-
- /** Set primary output device
-
- @param bProtect
- When true, all output operations preserve outdev
- state. When false, outdev state might change at any time.
- */
- void setCairo( ::cairo::Cairo* pCairo );
-
- /** Set secondary output device
-
- Used for sprites, to generate mask bitmap.
- */
- void setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev );
-
- // CanvasHelper functionality
- // ==========================
-
- // XCanvas (only providing, not implementing the
- // interface. Also note subtle method parameter differences)
- void drawPoint( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::geometry::RealPoint2D& aPoint,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- void drawLine( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::geometry::RealPoint2D& aStartPoint,
- const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- void drawBezier( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
- const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- drawPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- strokePolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::rendering::Texture >& textures,
- const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::rendering::Texture >& textures,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::geometry::XMapping2D >& xMapping,
- const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
- queryStrokeShapes( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- fillPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::rendering::Texture >& textures );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::rendering::Texture >& textures,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::geometry::XMapping2D >& xMapping );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >
- createFont( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::rendering::FontRequest& fontRequest,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::beans::PropertyValue >& extraFontProperties,
- const ::com::sun::star::geometry::Matrix2D& fontMatrix );
-
- ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
- queryAvailableFonts( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::rendering::FontInfo& aFilter,
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::beans::PropertyValue >& aFontProperties );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- drawText( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::rendering::StringContext& text,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvasFont >& xFont,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- sal_Int8 textDirection );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- drawTextLayout( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XTextLayout >& layoutetText,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- drawBitmap( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap >& xBitmap,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- drawBitmapModulated( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap >& xBitmap,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
- getDevice();
-
- // BitmapCanvasHelper functionality
- // ================================
-
- void copyRect( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas,
- const ::com::sun::star::geometry::RealRectangle2D& sourceRect,
- const ::com::sun::star::rendering::ViewState& sourceViewState,
- const ::com::sun::star::rendering::RenderState& sourceRenderState,
- const ::com::sun::star::geometry::RealRectangle2D& destRect,
- const ::com::sun::star::rendering::ViewState& destViewState,
- const ::com::sun::star::rendering::RenderState& destRenderState );
-
- ::com::sun::star::geometry::IntegerSize2D getSize();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
- getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize,
- sal_Bool beFast );
-
- ::com::sun::star::uno::Sequence< sal_Int8 >
- getData( const ::com::sun::star::geometry::IntegerRectangle2D& rect );
-
- void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data,
- const ::com::sun::star::geometry::IntegerRectangle2D& rect );
-
- void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color,
- const ::com::sun::star::geometry::IntegerPoint2D& pos );
-
- ::com::sun::star::uno::Sequence< sal_Int8 >
- getPixel( const ::com::sun::star::geometry::IntegerPoint2D& pos );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > getPalette();
-
- ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
-
- /// Repaint a cached bitmap
- bool repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const;
-
- enum ColorType
- {
- LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
- };
-
- protected:
- /// Phyical output device
- WindowGraphicDevice::ImplRef mxDevice;
-
- OutDevProviderSharedPtr mp2ndOutDev;
-
- ::cairo::Cairo* mpCairo;
-
- private:
- // default: disabled copy/assignment
- CanvasHelper(const CanvasHelper&);
- CanvasHelper& operator=( const CanvasHelper& );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
- implDrawBitmap( const ::com::sun::star::rendering::XCanvas& rCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap >& xBitmap,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- bool bModulateColors );
-
- bool setupTextOutput( ::Point& o_rOutPos,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >& xFont );
-
- void useStates( const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- bool setColor );
-
- enum Operation {
- Stroke,
- Fill,
- Clip
- };
-
-
- const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* mpTextures;
- void doOperation( Operation aOperation );
- sal_uInt32 mnPolygonIndex;
-
- void drawPolyPolygonImplementation( ::basegfx::B2DPolyPolygon aPolyPolygon, Operation aOperation );
- void drawPolyPolygonFallback( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- Operation aOperation );
- void drawPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
- Operation aOperation );
- };
-}
-
-#endif /* _VCLCANVAS_CANVASHELPER_HXX_ */
diff --git a/scratch/canvas-cairo/cairo_canvashelper_texturefill.cxx b/scratch/canvas-cairo/cairo_canvashelper_texturefill.cxx
deleted file mode 100644
index e30b8f829..000000000
--- a/scratch/canvas-cairo/cairo_canvashelper_texturefill.cxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_TEXTDIRECTION_HPP__
-#include <com/sun/star/rendering/TextDirection.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_TEXTURINGMODE_HPP_
-#include <com/sun/star/rendering/TexturingMode.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_PATHCAPTYPE_HPP_
-#include <com/sun/star/rendering/PathCapType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_PATHJOINTYPE_HPP_
-#include <com/sun/star/rendering/PathJoinType.hpp>
-#endif
-
-#ifndef _TL_POLY_HXX
-#include <tools/poly.hxx>
-#endif
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
-#include <basegfx/range/b2drectangle.hxx>
-#endif
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_VECTOR_B2DSIZE_HXX
-#include <basegfx/vector/b2dsize.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
-#include <basegfx/polygon/b2dpolygon.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DLINEGEOMETRY_HXX
-#include <basegfx/polygon/b2dlinegeometry.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#include <utility>
-
-#include <comphelper/sequence.hxx>
-#include <canvas/canvastools.hxx>
-
-#include "cairo_textlayout.hxx"
-#include "cairo_parametricpolypolygon.hxx"
-#include "cairo_canvashelper.hxx"
-#include "cairo_canvasbitmap.hxx"
-#include "cairo_impltools.hxx"
-#include "cairo_canvasfont.hxx"
-
-using namespace ::com::sun::star;
-
-namespace vclcanvas
-{
- namespace
- {
- bool textureFill( OutputDevice& rOutDev,
- GraphicObject& rGraphic,
- const ::Point& rPosPixel,
- const ::Size& rNextTileX,
- const ::Size& rNextTileY,
- sal_Int32 nTilesX,
- sal_Int32 nTilesY,
- const ::Size& rTileSize,
- const GraphicAttr& rAttr)
- {
- BOOL bRet( false );
- Point aCurrPos;
- int nX, nY;
-
- for( nY=0; nY < nTilesY; ++nY )
- {
- aCurrPos.X() = rPosPixel.X() + nY*rNextTileY.Width();
- aCurrPos.Y() = rPosPixel.Y() + nY*rNextTileY.Height();
-
- for( nX=0; nX < nTilesX; ++nX )
- {
- // update return value. This method should return true, if
- // at least one of the looped Draws succeeded.
- bRet |= rGraphic.Draw( &rOutDev,
- aCurrPos,
- rTileSize,
- &rAttr );
-
- aCurrPos.X() += rNextTileX.Width();
- aCurrPos.Y() += rNextTileX.Height();
- }
- }
-
- return bRet;
- }
-
- inline sal_Int32 roundDown( const double& rVal )
- {
- return static_cast< sal_Int32 >( floor( rVal ) );
- }
-
- inline sal_Int32 roundUp( const double& rVal )
- {
- return static_cast< sal_Int32 >( ceil( rVal ) );
- }
- }
-
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTexturedPolyPolygon( const rendering::XCanvas& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const uno::Sequence< rendering::Texture >& textures )
- {
- CHECK_AND_THROW( xPolyPolygon.is(),
- "CanvasHelper::fillPolyPolygon(): polygon is NULL");
- CHECK_AND_THROW( textures.getLength(),
- "CanvasHelper::fillTexturedPolyPolygon: empty texture sequence");
-
- printf ("texture fill called, TODO\n");
-
- cairo_save( mpCairo );
-
- useStates( viewState, renderState, true );
-
- mpTextures = &textures;
-
- drawPolyPolygonPath( xPolyPolygon, Fill );
-
- mpTextures = NULL;
-
- cairo_restore( mpCairo );
-
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
- }
-}
diff --git a/scratch/canvas-cairo/cairo_helper.cxx b/scratch/canvas-cairo/cairo_helper.cxx
deleted file mode 100644
index 24223a588..000000000
--- a/scratch/canvas-cairo/cairo_helper.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-namespace cairo {
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <cairo.h>
-#include <cairo-xlib.h>
-
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-#include <GL/glx.h>
-
-#include <cairo-glitz.h>
-
-#include <glitz.h>
-#include <glitz-glx.h>
-#endif
-}
-
-#ifndef _SV_SYSDATA_HXX
-#include <vcl/sysdata.hxx>
-#endif
-
-#ifndef _SV_BITMAP_HXX
-#include <vcl/bitmap.hxx>
-#endif
-
-using namespace ::cairo;
-
-//#define OOO_CANVAS_GLITZ 1
-
-int cairoHelperGetDefaultScreen( void* display )
-{
- return DefaultScreen( ( (Display *) display ) );
-}
-
-void*
-cairoHelperGetGlitzDrawable( const SystemEnvData* pSysData, int width, int height )
-{
-#ifdef OOO_CANVAS_GLITZ
- Display* display = (Display*) pSysData->pDisplay;
- ::cairo::Window window = pSysData->aWindow;
- VisualID vid = XVisualIDFromVisual( (Visual*) pSysData->pVisual );
- int screen = DefaultScreen( display );
-
- glitz_drawable_t *pDrawable = NULL;
- glitz_format_t* pFormat = NULL;
- glitz_drawable_format_t* pDrawableFormat;
- XWindowAttributes attrs;
-
- XGetWindowAttributes (display, window, &attrs);
- VisualID wVID = XVisualIDFromVisual( attrs.visual );
- printf ("find format for visual id %d (%d)\n", wVID, vid);
- pDrawableFormat = glitz_glx_find_drawable_format_for_visual ( display, screen, wVID );
-
- if( pDrawableFormat )
- printf ("format found color %d %d %d %d doublebuffer %d\n",
- pDrawableFormat->color.red_size,
- pDrawableFormat->color.green_size,
- pDrawableFormat->color.blue_size,
- pDrawableFormat->color.alpha_size,
- pDrawableFormat->doublebuffer);
-
- if( pDrawableFormat && pDrawableFormat->doublebuffer == 0 )
- pDrawable = glitz_glx_create_drawable_for_window( display, screen, pDrawableFormat, window, attrs.width, attrs.height );
-
- return pDrawable;
-#endif
- return NULL;
-}
-
-void*
-cairoHelperGetGlitzSurface( const SystemEnvData* pSysData, void *drawable, int x, int y, int width, int height )
-{
-#ifdef OOO_CANVAS_GLITZ
- Display* display = (Display*) pSysData->pDisplay;
- ::cairo::Window window = pSysData->aWindow;
-
- glitz_drawable_t *pDrawable = (glitz_drawable_t *) drawable;
- glitz_format_t* pFormat = NULL;
- glitz_surface_t* pGlitzSurface = NULL;
-
- if( pDrawable )
- pFormat = glitz_find_standard_format (pDrawable, GLITZ_STANDARD_ARGB32 );
-
- if( pFormat )
- pGlitzSurface = glitz_surface_create( pDrawable, pFormat, width, height, 0, NULL );
-
- if (pGlitzSurface)
- glitz_surface_attach (pGlitzSurface, pDrawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR, x, y );
-
- if( pGlitzSurface )
- printf ("glitz surface created successfully\n");
-
- return pGlitzSurface;
-#endif
- return NULL;
-}
-
-void*
-cairoHelperGetSurface( const SystemEnvData* pSysData, int x, int y, int width, int height )
-{
- cairo_surface_t* pSurface = NULL;
-
-#ifdef OOO_CANVAS_GLITZ
-#ifdef CAIRO_HAS_GLITZ_SURFACE
- glitz_drawable_t* pGlitzDrawable;
- glitz_surface_t* pGlitzSurface;
-
- printf ("try to create glitz surface %d x %d\n", width, height );
- pGlitzDrawable = (glitz_drawable_t*) cairoHelperGetGlitzDrawable( pSysData, width, height );
-
- if( pGlitzDrawable )
- pGlitzSurface = (glitz_surface_t*) cairoHelperGetGlitzSurface( pSysData, pGlitzDrawable, x, y, width, height );
-
- if( pGlitzSurface )
- pSurface = cairo_glitz_surface_create( pGlitzSurface );
-
-#endif
-#endif
- if( !pSurface ) {
- pSurface=cairo_xlib_surface_create( (Display*) pSysData->pDisplay,
- pSysData->aWindow,
- (Visual*) pSysData->pVisual,
- width + x, height + y );
- cairo_surface_set_device_offset( pSurface, x, y );
- }
-
- return pSurface;
-}
-
-void
-cairoHelperFlush( const SystemEnvData* pSysData )
-{
- #ifdef CAIRO_HAS_GLITZ_SURFACE
- glXWaitGL();
- glXWaitX();
- //glFinish();
- #else
- XSync( (Display*) pSysData->pDisplay, false );
- #endif
-}
-
-void*
-cairoHelperGetSurface( const SystemEnvData* pSysData, const BitmapSystemData& rBmpData, int width, int height )
-{
- return cairo_xlib_surface_create( (Display*) pSysData->pDisplay,
- (Drawable) rBmpData.aPixmap,
- (Visual*) pSysData->pVisual,
- width, height );
-}
diff --git a/scratch/canvas-cairo/cairo_helper.hxx b/scratch/canvas-cairo/cairo_helper.hxx
deleted file mode 100644
index c3eb87ed9..000000000
--- a/scratch/canvas-cairo/cairo_helper.hxx
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _SV_SYSDATA_HXX
-#include <vcl/sysdata.hxx>
-#endif
-
-#ifndef _SV_BITMAP_HXX
-#include <vcl/bitmap.hxx>
-#endif
-
-int cairoHelperGetDefaultScreen( void* display );
-void* cairoHelperGetGlitzDrawable( const SystemEnvData* pSysData, int width, int height );
-void* cairoHelperGetGlitzSurface( const SystemEnvData* pSysData, void *drawable, int x, int y, int width, int height );
-void* cairoHelperGetSurface( const SystemEnvData* pSysData, int x, int y, int width, int height );
-void cairoHelperFlush( const SystemEnvData* pSysData );
-void* cairoHelperGetSurface( const SystemEnvData* pSysData, const BitmapSystemData& rBmpData, int width, int height );
diff --git a/scratch/canvas-cairo/cairo_impltools.cxx b/scratch/canvas-cairo/cairo_impltools.cxx
deleted file mode 100644
index 96481b8c1..000000000
--- a/scratch/canvas-cairo/cairo_impltools.cxx
+++ /dev/null
@@ -1,443 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef _USE_MATH_DEFINES
-#define _USE_MATH_DEFINES // needed by Visual C++ for math constants
-#endif
-#include <math.h> // M_PI definition
-
-#ifndef _RTL_LOGFILE_HXX_
-#include <rtl/logfile.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_GEOMETRY_REALSIZE2D_HPP__
-#include <com/sun/star/geometry/RealSize2D.hpp>
-#endif
-#ifndef _COM_SUN_STAR_GEOMETRY_REALPOINT2D_HPP__
-#include <com/sun/star/geometry/RealPoint2D.hpp>
-#endif
-#ifndef _COM_SUN_STAR_GEOMETRY_REALRECTANGLE2D_HPP__
-#include <com/sun/star/geometry/RealRectangle2D.hpp>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_RENDERSTATE_HPP__
-#include <com/sun/star/rendering/RenderState.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP__
-#include <com/sun/star/rendering/XCanvas.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XBITMAP_HPP__
-#include <com/sun/star/rendering/XBitmap.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XPOLYPOLYGON2D_HPP__
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#endif
-#ifndef _COM_SUN_STAR_GEOMETRY_REALBEZIERSEGMENT2D_HPP__
-#include <com/sun/star/geometry/RealBezierSegment2D.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP__
-#include <com/sun/star/rendering/XIntegerBitmap.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#endif
-
-#ifndef _SV_SALBTYPE_HXX
-#include <vcl/salbtype.hxx>
-#endif
-#ifndef _SV_BMPACC_HXX
-#include <vcl/bmpacc.hxx>
-#endif
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-#ifndef _SV_METRIC_HXX
-#include <vcl/metric.hxx>
-#endif
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_TUPLE_B2DTUPLE_HXX
-#include <basegfx/tuple/b2dtuple.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
-#include <basegfx/range/b2drectangle.hxx>
-#endif
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-
-#include "cairo_impltools.hxx"
-#include "cairo_linepolypolygon.hxx"
-#include "cairo_canvasbitmap.hxx"
-
-#include <numeric>
-
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- namespace tools
- {
- ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
- {
- LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() );
-
- if( pPolyImpl )
- {
- return pPolyImpl->getPolyPolygon();
- }
- else
- {
- const sal_Int32 nPolys( xPoly->getNumberOfPolygons() );
-
- // not a known implementation object - try data source
- // interfaces
- uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
- xPoly,
- uno::UNO_QUERY );
-
- if( xBezierPoly.is() )
- {
- return ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence(
- xBezierPoly->getBezierSegments( 0,
- nPolys,
- 0,
- -1 ) );
- }
- else
- {
- uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly(
- xPoly,
- uno::UNO_QUERY );
-
- // no implementation class and no data provider
- // found - contract violation.
- CHECK_AND_THROW( xLinePoly.is(),
- "CairoCanvas::polyPolygonFromXPolyPolygon2D(): Invalid input "
- "poly-polygon, cannot retrieve vertex data" );
-
- return ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence(
- xLinePoly->getPoints( 0,
- nPolys,
- 0,
- -1 ) );
- }
- }
- }
-
- Cairo* cairoFromXBitmap( const uno::Reference< rendering::XBitmap >& xBitmap )
- {
- uno::Reference< lang::XServiceInfo > xRef( xBitmap,
- uno::UNO_QUERY );
-
- if( xRef.is() &&
- xRef->getImplementationName().equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CANVASBITMAP_IMPLEMENTATION_NAME))) )
- {
- // TODO(Q1): Maybe use dynamic_cast here
- return static_cast<CanvasBitmap*>(xBitmap.get())->getCairo();
- }
-
- return NULL;
- }
-
- ::BitmapEx bitmapExFromXBitmap( const uno::Reference< rendering::XBitmap >& xBitmap )
- {
- uno::Reference< lang::XUnoTunnel > xTunnel( xBitmap, uno::UNO_QUERY );
- if( xTunnel.is() )
- {
- sal_Int64 nPtr = xTunnel->getSomething( vcl::unotools::getTunnelIdentifier( vcl::unotools::Id_BitmapEx ) );
- if( nPtr )
- return BitmapEx( *(BitmapEx*)nPtr );
- }
-
- // TODO(F1): extract pixel from XBitmap interface
- ENSURE_AND_THROW( false,
- "bitmapExFromXBitmap(): could not extract BitmapEx" );
-
- return ::BitmapEx();
- }
-
- Surface* surfaceFromXBitmap( const uno::Reference< rendering::XBitmap >& xBitmap, const WindowGraphicDevice::ImplRef& rDevice, unsigned char*& data )
- {
- Surface* pSurface = NULL;
- Cairo* pCairo = cairoFromXBitmap( xBitmap );
- if( pCairo ) {
- pSurface = cairo_get_target( pCairo );
- cairo_surface_reference( pSurface );
- data = NULL;
- } else {
- BitmapEx aBmpEx = bitmapExFromXBitmap(xBitmap);
- Bitmap aBitmap = aBmpEx.GetBitmap();
- AlphaMask aAlpha = aBmpEx.GetAlpha();
-
- // there's no pixmap for alpha bitmap. we might still
- // use rgb pixmap and only access alpha pixels the
- // slow way. now we just speedup rgb bitmaps
- if( !aBmpEx.IsTransparent() && !aBmpEx.IsAlpha() ) {
- WindowGraphicDevice::ImplRef xDevice = rDevice;
- pSurface = xDevice->getSurface( aBitmap );
- data = NULL;
- }
-
- if( !pSurface ) {
-
- BitmapReadAccess* pBitmapReadAcc = aBitmap.AcquireReadAccess();
- BitmapReadAccess* pAlphaReadAcc = aAlpha.AcquireReadAccess();
-
- const long nWidth = pBitmapReadAcc->Width();
- const long nHeight = pBitmapReadAcc->Height();
- long nX, nY;
-
- data = (unsigned char*) malloc( nWidth*nHeight*4 );
- long nOff = 0;
- Color aColor;
- unsigned int nAlpha = 255;
-
- for( nY = 0; nY < nHeight; nY++ )
- for( nX = 0; nX < nWidth; nX++ ) {
- if( pAlphaReadAcc)
- nAlpha = 255 - pAlphaReadAcc->GetColor( nY, nX ).GetBlue();
- aColor = pBitmapReadAcc->GetColor( nY, nX );
-
- // cairo need premultiplied color values
- // TODO(rodo) handle endianess
- data [nOff++] = ( nAlpha*aColor.GetBlue() )/255;
- data [nOff++] = ( nAlpha*aColor.GetGreen() )/255;
- data [nOff++] = ( nAlpha*aColor.GetRed() )/255;
- data [nOff++] = nAlpha;
- }
-
- pSurface = cairo_image_surface_create_for_data( data, CAIRO_FORMAT_ARGB32, nWidth, nHeight, nWidth*4 );
- }
- }
-
- return pSurface;
- }
-
- bool setupFontTransform( ::Point& o_rPoint,
- ::Font& io_rVCLFont,
- const rendering::ViewState& rViewState,
- const rendering::RenderState& rRenderState,
- ::OutputDevice& rOutDev )
- {
- ::basegfx::B2DHomMatrix aMatrix;
-
- ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- rViewState,
- rRenderState);
-
- ::basegfx::B2DTuple aScale;
- ::basegfx::B2DTuple aTranslate;
- double nRotate, nShearX;
-
- aMatrix.decompose( aScale, aTranslate, nRotate, nShearX );
-
- // query font metric _before_ tampering with width and height
- if( !::rtl::math::approxEqual(aScale.getX(), aScale.getY()) )
- {
- // retrieve true font width
- const int nFontWidth( rOutDev.GetFontMetric( io_rVCLFont ).GetWidth() );
-
- const int nScaledFontWidth( ::basegfx::fround(nFontWidth * aScale.getX()) );
-
- if( !nScaledFontWidth )
- {
- // scale is smaller than one pixel - disable text
- // output altogether
- return false;
- }
-
- io_rVCLFont.SetWidth( nScaledFontWidth );
- }
-
- if( !::rtl::math::approxEqual(aScale.getY(), 1.0) )
- {
- const int nFontHeight( io_rVCLFont.GetHeight() );
- io_rVCLFont.SetHeight( ::basegfx::fround(nFontHeight * aScale.getY()) );
- }
-
- io_rVCLFont.SetOrientation( static_cast< short >( ::basegfx::fround(-fmod(nRotate, 2*M_PI)*(1800.0/M_PI)) ) );
-
- // TODO(F2): Missing functionality in VCL: shearing
- o_rPoint.X() = ::basegfx::fround(aTranslate.getX());
- o_rPoint.Y() = ::basegfx::fround(aTranslate.getY());
-
- return true;
- }
-
- bool isPolyPolygonEqualRectangle( const PolyPolygon& rPolyPoly,
- const Rectangle& rRect )
- {
- // exclude some cheap cases first
- if( rPolyPoly.Count() != 1 )
- return false;
-
- const ::Polygon& rPoly( rPolyPoly[0] );
-
- USHORT nCount( rPoly.GetSize() );
- if( nCount != 4 && nCount != 5 )
- return false;
-
- // fill array with rectangle vertices
- const ::Point aPoints[4] =
- {
- rRect.TopLeft(),
- rRect.TopRight(),
- rRect.BottomRight(),
- rRect.BottomLeft()
- };
-
- // now match polygon and rectangle start points, to
- // facilitate point-by-point comparison
- const ::Point* aIter;
- const ::Point* const aEnd( &aPoints[5] );
- if( (aIter=::std::find( aPoints, aEnd,
- rPoly[0] )) == aEnd )
- return false; // point not found
-
- // determine index from iterator
- const ::std::size_t nIndexOfFirstPoint( aIter - aPoints );
-
- bool bNotMatching( false ); // when true, at least on
- // point does not match
-
- // start point found, now try forward sweep to match
- // points
- for( USHORT i=0; i<4; ++i )
- {
- if( rPoly[i] != aPoints[ (i+nIndexOfFirstPoint)%4 ] )
- {
- bNotMatching = true;
- break;
- }
- }
-
- if( !bNotMatching )
- return true; // all points match, done
-
- // at least one point doesn't match, try reverse sweep to
- // match points
- for( USHORT i=0; i<4; ++i )
- {
- if( rPoly[i] != aPoints[ (4-i+nIndexOfFirstPoint)%4 ] )
- return false; // nothing more to try, exit directly
- }
-
- // all points for reverse sweep match
- return true;
- }
-
-
- // VCL-Canvas related
- //---------------------------------------------------------------------
-
- ::Point mapRealPoint2D( const geometry::RealPoint2D& rPoint,
- const rendering::ViewState& rViewState,
- const rendering::RenderState& rRenderState )
- {
- ::basegfx::B2DPoint aPoint( ::basegfx::unotools::b2DPointFromRealPoint2D(rPoint) );
-
- ::basegfx::B2DHomMatrix aMatrix;
- aPoint *= ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- rViewState,
- rRenderState);
-
- return ::vcl::unotools::pointFromB2DPoint( aPoint );
- }
-
- ::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
- const rendering::ViewState& rViewState,
- const rendering::RenderState& rRenderState )
- {
- ::basegfx::B2DHomMatrix aMatrix;
- ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- rViewState,
- rRenderState);
-
- ::basegfx::B2DPolyPolygon aTemp( rPoly );
-
- aTemp.transform( aMatrix );
-
- return ::PolyPolygon( aTemp );
- }
- }
-}
diff --git a/scratch/canvas-cairo/cairo_impltools.hxx b/scratch/canvas-cairo/cairo_impltools.hxx
deleted file mode 100644
index 81ef5f84e..000000000
--- a/scratch/canvas-cairo/cairo_impltools.hxx
+++ /dev/null
@@ -1,258 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_TOOLS_HXX
-#define _VCLCANVAS_TOOLS_HXX
-
-#ifndef _OSL_MUTEX_HXX_
-#include <osl/mutex.hxx>
-#endif
-#ifndef _VOS_MUTEX_HXX_
-#include <vos/mutex.hxx>
-#endif
-#ifndef _SV_SVAPP_HXX
-#include <vcl/svapp.hxx>
-#endif
-
-#ifndef _SV_OUTDEV_HXX
-#include <vcl/outdev.hxx>
-#endif
-
-#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
-#include <com/sun/star/uno/Reference.hxx>
-#endif
-#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
-#include <com/sun/star/uno/Sequence.hxx>
-#endif
-
-#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
-#include <boost/shared_ptr.hpp>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_outdevprovider.hxx"
-#include "cairo_windowgraphicdevice.hxx"
-
-class OutputDevice;
-class Point;
-class Size;
-
-namespace basegfx
-{
- namespace matrix
- {
- class B2DHomMatrix;
- }
- namespace vector
- {
- class B2DVector;
- }
- namespace point
- {
- class B2DPoint;
- }
-}
-
-namespace com { namespace sun { namespace star { namespace awt
-{
- struct Point;
- struct Size;
- struct Rectangle;
-} } } }
-
-namespace com { namespace sun { namespace star { namespace drawing
-{
- struct HomogenMatrix3;
-} } } }
-
-namespace com { namespace sun { namespace star { namespace geometry
-{
- struct RealPoint2D;
- struct RealSize2D;
- struct RealRectangle2D;
-} } } }
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- struct RenderState;
- struct ViewState;
- class XCanvas;
- class XBitmap;
- class XPolyPolygon2D;
-} } } }
-
-
-namespace vclcanvas
-{
- namespace tools
- {
- ::basegfx::B2DPolyPolygon
- polyPolygonFromXPolyPolygon2D( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& );
-
- ::BitmapEx bitmapExFromXBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& );
- ::cairo::Cairo* cairoFromXBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& );
- ::cairo::Surface* surfaceFromXBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& xBitmap,
- const WindowGraphicDevice::ImplRef& rDevice,
- unsigned char*& data );
-
- /** Setup VCL font and output position
-
- @returns false, if no text output should happen
- */
- bool setupFontTransform( ::Point& o_rPoint,
- ::Font& io_rVCLFont,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- ::OutputDevice& rOutDev );
-
- /** Predicate, to determine whether polygon is equal to given rectangle
-
- @return true, if the polygon exactly describes the given rectangle
- */
- bool isPolyPolygonEqualRectangle( const PolyPolygon& rPolyPoly,
- const Rectangle& rRect );
-
-
- // Little helper to encapsulate locking into policy class
- class LocalGuard
- {
- public:
- LocalGuard() :
- aGuard( Application::GetSolarMutex() )
- {
- }
-
- /// To be compatible with CanvasBase mutex concept
- LocalGuard( const ::osl::Mutex& ) :
- aGuard( Application::GetSolarMutex() )
- {
- }
-
- private:
- ::vos::OGuard aGuard;
- };
-
- class OutDevStateKeeper
- {
- public:
- typedef ::boost::shared_ptr< canvas::vcltools::VCLObject< OutputDevice > > OutputDeviceSharedPtr;
-
- explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
- mpOutDev( &rOutDev ),
- mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() )
- {
- init();
- }
-
- explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
- mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : NULL ),
- mbMappingWasEnabled( mpOutDev ? mpOutDev->IsMapModeEnabled() : false )
- {
- init();
- }
-
- ~OutDevStateKeeper()
- {
- if( mpOutDev )
- {
- mpOutDev->EnableMapMode( mbMappingWasEnabled );
- mpOutDev->Pop();
- }
- }
-
- private:
- void init()
- {
- if( mpOutDev )
- {
- mpOutDev->Push();
- mpOutDev->EnableMapMode(FALSE);
- }
- }
-
- OutputDevice* mpOutDev;
- const bool mbMappingWasEnabled;
- };
-
- ::Point mapRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint,
- const ::com::sun::star::rendering::ViewState& rViewState,
- const ::com::sun::star::rendering::RenderState& rRenderState );
-
- ::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
- const ::com::sun::star::rendering::ViewState& rViewState,
- const ::com::sun::star::rendering::RenderState& rRenderState );
-
- enum ModulationMode
- {
- MODULATE_NONE,
- MODULATE_WITH_DEVICECOLOR
- };
- }
-}
-
-#endif /* _VCLCANVAS_TOOLS_HXX */
diff --git a/scratch/canvas-cairo/cairo_linepolypolygon.cxx b/scratch/canvas-cairo/cairo_linepolypolygon.cxx
deleted file mode 100644
index 921baea14..000000000
--- a/scratch/canvas-cairo/cairo_linepolypolygon.cxx
+++ /dev/null
@@ -1,114 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
-#include <basegfx/polygon/b2dpolygon.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-
-#include "cairo_impltools.hxx"
-#include "cairo_linepolypolygon.hxx"
-
-
-
-using namespace ::com::sun::star;
-
-namespace vclcanvas
-{
-
- LinePolyPolygon::LinePolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) :
- ::canvas::tools::LinePolyPolygonBase( rPolyPoly )
- {
- }
-
- LinePolyPolygon::~LinePolyPolygon()
- {
- }
-
- ::rtl::OUString SAL_CALL LinePolyPolygon::getImplementationName() throw (uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LINEPOLYPOLYGON_IMPLEMENTATION_NAME ) );
- }
-
-#define SERVICE_NAME "com.sun.star.rendering.LinePolyPolygon"
-
- sal_Bool SAL_CALL LinePolyPolygon::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL LinePolyPolygon::getSupportedServiceNames( ) throw (uno::RuntimeException)
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-}
-
-// eof
diff --git a/scratch/canvas-cairo/cairo_linepolypolygon.hxx b/scratch/canvas-cairo/cairo_linepolypolygon.hxx
deleted file mode 100644
index a88b28fbc..000000000
--- a/scratch/canvas-cairo/cairo_linepolypolygon.hxx
+++ /dev/null
@@ -1,100 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_LINEPOLYPOLYGON_HXX_
-#define _VCLCANVAS_LINEPOLYPOLYGON_HXX_
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-
-#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-#include <canvas/linepolypolygonbase.hxx>
-#include <canvas/vclwrapper.hxx>
-
-
-#define LINEPOLYPOLYGON_IMPLEMENTATION_NAME "CairoCanvas::LinePolyPolygon"
-
-namespace vclcanvas
-{
- class LinePolyPolygon : public ::canvas::tools::LinePolyPolygonBase
- {
- public:
- explicit LinePolyPolygon( const ::basegfx::B2DPolyPolygon& );
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
-
- protected:
- ~LinePolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- };
-}
-
-#endif /* _VCLCANVAS_LINEPOLYPOLYGON_HXX_ */
-// eof
diff --git a/scratch/canvas-cairo/cairo_outdevprovider.hxx b/scratch/canvas-cairo/cairo_outdevprovider.hxx
deleted file mode 100644
index ac9a4e549..000000000
--- a/scratch/canvas-cairo/cairo_outdevprovider.hxx
+++ /dev/null
@@ -1,92 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_OUTDEVPROVIDER_HXX
-#define _VCLCANVAS_OUTDEVPROVIDER_HXX
-
-#include <sal/types.h>
-
-#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
-#include <boost/shared_ptr.hpp>
-#endif
-
-class OutputDevice;
-
-namespace vclcanvas
-{
- /* Definition of OutDevProvider interface */
-
- /** Implementers of this interface provide the CanvasHelper
- with its OutputDevice
- */
- class OutDevProvider
- {
- public:
- virtual ~OutDevProvider() {}
-
- virtual OutputDevice& getOutDev() = 0;
- virtual const OutputDevice& getOutDev() const = 0;
- };
-
- typedef ::boost::shared_ptr< OutDevProvider > OutDevProviderSharedPtr;
-}
-
-#endif /* _VCLCANVAS_OUTDEVPROVIDER_HXX */
diff --git a/scratch/canvas-cairo/cairo_parametricpolypolygon.cxx b/scratch/canvas-cairo/cairo_parametricpolypolygon.cxx
deleted file mode 100644
index dc493300c..000000000
--- a/scratch/canvas-cairo/cairo_parametricpolypolygon.cxx
+++ /dev/null
@@ -1,899 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _USE_MATH_DEFINES
-#define _USE_MATH_DEFINES // needed by Visual C++ for math constants
-#endif
-#include <math.h> // M_PI definition
-
-#include <canvas/debug.hxx>
-#include <canvas/canvastools.hxx>
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_POLYGON_B2DPOLYGONTOOLS_HXX
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#endif
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
-#include <basegfx/range/b2drectangle.hxx>
-#endif
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-#ifndef _BGFX_TOOLS_TOOLS_HXX
-#include <basegfx/tools/tools.hxx>
-#endif
-
-#include <limits>
-
-#include "cairo_impltools.hxx"
-#include "cairo_parametricpolypolygon.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace vclcanvas
-{
- ParametricPolyPolygon* ParametricPolyPolygon::createLinearHorizontalGradient( const uno::Sequence< double >& leftColor,
- const uno::Sequence< double >& rightColor,
- const uno::Reference< rendering::XGraphicDevice >& xDevice )
- {
- // TODO(P2): hold gradient brush statically, and only setup
- // the colors
- return new ParametricPolyPolygon( GRADIENT_LINEAR,
- ::vcl::unotools::sequenceToColor( xDevice,
- leftColor ),
- ::vcl::unotools::sequenceToColor( xDevice,
- rightColor ) );
- }
-
- ParametricPolyPolygon* ParametricPolyPolygon::createAxialHorizontalGradient( const uno::Sequence< double >& middleColor,
- const uno::Sequence< double >& endColor,
- const uno::Reference< rendering::XGraphicDevice >& xDevice )
- {
- // TODO(P2): hold gradient brush statically, and only setup
- // the colors
- return new ParametricPolyPolygon( GRADIENT_AXIAL,
- ::vcl::unotools::sequenceToColor( xDevice,
- endColor ),
- ::vcl::unotools::sequenceToColor( xDevice,
- middleColor ) );
- }
-
- namespace
- {
- double calcAspectRatio( const geometry::RealRectangle2D& rBoundRect )
- {
- const double nWidth( rBoundRect.X2 - rBoundRect.X1 );
- const double nHeight( rBoundRect.Y2 - rBoundRect.Y1 );
-
- return ::basegfx::fTools::equalZero( nHeight ) ? 1.0 : fabs( nWidth / nHeight );
- }
- }
-
- ParametricPolyPolygon* ParametricPolyPolygon::createEllipticalGradient( const uno::Sequence< double >& centerColor,
- const uno::Sequence< double >& endColor,
- const geometry::RealRectangle2D& boundRect,
- const uno::Reference< rendering::XGraphicDevice >& xDevice )
- {
- // TODO(P2): hold gradient polygon statically, and only setup
- // the colors
- return new ParametricPolyPolygon(
- ::basegfx::tools::createPolygonFromCircle(
- ::basegfx::B2DPoint( 0.5, 0.5), 0.5 ),
- ::vcl::unotools::sequenceToColor( xDevice,
- endColor ),
- ::vcl::unotools::sequenceToColor( xDevice,
- centerColor ),
- calcAspectRatio( boundRect ) );
- }
-
- ParametricPolyPolygon* ParametricPolyPolygon::createRectangularGradient( const uno::Sequence< double >& centerColor,
- const uno::Sequence< double >& endColor,
- const geometry::RealRectangle2D& boundRect,
- const uno::Reference< rendering::XGraphicDevice >& xDevice )
- {
- // TODO(P2): hold gradient polygon statically, and only setup
- // the colors
- return new ParametricPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( 0.0, 0.0, 1.0, 1.0 ) ),
- ::vcl::unotools::sequenceToColor( xDevice,
- endColor ),
- ::vcl::unotools::sequenceToColor( xDevice,
- centerColor ),
- calcAspectRatio( boundRect ) );
- }
-
- void SAL_CALL ParametricPolyPolygon::disposing()
- {
- }
-
- uno::Reference< rendering::XPolyPolygon2D > SAL_CALL ParametricPolyPolygon::getOutline( double t ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): outline NYI
- return uno::Reference< rendering::XPolyPolygon2D >();
- }
-
- uno::Sequence< double > SAL_CALL ParametricPolyPolygon::getColor( double t ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): color NYI
- return uno::Sequence< double >();
- }
-
- uno::Sequence< double > SAL_CALL ParametricPolyPolygon::getPointColor( const geometry::RealPoint2D& point ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): point color NYI
- return uno::Sequence< double >();
- }
-
-#define SERVICE_NAME "com.sun.star.rendering.ParametricPolyPolygon"
-
- ::rtl::OUString SAL_CALL ParametricPolyPolygon::getImplementationName( ) throw (uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL ParametricPolyPolygon::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL ParametricPolyPolygon::getSupportedServiceNames( ) throw (uno::RuntimeException)
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
- namespace
- {
- /** Fill linear or axial gradient
-
- Since most of the code for linear and axial gradients are
- the same, we've a unified method here
- */
- void fillGeneralLinearGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- const ::Color& rColor1,
- const ::Color& rColor2,
- bool bFillNonOverlapping,
- bool bAxialGradient )
- {
- // determine general position of gradient in relation to
- // the bound rect
- // =====================================================
-
- ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
- ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
- ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
- ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
-
- aLeftTop *= rTextureTransform;
- aLeftBottom *= rTextureTransform;
- aRightTop *= rTextureTransform;
- aRightBottom*= rTextureTransform;
-
- // calc length of bound rect diagonal
- const ::basegfx::B2DVector aBoundRectDiagonal(
- ::vcl::unotools::b2DPointFromPoint( rBounds.TopLeft() ) -
- ::vcl::unotools::b2DPointFromPoint( rBounds.BottomRight() ) );
- const double nDiagonalLength( aBoundRectDiagonal.getLength() );
-
- // create direction of gradient:
- // _______
- // | | |
- // -> | | | ...
- // | | |
- // -------
- ::basegfx::B2DVector aDirection( aRightTop - aLeftTop );
- aDirection.normalize();
-
- // now, we potentially have to enlarge our gradient area
- // atop and below the transformed [0,1]x[0,1] unit rect,
- // for the gradient to fill the complete bound rect.
- ::basegfx::tools::infiniteLineFromParallelogram( aLeftTop,
- aLeftBottom,
- aRightTop,
- aRightBottom,
- ::vcl::unotools::b2DRectangleFromRectangle( rBounds ) );
-
-
- // render gradient
- // ===============
-
- // for linear gradients, it's easy to render
- // non-overlapping polygons: just split the gradient into
- // nStepCount small strips. Prepare the strip now.
-
- // For performance reasons, we create a temporary VCL
- // polygon here, keep it all the way and only change the
- // vertex values in the loop below (as ::Polygon is a
- // pimpl class, creating one every loop turn would really
- // stress the mem allocator)
- ::Polygon aTempPoly( static_cast<USHORT>(5) );
-
- OSL_ENSURE( nStepCount >= 3,
- "fillLinearGradient(): stepcount smaller than 3" );
-
-
- // fill initial strip (extending two times the bound rect's
- // diagonal to the 'left'
- // ------------------------------------------------------
-
- // calculate left edge, by moving left edge of the
- // gradient rect two times the bound rect's diagonal to
- // the 'left'. Since we postpone actual rendering into the
- // loop below, we set the _right_ edge here, which will be
- // readily copied into the left edge in the loop below
- const ::basegfx::B2DPoint& rPoint1( aLeftTop - 2.0*nDiagonalLength*aDirection );
- aTempPoly[1] = ::Point( ::basegfx::fround( rPoint1.getX() ),
- ::basegfx::fround( rPoint1.getY() ) );
-
- const ::basegfx::B2DPoint& rPoint2( aLeftBottom - 2.0*nDiagonalLength*aDirection );
- aTempPoly[2] = ::Point( ::basegfx::fround( rPoint2.getX() ),
- ::basegfx::fround( rPoint2.getY() ) );
-
-
- // iteratively render all other strips
- // -----------------------------------
-
- // ensure that nStepCount is odd, to have a well-defined
- // middle index for axial gradients.
- if( bAxialGradient && !(nStepCount % 2) )
- ++nStepCount;
-
- const int nStepCountHalved( nStepCount / 2 );
-
- // only iterate nStepCount-1 steps, as the last strip is
- // explicitely painted below
- for( int i=0; i<nStepCount-1; ++i )
- {
- // lerp color
- if( bAxialGradient )
- {
- // axial gradient has a triangle-like interpolation function
- const int iPrime( i<=nStepCountHalved ? i : nStepCount-i-1);
-
- rOutDev.SetFillColor(
- Color( ((nStepCountHalved - iPrime)*rColor1.GetRed() + iPrime*rColor2.GetRed())/nStepCountHalved,
- ((nStepCountHalved - iPrime)*rColor1.GetGreen() + iPrime*rColor2.GetGreen())/nStepCountHalved,
- ((nStepCountHalved - iPrime)*rColor1.GetBlue() + iPrime*rColor2.GetBlue())/nStepCountHalved ) );
- }
- else
- {
- // linear gradient has a plain lerp between start and end color
- rOutDev.SetFillColor(
- Color( ((nStepCount - i)*rColor1.GetRed() + i*rColor2.GetRed())/nStepCount,
- ((nStepCount - i)*rColor1.GetGreen() + i*rColor2.GetGreen())/nStepCount,
- ((nStepCount - i)*rColor1.GetBlue() + i*rColor2.GetBlue())/nStepCount ) );
- }
-
- // copy right egde of polygon to left edge (and also
- // copy the closing point)
- aTempPoly[0] = aTempPoly[4] = aTempPoly[1];
- aTempPoly[3] = aTempPoly[2];
-
- // calculate new right edge, from interpolating
- // between start and end line. Note that i is
- // increased by one, to account for the fact that we
- // calculate the right border here (whereas the fill
- // color is governed by the left edge)
- const ::basegfx::B2DPoint& rPoint1(
- (nStepCount - i-1)/(double)nStepCount*aLeftTop +
- (i+1)/(double)nStepCount*aRightTop );
- aTempPoly[1] = ::Point( ::basegfx::fround( rPoint1.getX() ),
- ::basegfx::fround( rPoint1.getY() ) );
-
- const ::basegfx::B2DPoint& rPoint2(
- (nStepCount - i-1)/(double)nStepCount*aLeftBottom +
- (i+1)/(double)nStepCount*aRightBottom );
- aTempPoly[2] = ::Point( ::basegfx::fround( rPoint2.getX() ),
- ::basegfx::fround( rPoint2.getY() ) );
-
- rOutDev.DrawPolygon( aTempPoly );
- }
-
- // fill final strip (extending two times the bound rect's
- // diagonal to the 'right'
- // ------------------------------------------------------
-
- // copy right egde of polygon to left edge (and also
- // copy the closing point)
- aTempPoly[0] = aTempPoly[4] = aTempPoly[1];
- aTempPoly[3] = aTempPoly[2];
-
- // calculate new right edge, by moving right edge of the
- // gradient rect two times the bound rect's diagonal to
- // the 'right'.
- const ::basegfx::B2DPoint& rPoint3( aRightTop + 2.0*nDiagonalLength*aDirection );
- aTempPoly[0] = aTempPoly[4] = ::Point( ::basegfx::fround( rPoint3.getX() ),
- ::basegfx::fround( rPoint3.getY() ) );
-
- const ::basegfx::B2DPoint& rPoint4( aRightBottom + 2.0*nDiagonalLength*aDirection );
- aTempPoly[3] = ::Point( ::basegfx::fround( rPoint4.getX() ),
- ::basegfx::fround( rPoint4.getY() ) );
-
- if( bAxialGradient )
- rOutDev.SetFillColor( rColor1 );
- else
- rOutDev.SetFillColor( rColor2 );
-
- rOutDev.DrawPolygon( aTempPoly );
- }
- }
-
- void ParametricPolyPolygon::fillLinearGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const
- {
- fillGeneralLinearGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- maColor1,
- maColor2,
- bFillNonOverlapping,
- false );
- }
-
- void ParametricPolyPolygon::fillAxialGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const
- {
- fillGeneralLinearGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- maColor1,
- maColor2,
- bFillNonOverlapping,
- true );
- }
-
- void ParametricPolyPolygon::fillPolygonalGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const
- {
- ENSURE_AND_THROW( maGradientPoly.count() > 2,
- "ParametricPolyPolygon::fillPolygonalGradient(): polygon without area given" );
-
- // For performance reasons, we create a temporary VCL polygon
- // here, keep it all the way and only change the vertex values
- // in the loop below (as ::Polygon is a pimpl class, creating
- // one every loop turn would really stress the mem allocator)
- ::basegfx::B2DPolygon aOuterPoly( maGradientPoly );
- ::basegfx::B2DPolygon aInnerPoly;
-
- // subdivide polygon _before_ rendering, would otherwise have
- // to be performed on every loop turn.
- if( aOuterPoly.areControlPointsUsed() )
- aOuterPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aOuterPoly);
-
- aInnerPoly = aOuterPoly;
-
- // only transform outer polygon _after_ copying it into
- // aInnerPoly, because inner polygon has to be scaled before
- // the actual texture transformation takes place
- aOuterPoly.transform( rTextureTransform );
-
- // determine overall transformation for inner polygon (might
- // have to be prefixed by anisotrophic scaling)
- ::basegfx::B2DHomMatrix aInnerPolygonTransformMatrix;
-
-
- // apply scaling (possibly anisotrophic) to inner polygon
- // ------------------------------------------------------
-
- // move center of scaling to origin
- aInnerPolygonTransformMatrix.translate( -0.5, -0.5 );
-
- // scale inner polygon according to aspect ratio: for
- // wider-than-tall bounds (nAspectRatio > 1.0), the inner
- // polygon, representing the gradient focus, must have
- // non-zero width. Specifically, a bound rect twice as wide as
- // tall has a focus polygon of half it's width.
- if( mnAspectRatio > 1.0 )
- {
- // width > height case
- aInnerPolygonTransformMatrix.scale( 1.0 - 1.0/mnAspectRatio,
- 0.0 );
- }
- else if( mnAspectRatio < 1.0 )
- {
- // width < height case
- aInnerPolygonTransformMatrix.scale( 0.0,
- 1.0 - mnAspectRatio );
- }
- else
- {
- // isotrophic case
- aInnerPolygonTransformMatrix.scale( 0.0, 0.0 );
- }
-
- // move origin back to former center of polygon
- aInnerPolygonTransformMatrix.translate( 0.5, 0.5 );
-
- // and finally, add texture transform to it.
- aInnerPolygonTransformMatrix *= rTextureTransform;
-
- // apply final matrix to polygon
- aInnerPoly.transform( aInnerPolygonTransformMatrix );
-
-
- const sal_Int32 nNumPoints( aOuterPoly.count() );
- ::Polygon aTempPoly( static_cast<USHORT>(nNumPoints+1) );
-
- // increase number of steps by one: polygonal gradients have
- // the outermost polygon rendered in maColor2, and the
- // innermost in maColor1. The innermost polygon will never
- // have zero area, thus, we must divide the interval into
- // nStepCount+1 steps. For example, to create 3 steps:
- //
- // | |
- // |-------|-------|-------|
- // | |
- // 3 2 1 0
- //
- // This yields 4 tick marks, where 0 is never attained (since
- // zero-area polygons typically don't display perceivable
- // color).
- ++nStepCount;
-
- if( !bFillNonOverlapping )
- {
- // fill background
- rOutDev.SetFillColor( maColor1 );
- rOutDev.DrawRect( rBounds );
-
- // render polygon
- // ==============
-
- for( int i=1,p; i<nStepCount; ++i )
- {
- // lerp color
- rOutDev.SetFillColor(
- Color( ((nStepCount - i)*maColor1.GetRed() + i*maColor2.GetRed())/nStepCount,
- ((nStepCount - i)*maColor1.GetGreen() + i*maColor2.GetGreen())/nStepCount,
- ((nStepCount - i)*maColor1.GetBlue() + i*maColor2.GetBlue())/nStepCount ) );
-
- // scale and render polygon, by interpolating between
- // outer and inner polygon.
-
- // calc interpolation parameter in [0,1] range
- const double nT( (nStepCount-i)/(double)nStepCount );
-
- for( p=0; p<nNumPoints; ++p )
- {
- const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) );
- const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) );
-
- aTempPoly[p] = ::Point(
- ::basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ),
- ::basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) );
- }
-
- // close polygon explicitely
- aTempPoly[p] = aTempPoly[0];
-
- // TODO(P1): compare with vcl/source/gdi/outdev4.cxx,
- // OutputDevice::ImplDrawComplexGradient(), there's a note
- // that on some VDev's, rendering disjunct poly-polygons
- // is faster!
- rOutDev.DrawPolygon( aTempPoly );
- }
- }
- else
- {
- // render polygon
- // ==============
-
- // For performance reasons, we create a temporary VCL polygon
- // here, keep it all the way and only change the vertex values
- // in the loop below (as ::Polygon is a pimpl class, creating
- // one every loop turn would really stress the mem allocator)
- ::PolyPolygon aTempPolyPoly;
- ::Polygon aTempPoly2( static_cast<USHORT>(nNumPoints+1) );
-
- aTempPoly2[0] = rBounds.TopLeft();
- aTempPoly2[1] = rBounds.TopRight();
- aTempPoly2[2] = rBounds.BottomRight();
- aTempPoly2[3] = rBounds.BottomLeft();
- aTempPoly2[4] = rBounds.TopLeft();
-
- aTempPolyPoly.Insert( aTempPoly );
- aTempPolyPoly.Insert( aTempPoly2 );
-
- for( int i=0,p; i<nStepCount; ++i )
- {
- // lerp color
- rOutDev.SetFillColor(
- Color( ((nStepCount - i)*maColor1.GetRed() + i*maColor2.GetRed())/nStepCount,
- ((nStepCount - i)*maColor1.GetGreen() + i*maColor2.GetGreen())/nStepCount,
- ((nStepCount - i)*maColor1.GetBlue() + i*maColor2.GetBlue())/nStepCount ) );
-
-#if defined(VERBOSE) && defined(DBG_UTIL)
- if( i && !(i % 10) )
- rOutDev.SetFillColor( COL_RED );
-#endif
-
- // scale and render polygon. Note that here, we
- // calculate the inner polygon, which is actually the
- // start of the _next_ color strip. Thus, i+1
-
- // calc interpolation parameter in [0,1] range
- const double nT( (nStepCount-i-1)/(double)nStepCount );
-
- for( p=0; p<nNumPoints; ++p )
- {
- const ::basegfx::B2DPoint& rOuterPoint( aOuterPoly.getB2DPoint(p) );
- const ::basegfx::B2DPoint& rInnerPoint( aInnerPoly.getB2DPoint(p) );
-
- aTempPoly[p] = ::Point(
- ::basegfx::fround( (1.0-nT)*rInnerPoint.getX() + nT*rOuterPoint.getX() ),
- ::basegfx::fround( (1.0-nT)*rInnerPoint.getY() + nT*rOuterPoint.getY() ) );
- }
-
- // close polygon explicitely
- aTempPoly[p] = aTempPoly[0];
-
- // swap inner and outer polygon
- aTempPolyPoly.Replace( aTempPolyPoly.GetObject( 1 ), 0 );
-
- if( i+1<nStepCount )
- {
- // assign new inner polygon. Note that with this
- // formulation, the internal pimpl objects for both
- // temp polygons and the polypolygon remain identical,
- // minimizing heap accesses (only a Polygon wrapper
- // object is freed and deleted twice during this swap).
- aTempPolyPoly.Replace( aTempPoly, 1 );
- }
- else
- {
- // last, i.e. inner strip. Now, the inner polygon
- // has zero area anyway, and to not leave holes in
- // the gradient, finally render a simple polygon:
- aTempPolyPoly.Remove( 1 );
- }
-
- rOutDev.DrawPolyPolygon( aTempPolyPoly );
- }
- }
- }
-
- void ParametricPolyPolygon::fill( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const
- {
- switch( meType )
- {
- case GRADIENT_LINEAR:
- fillLinearGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- bFillNonOverlapping );
- break;
-
- case GRADIENT_AXIAL:
- fillAxialGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- bFillNonOverlapping );
- break;
-
- case GRADIENT_POLYGON:
- fillPolygonalGradient( rOutDev,
- rTextureTransform,
- rBounds,
- nStepCount,
- bFillNonOverlapping );
- break;
-
- default:
- ENSURE_AND_THROW( false,
- "ParametricPolyPolygon::fill(): Unexpected case" );
- }
- }
-
- bool ParametricPolyPolygon::fill( OutputDevice& rOutDev,
- OutputDevice* p2ndOutDev,
- const PolyPolygon& rPoly,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- const rendering::Texture& texture,
- int nTransparency ) const
- {
- // TODO(T2): It is maybe necessary to lock here, should
- // maGradientPoly someday cease to be const. But then, beware of
- // deadlocks, canvashelper calls this method with locked own
- // mutex.
-
- // calculate overall texture transformation (directly from
- // texture to device space).
- ::basegfx::B2DHomMatrix aMatrix;
- ::basegfx::B2DHomMatrix aTextureTransform;
-
- ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
- texture.AffineTransform );
- ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- viewState,
- renderState);
- aTextureTransform *= aMatrix; // prepend total view/render transformation
-
- // determine maximal bound rect of gradient-filled polygon
- const ::Rectangle aPolygonDeviceRectOrig(
- rPoly.GetBoundRect() );
-
- // determine size of gradient in device coordinate system
- // (to e.g. determine sensible number of gradient steps)
- ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
- ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
- ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
- ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
-
- aLeftTop *= aTextureTransform;
- aLeftBottom *= aTextureTransform;
- aRightTop *= aTextureTransform;
- aRightBottom*= aTextureTransform;
-
-
- // calc step size
- // --------------
- const int nColorSteps(
- ::std::max(
- labs( maColor1.GetRed() - maColor2.GetRed() ),
- ::std::max(
- labs( maColor1.GetGreen() - maColor2.GetGreen() ),
- labs( maColor1.GetBlue() - maColor2.GetBlue() ) ) ) );
-
- // longest line in gradient bound rect
- const int nGradientSize(
- static_cast<int>(
- ::std::max(
- ::basegfx::B2DVector(aRightBottom-aLeftTop).getLength(),
- ::basegfx::B2DVector(aRightTop-aLeftBottom).getLength() ) + 1.0 ) );
-
- // typical number for pixel of the same color (strip size)
- const int nStripSize( nGradientSize < 50 ? 2 : 4 );
-
- // use at least three steps, and at utmost the number of color
- // steps
- const int nStepCount(
- ::std::max(
- 3,
- ::std::min(
- nGradientSize / nStripSize,
- nColorSteps ) ) );
-
- rOutDev.SetLineColor();
-
- if( tools::isPolyPolygonEqualRectangle( rPoly,
- aPolygonDeviceRectOrig ) )
- {
- // use optimized output path
- // -------------------------
-
- // this distinction really looks like a
- // micro-optimisation, but in fact greatly speeds up
- // especially complex gradients. That's because when using
- // clipping, we can output polygons instead of
- // poly-polygons, and don't have to output the gradient
- // twice for XOR
-
- rOutDev.Push( PUSH_CLIPREGION );
- rOutDev.IntersectClipRegion( aPolygonDeviceRectOrig );
- fill( rOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- false );
- rOutDev.Pop();
-
- if( p2ndOutDev )
- {
- p2ndOutDev->Push( PUSH_CLIPREGION );
- p2ndOutDev->IntersectClipRegion( aPolygonDeviceRectOrig );
- fill( *p2ndOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- false );
- p2ndOutDev->Pop();
- }
- }
- else
- {
- // output gradient the hard way: XORing out the polygon
- rOutDev.Push( PUSH_RASTEROP );
- rOutDev.SetRasterOp( ROP_XOR );
- fill( rOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- true );
- rOutDev.SetFillColor( COL_BLACK );
- rOutDev.SetRasterOp( ROP_0 );
- rOutDev.DrawPolyPolygon( rPoly );
- rOutDev.SetRasterOp( ROP_XOR );
- fill( rOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- true );
- rOutDev.Pop();
-
- if( p2ndOutDev )
- {
- p2ndOutDev->Push( PUSH_RASTEROP );
- p2ndOutDev->SetRasterOp( ROP_XOR );
- fill( *p2ndOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- true );
- p2ndOutDev->SetFillColor( COL_BLACK );
- p2ndOutDev->SetRasterOp( ROP_0 );
- p2ndOutDev->DrawPolyPolygon( rPoly );
- p2ndOutDev->SetRasterOp( ROP_XOR );
- fill( *p2ndOutDev,
- aTextureTransform,
- aPolygonDeviceRectOrig,
- nStepCount,
- true );
- p2ndOutDev->Pop();
- }
- }
-
-#if defined(VERBOSE) && defined(DBG_UTIL)
- {
- ::basegfx::B2DRectangle aRect(0.0, 0.0, 1.0, 1.0);
- ::basegfx::B2DRectangle aTextureDeviceRect;
- ::canvas::tools::calcTransformedRectBounds( aTextureDeviceRect,
- aRect,
- aTextureTransform );
- rOutDev.SetLineColor( COL_RED );
- rOutDev.SetFillColor();
- rOutDev.DrawRect( ::vcl::unotools::rectangleFromB2DRectangle( aTextureDeviceRect ) );
-
- rOutDev.SetLineColor( COL_BLUE );
- ::basegfx::B2DPolygon aPoly(
- ::Polygon(
- ::vcl::unotools::rectangleFromB2DRectangle(
- aRect ) ).getB2DPolygon() );
- aPoly.transform( aTextureTransform );
- ::Polygon aPoly2( aPoly );
- rOutDev.DrawPolygon( aPoly2 );
- }
-#endif
-
- return true;
- }
-
- ParametricPolyPolygon::~ParametricPolyPolygon()
- {
- }
-
- ParametricPolyPolygon::ParametricPolyPolygon( const ::basegfx::B2DPolygon& rGradientPoly,
- const ::Color& rColor1,
- const ::Color& rColor2 ) :
- ParametricPolyPolygon_Base( m_aMutex ),
- maGradientPoly( rGradientPoly ),
- mnAspectRatio( 1.0 ),
- maColor1( rColor1 ),
- maColor2( rColor2 ),
- meType( GRADIENT_POLYGON )
- {
- }
-
- ParametricPolyPolygon::ParametricPolyPolygon( const ::basegfx::B2DPolygon& rGradientPoly,
- const ::Color& rColor1,
- const ::Color& rColor2,
- double nAspectRatio ) :
- ParametricPolyPolygon_Base( m_aMutex ),
- maGradientPoly( rGradientPoly ),
- mnAspectRatio( nAspectRatio ),
- maColor1( rColor1 ),
- maColor2( rColor2 ),
- meType( GRADIENT_POLYGON )
- {
- }
-
- ParametricPolyPolygon::ParametricPolyPolygon( GradientType eType,
- const ::Color& rColor1,
- const ::Color& rColor2 ) :
- ParametricPolyPolygon_Base( m_aMutex ),
- maGradientPoly(),
- mnAspectRatio( 1.0 ),
- maColor1( rColor1 ),
- maColor2( rColor2 ),
- meType( eType )
- {
- }
-
-}
diff --git a/scratch/canvas-cairo/cairo_parametricpolypolygon.hxx b/scratch/canvas-cairo/cairo_parametricpolypolygon.hxx
deleted file mode 100644
index 2c6decc44..000000000
--- a/scratch/canvas-cairo/cairo_parametricpolypolygon.hxx
+++ /dev/null
@@ -1,223 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_PARAMETRICPOLYPOLYGON_HXX
-#define _VCLCANVAS_PARAMETRICPOLYPOLYGON_HXX
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XGRAPHICDEVICE_HPP_
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XPARAMETRICPOLYPOLYGON2DFACTORY_HPP_
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
-#endif
-
-#ifndef _CPPUHELPER_COMPBASE2_HXX_
-#include <cppuhelper/compbase2.hxx>
-#endif
-#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
-#include <comphelper/broadcasthelper.hxx>
-#endif
-
-#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
-#include <basegfx/polygon/b2dpolygon.hxx>
-#endif
-#ifndef _SV_GEN_HXX
-#include <tools/gen.hxx>
-#endif
-#ifndef _TOOLS_COLOR_HXX
-#include <tools/color.hxx>
-#endif
-
-class OutputDevice;
-class PolyPolygon;
-
-namespace basegfx
-{
- class B2DPolygon;
- class B2DHomMatrix;
-}
-
-#define PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME "CairoCanvas::ParametricPolyPolygon"
-
-/* Definition of ParametricPolyPolygon class */
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XParametricPolyPolygon2D,
- ::com::sun::star::lang::XServiceInfo > ParametricPolyPolygon_Base;
-
- class ParametricPolyPolygon : public ::comphelper::OBaseMutex, public ParametricPolyPolygon_Base
- {
- public:
-
- static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Sequence< double >& leftColor,
- const ::com::sun::star::uno::Sequence< double >& rightColor,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& xDevice );
- static ParametricPolyPolygon* createAxialHorizontalGradient( const ::com::sun::star::uno::Sequence< double >& middleColor,
- const ::com::sun::star::uno::Sequence< double >& endColor,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& xDevice );
- static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Sequence< double >& centerColor,
- const ::com::sun::star::uno::Sequence< double >& endColor,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& xDevice );
- static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Sequence< double >& centerColor,
- const ::com::sun::star::uno::Sequence< double >& endColor,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& xDevice );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XParametricPolyPolygon2D
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL getOutline( double t ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getColor( double t ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getPointColor( const ::com::sun::star::geometry::RealPoint2D& point ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
-
- bool fill( OutputDevice& rOutDev,
- OutputDevice* p2ndOutDev,
- const PolyPolygon& rPoly,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState,
- const ::com::sun::star::rendering::Texture& texture,
- int nTransparency ) const;
-
- protected:
- ~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- ParametricPolyPolygon(const ParametricPolyPolygon&);
- ParametricPolyPolygon& operator=( const ParametricPolyPolygon& );
-
- enum GradientType
- {
- GRADIENT_LINEAR,
- GRADIENT_AXIAL,
- GRADIENT_POLYGON
- };
-
- /// Private, because objects can only be created from the static factories
- ParametricPolyPolygon( const ::basegfx::B2DPolygon& rGradientPoly,
- const ::Color& rColor1,
- const ::Color& rColor2 );
- ParametricPolyPolygon( const ::basegfx::B2DPolygon& rGradientPoly,
- const ::Color& rColor1,
- const ::Color& rColor2,
- double nAspectRatio );
- ParametricPolyPolygon( GradientType eType,
- const ::Color& rColor1,
- const ::Color& rColor2 );
-
- void fillLinearGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const;
-
- void fillAxialGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const;
-
- void fillPolygonalGradient( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const;
-
- void fill( OutputDevice& rOutDev,
- const ::basegfx::B2DHomMatrix& rTextureTransform,
- const ::Rectangle& rBounds,
- int nStepCount,
- bool bFillNonOverlapping ) const;
-
-
- /// Polygon gradient shape
- const ::basegfx::B2DPolygon maGradientPoly;
-
- /// Aspect ratio of gradient, affects scaling of innermost gradient polygon
- const double mnAspectRatio;
-
- /// First gradient color
- const ::Color maColor1;
-
- /// Second gradient color
- const ::Color maColor2;
-
- /// Type of gradient to render (as e.g. linear grads are not represented by maGradientPoly)
- const GradientType meType;
- };
-}
-
-#endif /* _VCLCANVAS_PARAMETRICPOLYPOLYGON_HXX */
diff --git a/scratch/canvas-cairo/cairo_redrawmanager.cxx b/scratch/canvas-cairo/cairo_redrawmanager.cxx
deleted file mode 100644
index 61bad9ad6..000000000
--- a/scratch/canvas-cairo/cairo_redrawmanager.cxx
+++ /dev/null
@@ -1,553 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef _RTL_STRING_HXX_
-#include <rtl/string.hxx>
-#endif
-#ifndef _RTL_TEXTENC_H
-#include <rtl/textenc.h>
-#endif
-
-#ifndef INCLUDED_RTL_MATH_HXX
-#include <rtl/math.hxx>
-#endif
-
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#ifndef BOOST_BIND_HPP_INCLUDED
-#include <boost/bind.hpp>
-#endif
-
-#include <algorithm>
-#include <functional>
-#include <numeric>
-
-#include "cairo_redrawmanager.hxx"
-
-
-#define FPS_BOUNDS Rectangle(0,0,130,90)
-#define INFO_COLOR COL_RED
-
-using namespace ::cairo;
-
-namespace vclcanvas
-{
-
- class SpritePainter
- {
- public:
- SpritePainter( Cairo* pCairo )
- {
- mpCairo = pCairo;
- }
-
- void operator()( const ::vclcanvas::Sprite::ImplRef& rSprite )
- {
- rSprite->redraw( mpCairo );
- }
-
- private:
- Cairo* mpCairo;
- };
-
- inline double accumulatePixel( double nPrevVal, const ::vclcanvas::Sprite::ImplRef& rSprite )
- {
- const ::basegfx::B2DSize& rSize( rSprite->getSpriteSize() );
-
- return nPrevVal + rSize.getX() * rSize.getY();
- }
-
- // Initial size of change records vector
- enum{ CHANGE_RECORDS_INITIAL_SIZE=4 };
-
- RedrawManager::RedrawManager( OutputDevice& rOutDev,
- const BackBufferSharedPtr& rBackBuffer,
- Surface* pSurface) :
- maSprites(),
- maChangeRecords(),
- mrOutDev( rOutDev ),
- mpBackBuffer( rBackBuffer ),
- maLastUpdate(),
- mbBackgroundDirty( true )
- {
- printf("redraw manager constructor\n");
- ENSURE_AND_THROW( mpBackBuffer.get(),
- "RedrawManager::RedrawManager(): Invalid backbuffer" );
- maChangeRecords.reserve( CHANGE_RECORDS_INITIAL_SIZE );
-
- Size aSize = mpBackBuffer->getSize();
- mpSurface = cairo_surface_create_similar( mpBackBuffer->getSurface(), CAIRO_FORMAT_RGB24, aSize.Width(), aSize.Height() );
- mpCairo = cairo_create( mpSurface );
- mpWinSurface = pSurface;
- cairo_surface_reference( mpWinSurface );
- }
-
- RedrawManager::~RedrawManager()
- {
- printf("redraw manager destructor\n");
- cairo_destroy( mpCairo );
- cairo_surface_destroy( mpSurface );
- cairo_surface_destroy( mpWinSurface );
- }
-
- void RedrawManager::updateScreen( bool bUpdateAll )
- {
- tools::OutDevStateKeeper aStateKeeper( mrOutDev );
-
- // TODO(F3): The SpriteCanvas currently doesn't act on window
- // resizes. Somehow, the VCL window must broadcast resizes
- // _very early_ (before the application repaints the content)
- // to the canvas, such that the backbuffer can be adapted.
-// const Size aOutDevSize( mpBackBuffer->getOutDev().GetOutputSizePixel() );
- const Point aEmptyPoint(0,0);
-
- // TODO(P1): Might be worthwile to track areas of background
- // changes, too.
- if( !bUpdateAll && !mbBackgroundDirty )
- {
- // background has not changed, so we're free to optimize
- // repaint to areas where a sprite has changed
-
- // TODO(F2): Unchanged sprites, which happen to be in the
- // area-to-be-updated are currently not repainted.
-
- // calculate rectangular areas of mutually intersecting
- // sprite updates. We must handle them together, to
- // achieve proper compositing effects
- SpriteConnectedRanges aUpdateAreas;
-
-#if defined(VERBOSE) && defined(DBG_UTIL)
- // also repaint background below frame counter (fake that
- // as a sprite vanishing in this area)
- aUpdateAreas.addRange( ::basegfx::B2DRectangle( 0.0, 0.0,
- FPS_BOUNDS.Right(),
- FPS_BOUNDS.Bottom() ),
- Sprite::ImplRef() );
-#endif
-
- // extract all referenced sprites from the maChangeRecords
- // (copy sprites, make the list unique, regarding the
- // sprite pointer). This assumes that, until this scope
- // ends, nobody changes the maChangeRecords vector!
- typedef ::std::vector< Sprite::ImplRef > UpdateSprites;
- UpdateSprites aUpdateSprites;
- ::std::transform( maChangeRecords.begin(),
- maChangeRecords.end(),
- ::std::back_insert_iterator< UpdateSprites >(aUpdateSprites),
- ::std::mem_fun_ref( &SpriteChangeRecord::getSprite ) );
- ::std::sort( aUpdateSprites.begin(),
- aUpdateSprites.end() );
-
- UpdateSprites::iterator aBegin( aUpdateSprites.begin() );
- UpdateSprites::iterator aEnd ( aUpdateSprites.end() );
- aEnd = ::std::unique( aBegin, aEnd );
-
- // for each unique sprite, check the change event vector,
- // calculate the update operation from that, and add the
- // result to the aUpdateArea.
- ::std::for_each( aBegin, aEnd,
- ::canvas::internal::SpriteUpdater< Sprite::ImplRef,
- ChangeRecords,
- SpriteConnectedRanges >(aUpdateAreas,
- maChangeRecords) );
-
- // prepare and flush all aggregated components to screen
- aUpdateAreas.forEachAggregate( ::boost::bind( &RedrawManager::updateArea,
- this,
- _1 ) );
- }
- else
- {
- // background has changed, so we currently have no choice
- // but repaint everything (or caller requested that)
- bUpdateAll = true;
- }
-
- // check again for fullscreen update, maybe update area
- // calculation above yielded decision to perform a fullscreen
- // update, anyway.
- if( bUpdateAll )
- {
- printf ("redraw manager: update all\n");
-
- Surface* pBackingStoreSurface;
-
- if( maSprites.size() > 0 ) {
- cairo_save( mpCairo );
- cairo_set_operator( mpCairo, CAIRO_OPERATOR_SOURCE );
- cairo_set_source_surface( mpCairo, mpBackBuffer->getSurface(), 0, 0 );
- cairo_paint( mpCairo );
- cairo_restore( mpCairo );
-
- // repaint all active sprites
- ::std::for_each( maSprites.begin(),
- maSprites.end(),
- SpritePainter( mpCairo ) );
-
- pBackingStoreSurface = mpSurface;
- } else
- pBackingStoreSurface = mpBackBuffer->getSurface();
-
- // flush to screen
- Cairo* pCairo = cairo_create( mpWinSurface );
- cairo_set_operator( pCairo, CAIRO_OPERATOR_SOURCE );
- cairo_set_source_surface( pCairo, pBackingStoreSurface, 0, 0 );
- cairo_paint( pCairo );
- cairo_destroy( pCairo );
- }
-
- // change record vector must be cleared, for the next turn of
- // rendering and sprite changing
- maChangeRecords.clear();
-
- mbBackgroundDirty = false;
-
-#if defined(VERBOSE) && defined(DBG_UTIL)
- //renderFrameCounter();
- //renderSpriteCount();
- //renderMemUsage();
-#endif
- }
-
- void RedrawManager::renderInfoText( const ::rtl::OUString& rStr,
- const Point& rPos )
- {
- Font aVCLFont;
- aVCLFont.SetHeight( 20 );
- aVCLFont.SetColor( Color( INFO_COLOR ) );
-
- mrOutDev.SetTextColor( Color( INFO_COLOR ) );
- mrOutDev.SetFont( aVCLFont );
-
- mrOutDev.DrawText( rPos, rStr );
- }
-
- void RedrawManager::renderFrameCounter()
- {
- const double denominator( maLastUpdate.getElapsedTime() );
- maLastUpdate.reset();
-
- ::rtl::OUString text( ::rtl::math::doubleToUString( denominator == 0.0 ? 100.0 : 1.0/denominator,
- rtl_math_StringFormat_F,
- 2,'.',NULL,' ') );
-
- // pad with leading space
- while( text.getLength() < 6 )
- text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text;
-
- text += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" fps"));
-
- renderInfoText( text,
- Point(0, 0) );
- }
-
- void RedrawManager::renderSpriteCount()
- {
- ::rtl::OUString text(
- ::rtl::OUString::valueOf(
- // disambiguate overload...
- static_cast<sal_Int64>(maSprites.size()) ) );
-
- // pad with leading space
- while( text.getLength() < 3 )
- text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text;
-
- text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Sprites: ")) + text;
-
- renderInfoText( text,
- Point(0, 30) );
- }
-
- void RedrawManager::renderMemUsage()
- {
- // rodo TODO
-// const double nPixel( ::std::accumulate( maSprites.begin(),
-// maSprites.end(),
-// 0.0,
-// ::std::ptr_fun( &accumulatePixel ) ) );
-
-// static const int NUM_VIRDEV(2);
-// static const int BYTES_PER_PIXEL(3);
-
-// const Size& rVDevSize( maVDev->GetOutputSizePixel() );
-// // const Size& rBackBufferSize( mpBackBuffer->getOutDev().GetOutputSizePixel() );
-
-// const double nMemUsage( nPixel * NUM_VIRDEV * BYTES_PER_PIXEL +
-// rVDevSize.Width()*rVDevSize.Height() * BYTES_PER_PIXEL +
-// rBackBufferSize.Width()*rBackBufferSize.Height() * BYTES_PER_PIXEL );
-
-// ::rtl::OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0,
-// rtl_math_StringFormat_F,
-// 2,'.',NULL,' ') );
-
-// // pad with leading space
-// while( text.getLength() < 4 )
-// text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" ")) + text;
-
-// text = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("Mem: ")) +
-// text +
-// ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("MB"));
-
-// renderInfoText( text,
-// Point(0, 60) );
- }
-
- void RedrawManager::backgroundDirty()
- {
- mbBackgroundDirty = true;
- }
-
- void RedrawManager::showSprite( const Sprite::ImplRef& sprite )
- {
- maSprites.push_back( sprite );
- }
-
- void RedrawManager::hideSprite( const Sprite::ImplRef& sprite )
- {
- maSprites.remove( sprite );
- }
-
- void RedrawManager::moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize )
- {
- // TODO(Q1): Use AW's converters once resynced
- maChangeRecords.push_back( SpriteChangeRecord( sprite,
- ::basegfx::B2DPoint( rOldPos.X(),
- rOldPos.Y() ),
- ::basegfx::B2DPoint( rNewPos.X(),
- rNewPos.Y() ),
- ::basegfx::B2DSize( rSpriteSize.Width(),
- rSpriteSize.Height() ) ) );
- }
-
- void RedrawManager::updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea )
- {
- // TODO(Q1): Use AW's converters once resynced
- maChangeRecords.push_back( SpriteChangeRecord( sprite,
- ::basegfx::B2DPoint( rPos.X(),
- rPos.Y() ),
- ::basegfx::B2DRectangle( rUpdateArea.Left(),
- rUpdateArea.Top(),
- rUpdateArea.Right(),
- rUpdateArea.Bottom() ) ) );
- }
-
- namespace
- {
- bool isAreaUpdateNotOpaque( const Rectangle& rUpdateArea,
- const RedrawManager::SpriteConnectedRanges::ComponentType& rComponent )
- {
- const Sprite::ImplRef& pAffectedSprite( rComponent.second );
-
- if( !pAffectedSprite.is() )
- return true; // no sprite, no opaque update!
-
- return !pAffectedSprite->isAreaUpdateOpaque( rUpdateArea );
- }
-
- void spriteRedrawStub( const Point& rOffset,
- Cairo* pCairo,
- const RedrawManager::SpriteConnectedRanges::ComponentType& rComponent )
- {
- const Sprite::ImplRef& pAffectedSprite( rComponent.second );
-
- printf ("spriteRedrawStub\n");
-
- if( !pAffectedSprite.is() )
- return; // no sprite, no update!
-
- // calc relative sprite position in rUpdateArea (which need
- // not be the whole screen!)
- const ::basegfx::B2DPoint aSpriteScreenPos( pAffectedSprite->getSpritePos() );
-
- // paint affected sprite
- pAffectedSprite->redraw( pCairo, aSpriteScreenPos );
- }
- }
-
-
- void RedrawManager::updateArea( const SpriteConnectedRanges::ConnectedComponents& rComponents )
- {
- const ::basegfx::B2DRectangle& rRequestedArea( rComponents.maTotalBounds );
-
- // limit size of update VDev to target outdev's size
- const Size& rTargetSizePixel( mrOutDev.GetOutputSizePixel() );
-
- // round output position towards zero. Don't want to truncate
- // a fraction of a sprite pixel... Clip position at origin,
- // otherwise, truncation of size below might leave visible
- // areas uncovered by VDev.
- const Point aOutputPosition(
- ::std::max( 0L,
- static_cast< long >(rRequestedArea.getMinX()) ),
- ::std::max( 0L,
- static_cast< long >(rRequestedArea.getMinY()) ) );
- // round output size towards +infty. Don't want to truncate a
- // fraction of a sprite pixel... Limit size of VDev to output
- // device's area.
- const Size aOutputSize(
- ::std::min( rTargetSizePixel.Width(),
- static_cast< long >(
- ceil( rRequestedArea.getMaxX() - aOutputPosition.X()) ) ),
- ::std::min( rTargetSizePixel.Height(),
- static_cast< long >(
- ceil( rRequestedArea.getMaxY() - aOutputPosition.Y()) ) ) );
-
- const Rectangle aUpdateArea( aOutputPosition.X(),
- aOutputPosition.Y(),
- aOutputPosition.X() + aOutputSize.Width(),
- aOutputPosition.Y() + aOutputSize.Height() );
-
- const Point aEmptyPoint(0,0);
-
-// if( rComponents.maComponentList.size() < 3 &&
-// ::std::find_if( rComponents.maComponentList.begin(),
-// rComponents.maComponentList.end(),
-// ::boost::bind( &isAreaUpdateNotOpaque,
-// ::boost::cref(aUpdateArea),
-// _1 ) ) == rComponents.maComponentList.end() )
-// {
-// // no more than two sprites, and all opaque - can render
-// // directly to the frontbuffer
-
-// // clip output to actual update region (otherwise a)
-// // wouldn't save much render time, and b) might clutter
-// // sprites outside this area)
-// cairo_save( mpCairo );
-// cairo_rectangle( mpCairo, aOutputPosition.X(), aOutputPosition.Y(), aOutputSize.Width(), aOutputSize.Height() );
-// cairo_clip( mpCairo );
-
-// Cairo* pCairo = cairo_create( mpWinSurface );
-
-// // paint all affected sprites to update area
-// ::std::for_each( rComponents.maComponentList.begin(),
-// rComponents.maComponentList.end(),
-// ::boost::bind( &spriteRedrawStub,
-// ::boost::cref(aEmptyPoint),
-// mpCairo,
-// _1 ) );
-
-// cairo_restore( mpCairo );
-// }
-// else
- {
- cairo_save( mpCairo );
-
- // paint background
-// {
- printf("sprite size: %d x %d\n", aOutputSize.Width(), aOutputSize.Height() );
-// Cairo* pCairo = cairo_create( mpBackBuffer->getSurface() );
-// cairo_set_source_rgb( pCairo, 1, 1, 0 );
-// cairo_rectangle( pCairo, 0, 0, mpBackBuffer->getSize().Width(), mpBackBuffer->getSize().Height() );
-// cairo_fill( pCairo );
-// }
-
- cairo_save( mpCairo );
- cairo_rectangle( mpCairo, aOutputPosition.X(), aOutputPosition.Y(), aOutputSize.Width(), aOutputSize.Height() );
- cairo_clip( mpCairo );
- cairo_set_operator( mpCairo, CAIRO_OPERATOR_SOURCE );
- cairo_set_source_surface( mpCairo, mpBackBuffer->getSurface(), 0, 0 );
- cairo_paint( mpCairo );
- cairo_restore( mpCairo );
-
- // paint all affected sprites to update area
- ::std::for_each( rComponents.maComponentList.begin(),
- rComponents.maComponentList.end(),
- ::boost::bind( &spriteRedrawStub,
- ::boost::cref(aUpdateArea.TopLeft()),
- mpCairo,
- _1 ) );
-
-// cairo_reset_clip( mpCairo );
-// cairo_set_line_width( mpCairo, 6 );
-// cairo_set_source_rgb( mpCairo, 1, 1, 0 );
-// cairo_rectangle( mpCairo, aOutputPosition.X(), aOutputPosition.Y(), aOutputSize.Width(), aOutputSize.Height() );
-// cairo_stroke( mpCairo );
-
- // flush to screen
- Cairo* pCairo = cairo_create( mpWinSurface );
-
- cairo_save( mpCairo );
- cairo_rectangle( pCairo, aOutputPosition.X(), aOutputPosition.Y(), aOutputSize.Width(), aOutputSize.Height() );
- cairo_clip( pCairo );
- cairo_set_operator( pCairo, CAIRO_OPERATOR_SOURCE );
- cairo_set_source_surface( pCairo, mpSurface, 0, 0 );
- cairo_paint( pCairo );
- cairo_restore( mpCairo );
-
- cairo_destroy( pCairo );
-
- cairo_restore( mpCairo );
- }
- }
-}
diff --git a/scratch/canvas-cairo/cairo_redrawmanager.hxx b/scratch/canvas-cairo/cairo_redrawmanager.hxx
deleted file mode 100644
index 6e2c6d872..000000000
--- a/scratch/canvas-cairo/cairo_redrawmanager.hxx
+++ /dev/null
@@ -1,201 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_REDRAWMANAGER_HXX
-#define _VCLCANVAS_REDRAWMANAGER_HXX
-
-#include <list>
-#include <vector>
-
-#ifndef _COM_SUN_STAR_AWT_POINT_HPP_
-#include <com/sun/star/awt/Point.hpp>
-#endif
-#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_
-#include <com/sun/star/awt/Size.hpp>
-#endif
-
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/point/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_VECTOR_B2DSIZE_HXX
-#include <basegfx/vector/b2dsize.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DRECTANGLE_HXX
-#include <basegfx/range/b2drectangle.hxx>
-#endif
-#ifndef _BGFX_RANGE_B2DCONNECTEDRANGES_HXX
-#include <basegfx/range/b2dconnectedranges.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-#include <canvas/elapsedtime.hxx>
-#include <canvas/redrawmanagement.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_sprite.hxx"
-#include "cairo_backbuffer.hxx"
-#include "cairo_impltools.hxx"
-
-
-/* Definition of RedrawManager class */
-
-namespace vclcanvas
-{
-
- /** This class manages smooth SpriteCanvas updates
-
- @attention This class does not perform Solar mutex locking,
- this must be handled by the client code.
- */
- class RedrawManager
- {
- public:
- /** Constructed with references to back buffer and output
- device, the RedrawManager keeps track of sprite movements,
- and repaints only those areas on updateScreen, that
- actually needs an update.
-
- @param rOutDev
- Reference to output device, typically a window on
- screen. Does not take ownership.
-
- @param rBackBuffer
- Reference to a back buffer. Back buffer content must be
- provided from elsewhere, everytime back buffer content
- changes, backgroundDirty() must be called.
- */
- RedrawManager( OutputDevice& rOutDev,
- const BackBufferSharedPtr& rBackBuffer,
- ::cairo::Surface* pSurface);
- ~RedrawManager();
-
- void updateScreen( bool bUpdateAll );
- void backgroundDirty();
-
- // SpriteSurface interface, is delegated to e.g. from SpriteCanvas
- void showSprite( const Sprite::ImplRef& sprite );
- void hideSprite( const Sprite::ImplRef& sprite );
- void moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize );
- void updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea );
-
- typedef ::basegfx::B2DConnectedRanges< Sprite::ImplRef > SpriteConnectedRanges;
-
- private:
- typedef ::canvas::internal::SpriteChangeRecord< Sprite::ImplRef > SpriteChangeRecord;
- typedef ::std::vector< SpriteChangeRecord > ChangeRecords;
-
- // default: disabled copy/assignment
- RedrawManager(const RedrawManager&);
- RedrawManager& operator=( const RedrawManager& );
-
- /// Update given area of the screen
- void updateArea( const SpriteConnectedRanges::ConnectedComponents& rComponents );
-
- /// Update sprite in given area of the outdev
- void updateSpriteForArea( const Rectangle& rUpdateArea,
- OutputDevice& rOutputDevice,
- const SpriteConnectedRanges::ComponentType& rComponent );
-
- void renderInfoText( const ::rtl::OUString& rStr,
- const Point& rPos );
- void renderFrameCounter();
- void renderSpriteCount();
- void renderMemUsage();
-
- ::std::list< Sprite::ImplRef > maSprites; // list of active
- // sprite
- // objects. this
- // list is only
- // used for full
- // repaints,
- // otherwise, we
- // rely on the
- // active sprites
- // itself to notify
- // us.
- ChangeRecords maChangeRecords; // vector
- // of
- // sprites
- // changes
- // since
- // last
- // updateScreen()
- // call
- OutputDevice& mrOutDev;
- BackBufferSharedPtr mpBackBuffer;
- ::canvas::tools::ElapsedTime maLastUpdate; // for the frame counter
- bool mbBackgroundDirty;
- ::cairo::Surface* mpWinSurface;
- ::cairo::Surface* mpSurface;
- ::cairo::Cairo* mpCairo;
- };
-}
-
-#endif /* _VCLCANVAS_REDRAWMANAGER_HXX */
diff --git a/scratch/canvas-cairo/cairo_repainttarget.hxx b/scratch/canvas-cairo/cairo_repainttarget.hxx
deleted file mode 100644
index 99e2e7488..000000000
--- a/scratch/canvas-cairo/cairo_repainttarget.hxx
+++ /dev/null
@@ -1,97 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_REPAINTTARGET_HXX
-#define _VCLCANVAS_REPAINTTARGET_HXX
-
-#ifndef _RTL_REF_HXX_
-#include <rtl/ref.hxx>
-#endif
-
-#include "cairo_cachedbitmap.hxx"
-
-class Point;
-class Size;
-class GraphicAttr;
-
-namespace vclcanvas
-{
- /* Definition of RepaintTarget interface */
-
- /** Target interface for XCachedPrimitive implementations
-
- This interface must be implemented on all canvas
- implementations that hand out XCachedPrimitives
- */
- class RepaintTarget
- {
- public:
- virtual ~RepaintTarget() {}
-
- // call this when a bitmap is repainted
- virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const = 0;
- };
-}
-
-#endif /* _VCLCANVAS_REPAINTTARGET_HXX */
diff --git a/scratch/canvas-cairo/cairo_sprite.hxx b/scratch/canvas-cairo/cairo_sprite.hxx
deleted file mode 100644
index 3db8ef7f4..000000000
--- a/scratch/canvas-cairo/cairo_sprite.hxx
+++ /dev/null
@@ -1,131 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_SPRITE_HXX
-#define _VCLCANVAS_SPRITE_HXX
-
-#ifndef _RTL_REF_HXX_
-#include <rtl/ref.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP_
-#include <com/sun/star/rendering/XCanvas.hpp>
-#endif
-
-#ifndef _BGFX_POINT_B2DPOINT_HXX
-#include <basegfx/vector/b2dpoint.hxx>
-#endif
-#ifndef _BGFX_VECTOR_B2DSIZE_HXX
-#include <basegfx/vector/b2dsize.hxx>
-#endif
-
-#include "cairo_cairo.hxx"
-
-class OutputDevice;
-
-namespace vclcanvas
-{
- /* Definition of Sprite class */
-
- /** Helper interface to connect SpriteCanvas with various
- sprite implementations.
- */
-
- class Sprite : public ::com::sun::star::uno::XInterface
- {
- public:
- typedef ::rtl::Reference< Sprite > ImplRef;
-
- virtual ~Sprite() {}
-
- /** Repaint whole sprite on given target surface
- */
- virtual void redraw( ::cairo::Cairo* pCairo ) const = 0;
-
- /** Repaint sprite.
-
- @param rTargetSurface
- Target surface to output sprite content
-
- @param rOutputPos
- Position where to render the sprite (overrides the
- sprite's output position)
- */
- virtual void redraw( ::cairo::Cairo* pCairo,
- const ::basegfx::B2DPoint& rOutputPos ) const = 0;
-
- /** Query whether sprite update will fully cover the given area.
-
- Use this method to determine whether any background
- content (regardless of static or sprite) needs an update
- before rendering this sprite.
-
- @return true, if sprite redraw will fully overwrite given
- area.
- */
- virtual bool isAreaUpdateOpaque( const Rectangle& rUpdateArea ) const = 0;
-
- virtual ::basegfx::B2DPoint getSpritePos() const = 0;
- virtual ::basegfx::B2DSize getSpriteSize() const = 0;
- };
-}
-
-#endif /* _VCLCANVAS_SPRITE_HXX */
diff --git a/scratch/canvas-cairo/cairo_spritecanvas.cxx b/scratch/canvas-cairo/cairo_spritecanvas.cxx
deleted file mode 100644
index 12b33a151..000000000
--- a/scratch/canvas-cairo/cairo_spritecanvas.cxx
+++ /dev/null
@@ -1,559 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
-#include <com/sun/star/lang/XInitialization.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
-#include <com/sun/star/lang/XServiceName.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XCOMPONENTCONTEXT_HPP_
-#include <com/sun/star/uno/XComponentContext.hpp>
-#endif
-
-#ifndef _CPPUHELPER_FACTORY_HXX_
-#include <cppuhelper/factory.hxx>
-#endif
-#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
-#include <cppuhelper/implementationentry.hxx>
-#endif
-#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
-#include <cppuhelper/implementationentry.hxx>
-#endif
-
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-#ifndef _SV_OUTDEV_HXX
-#include <vcl/outdev.hxx>
-#endif
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-#ifndef _SV_SYSCHILD_HXX
-#include <vcl/syschild.hxx>
-#endif
-#ifndef _SV_SYSDATA_HXX
-#include <vcl/sysdata.hxx>
-#endif
-
-#ifndef _SV_BITMAPEX_HXX
-#include <vcl/bitmapex.hxx>
-#endif
-
-#include <algorithm>
-
-#include <canvas/verbosetrace.hxx>
-#include <canvas/canvastools.hxx>
-
-#include "cairo_spritecanvas.hxx"
-#include "cairo_canvascustomsprite.hxx"
-#include "cairo_windowgraphicdevice.hxx"
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-#define IMPLEMENTATION_NAME "CairoCanvas::SpriteCanvas"
-#define SERVICE_NAME "com.sun.star.rendering.CairoCanvas"
-
-namespace
-{
- static ::rtl::OUString SAL_CALL getImplementationName_SpriteCanvas()
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
- }
-
- static uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_SpriteCanvas()
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
-}
-
-namespace vclcanvas
-{
- SpriteCanvas::SpriteCanvas( const uno::Reference< uno::XComponentContext >& rxContext ) :
- maBounds(),
- mxComponentContext( rxContext ),
- mxDevice(),
- mpBackBuffer(),
- mpRedrawManager(),
- mbIsVisible( false )
- {
- }
-
- SpriteCanvas::~SpriteCanvas()
- {
- }
-
- void SAL_CALL SpriteCanvas::disposing()
- {
- tools::LocalGuard aGuard;
-
- printf ("disposing sprite canvas\n");
-
- dispose();
-
- // forward to parent
- SpriteCanvas_Base::disposing();
- }
-
- uno::Reference< rendering::XAnimatedSprite > SAL_CALL SpriteCanvas::createSpriteFromAnimation( const uno::Reference< rendering::XAnimation >& animation ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return uno::Reference< rendering::XAnimatedSprite >(NULL);
- }
-
- uno::Reference< rendering::XAnimatedSprite > SAL_CALL SpriteCanvas::createSpriteFromBitmaps( const uno::Sequence< uno::Reference< rendering::XBitmap > >& animationBitmaps,
- sal_Int8 interpolationMode ) throw (lang::IllegalArgumentException, rendering::VolatileContentDestroyedException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return uno::Reference< rendering::XAnimatedSprite >(NULL);
- }
-
- uno::Reference< rendering::XCustomSprite > SAL_CALL SpriteCanvas::createCustomSprite( const geometry::RealSize2D& spriteSize ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( !mxDevice.is() )
- return uno::Reference< rendering::XCustomSprite >(); // we're disposed
-
- return uno::Reference< rendering::XCustomSprite >(
- new CanvasCustomSprite( spriteSize,
- mxDevice,
- mpSysData,
- ImplRef(this)) );
- }
-
- uno::Reference< rendering::XSprite > SAL_CALL SpriteCanvas::createClonedSprite( const uno::Reference< rendering::XSprite >& original ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return uno::Reference< rendering::XSprite >(NULL);
- }
-
- sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- printf ("update screen called begin\n");
-
- if( !mpRedrawManager.get() )
- return sal_False; // disposed
-
- // hidden windows need not paint anything, thus prevent
- // screen updates, then
- if( !mbIsVisible )
- return sal_False;
-
- // pass background dirty state to redrawmanager
- if( mbSurfaceDirty )
- {
- mpRedrawManager->backgroundDirty();
- mbSurfaceDirty = false;
- }
-
- mpRedrawManager->updateScreen( bUpdateAll );
- mxDevice->flush();
-
- // commit to screen
- // rodo maCanvasHelper.flush();
-
-// #if defined(VERBOSE) && defined(DBG_UTIL)
-// static ::canvas::tools::ElapsedTime aElapsedTime;
-
-// // log time immediately after surface flip
-// OSL_TRACE( "SpriteCanvas::updateScreen(): flip done at %f",
-// aElapsedTime.getElapsedTime() );
-// #endif
-
- return sal_True;
- }
-
- void SAL_CALL SpriteCanvas::initialize( const uno::Sequence< uno::Any >& aArguments ) throw( uno::Exception,
- uno::RuntimeException)
- {
- VERBOSE_TRACE( "SpriteCanvas::initialize called" );
-
- CHECK_AND_THROW( aArguments.getLength() >= 1,
- "SpriteCanvas::initialize: wrong number of arguments" );
-
- // We expect a single Any here, containing a pointer to a valid
- // VCL window, on which to output
- if( aArguments.getLength() >= 1 &&
- aArguments[0].getValueTypeClass() == uno::TypeClass_HYPER )
- {
- // TODO(Q2): This now works for Solaris, but still warns for gcc
- ::Window* pOutputWindow = (::Window*) *reinterpret_cast<const sal_Int64*>(aArguments[0].getValue());
-
- CHECK_AND_THROW( pOutputWindow != NULL,
- "SpriteCanvas::initialize: invalid Window pointer" );
-
- // 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 )
- mpSysData = pSysChild->GetSystemData();
- else
- mpSysData = pOutputWindow->GetSystemData();
-
- // setup graphic device
- mxDevice = WindowGraphicDevice::ImplRef( new WindowGraphicDevice( *pOutputWindow, mpSysData ) );
-
- // setup helper
- maCanvasHelper.setGraphicDevice( mxDevice );
-
- // setup back buffer
- mpBackBuffer.reset( new BackBuffer( mxDevice, ::cairo::CAIRO_FORMAT_RGB24 ) );
- mpBackBuffer->setSize( pOutputWindow->GetOutputSizePixel() );
-
- // always render into back buffer, don't preserve state
- // (it's our private VDev, after all)
- maCanvasHelper.setCairo( mpBackBuffer->getCairo() );
-
- // setup RedrawManager
- mpRedrawManager.reset( new RedrawManager( *pOutputWindow,
- mpBackBuffer,
- mxDevice->getSurface() ) );
- }
- }
-
- void SAL_CALL SpriteCanvas::dispose( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- printf("sprite canvas dispose\n");
-
- maCanvasHelper.disposing();
-
- mxComponentContext.clear();
- if( mxDevice.is() )
- mxDevice->dispose();
- mxDevice.reset();
- mpBackBuffer.reset(),
- mpRedrawManager.reset();
- }
-
- void SAL_CALL SpriteCanvas::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::setPosSize( sal_Int32 nX,
- sal_Int32 nY,
- sal_Int32 nWidth,
- sal_Int32 nHeight,
- sal_Int16 nFlags ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- if( maBounds.X != nX ||
- maBounds.Y != nY ||
- maBounds.Width != nWidth ||
- maBounds.Height != nHeight )
- {
- maBounds.X = nX;
- maBounds.Y = nY;
- maBounds.Width = nWidth;
- maBounds.Height = nHeight;
-
- if( mpBackBuffer.get() )
- mpBackBuffer->setSize( Size( nWidth,
- nHeight ) );
- }
- }
-
- awt::Rectangle SAL_CALL SpriteCanvas::getPosSize( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return maBounds;
- }
-
- void SAL_CALL SpriteCanvas::setVisible( ::sal_Bool bVisible ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- mbIsVisible = bVisible;
- }
-
- void SAL_CALL SpriteCanvas::setEnable( ::sal_Bool Enable ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::setFocus( ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- void SAL_CALL SpriteCanvas::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException)
- {
- // Ignored
- }
-
- ::rtl::OUString SAL_CALL SpriteCanvas::getImplementationName() throw( uno::RuntimeException )
- {
- return getImplementationName_SpriteCanvas();
- }
-
- sal_Bool SAL_CALL SpriteCanvas::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL SpriteCanvas::getSupportedServiceNames() throw( uno::RuntimeException )
- {
- return getSupportedServiceNames_SpriteCanvas();
- }
-
- ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
- }
-
- uno::Reference< uno::XInterface > SAL_CALL SpriteCanvas::createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
- {
- return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new SpriteCanvas( xContext )) );
- }
-
- // SpriteSurface
- void SpriteCanvas::showSprite( const Sprite::ImplRef& sprite )
- {
- tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->showSprite( sprite );
- }
-
- void SpriteCanvas::hideSprite( const Sprite::ImplRef& sprite )
- {
- tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->hideSprite( sprite );
- }
-
- void SpriteCanvas::moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize )
- {
- tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->moveSprite( sprite, rOldPos, rNewPos, rSpriteSize );
- }
-
- void SpriteCanvas::updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea )
- {
- tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->updateSprite( sprite, rPos, rUpdateArea );
- }
-
- bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const
- {
- tools::LocalGuard aGuard;
-
- mbSurfaceDirty = true;
-
- return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
- }
-
-}
-
-namespace
-{
- /* shared lib exports implemented with helpers */
- static struct ::cppu::ImplementationEntry s_component_entries [] =
- {
- {
- vclcanvas::SpriteCanvas::createInstance, getImplementationName_SpriteCanvas,
- getSupportedServiceNames_SpriteCanvas, ::cppu::createSingleComponentFactory,
- 0, 0
- },
- { 0, 0, 0, 0, 0, 0 }
- };
-}
-
-
-/* Exported UNO methods for registration and object creation.
- ==========================================================
- */
-extern "C"
-{
- void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName,
- uno_Environment** ppEnv )
- {
- *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
- }
-
- sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory* xMgr,
- registry::XRegistryKey* xRegistry )
- {
- return ::cppu::component_writeInfoHelper(
- xMgr, xRegistry, s_component_entries );
- }
-
- void * SAL_CALL component_getFactory( sal_Char const* implName,
- lang::XMultiServiceFactory* xMgr,
- registry::XRegistryKey* xRegistry )
- {
- return ::cppu::component_getFactoryHelper(
- implName, xMgr, xRegistry, s_component_entries );
- }
-}
diff --git a/scratch/canvas-cairo/cairo_spritecanvas.hxx b/scratch/canvas-cairo/cairo_spritecanvas.hxx
deleted file mode 100644
index 7d49692d0..000000000
--- a/scratch/canvas-cairo/cairo_spritecanvas.hxx
+++ /dev/null
@@ -1,234 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_SPRITECANVAS_HXX_
-#define _VCLCANVAS_SPRITECANVAS_HXX_
-
-#ifndef _RTL_REF_HXX_
-#include <rtl/ref.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
-#include <com/sun/star/lang/XInitialization.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_
-#include <com/sun/star/lang/XServiceName.hpp>
-#endif
-
-#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
-#include <com/sun/star/awt/XWindow.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP_
-#include <com/sun/star/rendering/XSpriteCanvas.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XINTEGERBITMAP_HPP_
-#include <com/sun/star/rendering/XIntegerBitmap.hpp>
-#endif
-
-#ifndef _CPPUHELPER_COMPBASE6_HXX_
-#include <cppuhelper/compbase6.hxx>
-#endif
-
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-#include <canvas/bitmapcanvasbase.hxx>
-
-#include <memory>
-
-namespace cairo {
-#ifndef CAIRO_XLIB_H
-#include <cairo-xlib.h>
-#endif
-}
-
-#include "cairo_cairo.hxx"
-#include "cairo_redrawmanager.hxx"
-#include "cairo_spritesurface.hxx"
-#include "cairo_canvashelper.hxx"
-#include "cairo_backbuffer.hxx"
-#include "cairo_impltools.hxx"
-#include "cairo_repainttarget.hxx"
-
-class OutputDevice;
-class Point;
-
-namespace com { namespace sun { namespace star { namespace uno
-{
- class XComponentContext;
- class RuntimeException;
-} } } }
-
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::rendering::XSpriteCanvas,
- ::com::sun::star::rendering::XIntegerBitmap,
- ::com::sun::star::awt::XWindow,
- ::com::sun::star::lang::XInitialization,
- ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::lang::XServiceName > CanvasBase_Base;
- typedef ::canvas::internal::BitmapCanvasBase< CanvasBase_Base, CanvasHelper, tools::LocalGuard > SpriteCanvas_Base;
-
- class SpriteCanvas : public SpriteCanvas_Base,
- public SpriteSurface,
- public RepaintTarget
- {
- public:
- typedef ::rtl::Reference< SpriteCanvas > ImplRef;
-
- SpriteCanvas( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XSpriteCanvas
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > >& animationBitmaps,
- sal_Int8 interpolationMode ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCustomSprite > SAL_CALL createCustomSprite( const ::com::sun::star::geometry::RealSize2D& spriteSize ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite > SAL_CALL createClonedSprite( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
-
- // XComponent (comes implicitely with XWindow)
- virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
-
- // XWindow
- virtual void SAL_CALL setPosSize( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int16 Flags ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setVisible( ::sal_Bool Visible ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setEnable( ::sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setFocus( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw( ::com::sun::star::uno::Exception,
- ::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
-
- // XServiceName
- virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException);
-
- // factory
- static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) throw ( ::com::sun::star::uno::Exception );
-
- // SpriteSurface
- virtual void showSprite( const Sprite::ImplRef& sprite );
- virtual void hideSprite( const Sprite::ImplRef& sprite );
- virtual void moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize );
- virtual void updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea );
-
- // RepaintTarget
- virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const;
-
- protected:
- ~SpriteCanvas(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- SpriteCanvas(const SpriteCanvas&);
- SpriteCanvas& operator=( const SpriteCanvas& );
-
- /// Current bounds of the owning Window
- ::com::sun::star::awt::Rectangle maBounds;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
- WindowGraphicDevice::ImplRef mxDevice;
- BackBufferSharedPtr mpBackBuffer;
- ::std::auto_ptr< RedrawManager > mpRedrawManager; // handles smooth screen updates for us
-
- /// True, if the window this canvas is contained in, is visible
- bool mbIsVisible;
- const SystemEnvData* mpSysData;
- };
-}
-
-#endif
diff --git a/scratch/canvas-cairo/cairo_spritesurface.hxx b/scratch/canvas-cairo/cairo_spritesurface.hxx
deleted file mode 100644
index 98178618c..000000000
--- a/scratch/canvas-cairo/cairo_spritesurface.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_SPRITESURFACE_HXX
-#define _VCLCANVAS_SPRITESURFACE_HXX
-
-#ifndef _SAL_CONFIG_H_
-#include <sal/config.h>
-#endif
-
-#include "cairo_sprite.hxx"
-
-class Point;
-class Size;
-class Rectangle;
-
-namespace vclcanvas
-{
- /* Definition of SpriteSurface interface */
-
- class SpriteSurface
- {
- public:
- virtual ~SpriteSurface() {}
-
- // call this when XSprite::show() is called
- virtual void showSprite( const Sprite::ImplRef& sprite ) = 0;
-
- // call this when XSprite::hide() is called
- virtual void hideSprite( const Sprite::ImplRef& sprite ) = 0;
-
- // call this when XSprite::move() is called
- virtual void moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize ) = 0;
-
- // call this when some part of your sprite has changed. That
- // includes show/hide´, i.e. for show, both showSprite and
- // updateSprite must be called.
- virtual void updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea ) = 0;
-
- };
-}
-
-#endif /* _VCLCANVAS_SPRITESURFACE_HXX */
diff --git a/scratch/canvas-cairo/cairo_textlayout.cxx b/scratch/canvas-cairo/cairo_textlayout.cxx
deleted file mode 100644
index 4f493683e..000000000
--- a/scratch/canvas-cairo/cairo_textlayout.cxx
+++ /dev/null
@@ -1,418 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-#include "cairo_textlayout.hxx"
-
-#ifndef BOOST_SCOPED_ARRAY_HPP_INCLUDED
-#include <boost/scoped_array.hpp>
-#endif
-
-#ifndef _SV_METRIC_HXX
-#include <vcl/metric.hxx>
-#endif
-#ifndef _SV_VIRDEV_HXX
-#include <vcl/virdev.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_TEXTDIRECTION_HPP_
-#include <com/sun/star/rendering/TextDirection.hpp>
-#endif
-#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#endif
-#ifndef _BGFX_NUMERIC_FTOOLS_HXX
-#include <basegfx/numeric/ftools.hxx>
-#endif
-
-#include <canvas/canvastools.hxx>
-
-#include "cairo_impltools.hxx"
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- namespace
- {
- void setupLayoutMode( OutputDevice& rOutDev,
- sal_Int8 nTextDirection )
- {
- // TODO(P3): avoid if already correctly set
- ULONG nLayoutMode;
- switch( nTextDirection )
- {
- default:
- nLayoutMode = 0;
- break;
- case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
- nLayoutMode = TEXT_LAYOUT_BIDI_LTR;
- break;
- case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
- nLayoutMode = TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG;
- break;
- case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
- nLayoutMode = TEXT_LAYOUT_BIDI_RTL;
- break;
- case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
- nLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
- break;
- }
-
- // set calculated layout mode. Origin is always the left edge,
- // as required at the API spec
- rOutDev.SetLayoutMode( nLayoutMode | TEXT_LAYOUT_TEXTORIGIN_LEFT );
- }
- }
-
- TextLayout::TextLayout( const rendering::StringContext& aText,
- sal_Int8 nDirection,
- sal_Int64 nRandomSeed,
- const CanvasFont::ImplRef& rFont,
- Cairo* pCairo) :
- TextLayout_Base( m_aMutex ),
- maText( aText ),
- maLogicalAdvancements(),
- mpFont( rFont ),
- mnTextDirection( nDirection ),
- mpCairo( pCairo )
- {
- cairo_reference( mpCairo );
- }
-
- TextLayout::~TextLayout()
- {
- cairo_destroy( mpCairo );
- }
-
- void SAL_CALL TextLayout::disposing()
- {
- tools::LocalGuard aGuard;
-
- mpFont.reset();
- }
-
- // XTextLayout
- uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
- }
-
- uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Sequence< geometry::RealRectangle2D >();
- }
-
- uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Sequence< geometry::RealRectangle2D >();
- }
-
- uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return maLogicalAdvancements;
- }
-
- void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- CHECK_AND_THROW( aAdvancements.getLength() == maText.Length,
- "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
-
- maLogicalAdvancements = aAdvancements;
- }
-
- geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- geometry::RealRectangle2D aBounds( 0, 0, 0, 0 );
-
-// TODO(rodo)
-// if( maLogicalAdvancements.getLength() ) {
-// cairo_save( mpCairo );
-// useFont( mpCairo );
-// cairo_font_extents_t aFontExtents;
-// cairo_font_extents( mpCairo, &aFontExtents );
-// cairo_restore( mpCairo );
-
-// aBounds = geometry::RealRectangle2D( 0, -aFontExtents.ascent,
-// maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
-// aFontExtents.descent );
-// } else {
-
- cairo_save( mpCairo );
-
- ::rtl::OUString aSubText = maText.Text.copy( maText.StartPosition, maText.Length );
- ::rtl::OString aUTF8String = ::rtl::OUStringToOString( aSubText, RTL_TEXTENCODING_UTF8 );
-
- useFont( mpCairo );
-
- cairo_font_extents_t aFontExtents;
- cairo_font_extents( mpCairo, &aFontExtents );
- cairo_text_extents_t aTextExtents;
- cairo_text_extents( mpCairo, aUTF8String, &aTextExtents );
- cairo_restore( mpCairo );
-
- aBounds = geometry::RealRectangle2D( aTextExtents.x_bearing, -aFontExtents.ascent,
- aTextExtents.x_bearing + aTextExtents.width, aFontExtents.descent );
-// }
-
- return aBounds;
- }
-
- double SAL_CALL TextLayout::justify( double nSize ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return 0.0;
- }
-
- double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& aNextLayouts, double nSize ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return 0.0;
- }
-
- rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& aHitPoint ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return rendering::TextHit();
- }
-
- rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return rendering::Caret();
- }
-
- sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return 0;
- }
-
- uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Reference< rendering::XPolyPolygon2D >();
- }
-
- uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return uno::Reference< rendering::XPolyPolygon2D >();
- }
-
- double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- // TODO(F1)
- return 0.0;
- }
-
- sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return mnTextDirection;
- }
-
- uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return mpFont.getRef();
- }
-
- rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException)
- {
- tools::LocalGuard aGuard;
-
- return maText;
- }
-
- void TextLayout::useFont( Cairo* pCairo )
- {
- rendering::FontRequest aFontRequest = mpFont->getFontRequest();
- rendering::FontInfo aFontInfo = aFontRequest.FontDescription;
-
- cairo_select_font_face( pCairo, ::rtl::OUStringToOString( aFontInfo.FamilyName, RTL_TEXTENCODING_UTF8 ), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
- cairo_set_font_size( pCairo, aFontRequest.CellSize );
- }
-
- bool TextLayout::draw( Cairo* pCairo )
- {
- tools::LocalGuard aGuard;
-
- ::rtl::OUString aSubText = maText.Text.copy( maText.StartPosition, maText.Length );
- ::rtl::OString aUTF8String = ::rtl::OUStringToOString( aSubText, RTL_TEXTENCODING_UTF8 );
-
-
- cairo_save( pCairo );
- useFont( pCairo );
- cairo_show_text( pCairo, aUTF8String );
- cairo_restore( pCairo );
-
- return true;
- }
-
- namespace
- {
- class OffsetTransformer
- {
- public:
- OffsetTransformer( const ::basegfx::B2DHomMatrix& rMat ) :
- maMatrix( rMat )
- {
- }
-
- long operator()( const double& rOffset )
- {
- // This is an optimization of the normal rMat*[x,0]
- // transformation of the advancement vector (in x
- // direction), followed by a length calculation of the
- // resulting vector: advancement' =
- // ||rMat*[x,0]||. Since advancements are vectors, we
- // can ignore translational components, thus if [x,0],
- // it follows that rMat*[x,0]=[x',0] holds. Thus, we
- // just have to calc the transformation of the x
- // component.
-
- // TODO(F2): Handle non-horizontal advancements!
- return ::basegfx::fround( hypot(maMatrix.get(0,0)*rOffset,
- maMatrix.get(1,0)*rOffset) );
- }
-
- private:
- ::basegfx::B2DHomMatrix maMatrix;
- };
- }
-
- void TextLayout::setupTextOffsets( long* outputOffsets,
- const uno::Sequence< double >& inputOffsets,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState ) const
- {
- ENSURE_AND_THROW( outputOffsets!=NULL,
- "TextLayout::setupTextOffsets offsets NULL" );
-
- ::basegfx::B2DHomMatrix aMatrix;
-
- ::canvas::tools::mergeViewAndRenderTransform(aMatrix,
- viewState,
- renderState);
-
- // fill integer offsets
- ::std::transform( const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray(),
- const_cast< uno::Sequence< double >& >(inputOffsets).getConstArray()+inputOffsets.getLength(),
- outputOffsets,
- OffsetTransformer( aMatrix ) );
- }
-
-
-#define SERVICE_NAME "com.sun.star.rendering.TextLayout"
-
- ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException )
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( TEXTLAYOUT_IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException )
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-}
diff --git a/scratch/canvas-cairo/cairo_textlayout.hxx b/scratch/canvas-cairo/cairo_textlayout.hxx
deleted file mode 100644
index 02dea4607..000000000
--- a/scratch/canvas-cairo/cairo_textlayout.hxx
+++ /dev/null
@@ -1,157 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _TEXTLAYOUT_HXX
-#define _TEXTLAYOUT_HXX
-
-#ifndef _CPPUHELPER_COMPBASE2_HXX_
-#include <cppuhelper/compbase2.hxx>
-#endif
-#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
-#include <comphelper/broadcasthelper.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XTEXTLAYOUT_HPP_
-#include <com/sun/star/rendering/XTextLayout.hpp>
-#endif
-
-#include <canvas/vclwrapper.hxx>
-
-#include "cairo_cairo.hxx"
-#include "cairo_canvasfont.hxx"
-#include "cairo_impltools.hxx"
-
-
-#define TEXTLAYOUT_IMPLEMENTATION_NAME "CairoCanvas::TextLayout"
-
-/* Definition of TextLayout class */
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XTextLayout,
- ::com::sun::star::lang::XServiceInfo > TextLayout_Base;
-
- class TextLayout : public ::comphelper::OBaseMutex, public TextLayout_Base
- {
- public:
- TextLayout( const ::com::sun::star::rendering::StringContext& aText,
- sal_Int8 nDirection,
- sal_Int64 nRandomSeed,
- const CanvasFont::ImplRef& rFont,
- ::cairo::Cairo* pCairo );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XTextLayout
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealRectangle2D > SAL_CALL queryInkMeasures( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealRectangle2D > SAL_CALL queryMeasures( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< double > SAL_CALL queryLogicalAdvancements( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL applyLogicalAdvancements( const ::com::sun::star::uno::Sequence< double >& aAdvancements ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::geometry::RealRectangle2D SAL_CALL queryTextBounds( ) throw (::com::sun::star::uno::RuntimeException);
- virtual double SAL_CALL justify( double nSize ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual double SAL_CALL combinedJustify( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XTextLayout > >& aNextLayouts, double nSize ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::rendering::TextHit SAL_CALL getTextHit( const ::com::sun::star::geometry::RealPoint2D& aHitPoint ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::rendering::Caret SAL_CALL getCaret( sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getNextInsertionIndex( sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL queryVisualHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL queryLogicalHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
- virtual double SAL_CALL getBaselineOffset( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Int8 SAL_CALL getMainTextDirection( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::rendering::StringContext SAL_CALL getText( ) throw (::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
-
- bool draw( ::cairo::Cairo* pCairo );
-
- protected:
- ~TextLayout(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- TextLayout(const TextLayout&);
- TextLayout& operator=( const TextLayout& );
-
- void setupTextOffsets( long* outputOffsets,
- const ::com::sun::star::uno::Sequence< double >& inputOffsets,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState ) const;
-
- void useFont( ::cairo::Cairo* pCairo );
-
- ::com::sun::star::rendering::StringContext maText;
- ::com::sun::star::uno::Sequence< double > maLogicalAdvancements;
- CanvasFont::ImplRef mpFont;
- sal_Int8 mnTextDirection;
- ::cairo::Cairo* mpCairo;
- };
-
-}
-
-#endif /* _TEXTLAYOUT_HXX */
diff --git a/scratch/canvas-cairo/cairo_windowgraphicdevice.cxx b/scratch/canvas-cairo/cairo_windowgraphicdevice.cxx
deleted file mode 100644
index faace0ff1..000000000
--- a/scratch/canvas-cairo/cairo_windowgraphicdevice.cxx
+++ /dev/null
@@ -1,486 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#include <canvas/debug.hxx>
-
-#include "cairo_helper.hxx"
-#include "cairo_windowgraphicdevice.hxx"
-#include "cairo_linepolypolygon.hxx"
-#include "cairo_parametricpolypolygon.hxx"
-#include "cairo_canvasbitmap.hxx"
-
-#include <canvas/canvastools.hxx>
-
-#ifndef _SV_SYSDATA_HXX
-#include <vcl/sysdata.hxx>
-#endif
-
-#ifndef _OSL_MUTEX_HXX_
-#include <osl/mutex.hxx>
-#endif
-
-#ifndef _VCL_CANVASTOOLS_HXX
-#include <vcl/canvastools.hxx>
-#endif
-
-#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
-#include <basegfx/tools/canvastools.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_XLINEPOLYPOLYGON2D_HPP_
-#include <com/sun/star/rendering/XLinePolyPolygon2D.hpp>
-#endif
-
-using namespace ::com::sun::star;
-using namespace ::cairo;
-
-namespace vclcanvas
-{
- WindowGraphicDevice::WindowGraphicDevice( Window& rOutputWindow, const SystemEnvData* pSysData ) :
- WindowGraphicDevice_Base( m_aMutex ),
- mpOutputWindow( &rOutputWindow ),
- mpWindowSurface( NULL )
- {
- printf( "WindowGraphicDevice constructor\n" );
-
- CHECK_AND_THROW( mpOutputWindow != NULL,
- "WindowGraphicDevice::WindowGraphicDevice(): pWindow is NULL" );
- mpSysData = pSysData;
- }
-
- WindowGraphicDevice::~WindowGraphicDevice()
- {
- printf( "WindowGraphicDevice destructor\n" );
- }
-
- uno::Reference< rendering::XBufferController > SAL_CALL WindowGraphicDevice::getBufferController() throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return uno::Reference< rendering::XBufferController >();
- }
-
- uno::Reference< rendering::XColorSpace > SAL_CALL WindowGraphicDevice::getDeviceColorSpace() throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return uno::Reference< rendering::XColorSpace >();
- }
-
- geometry::RealSize2D SAL_CALL WindowGraphicDevice::getPhysicalResolution() throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return ::canvas::tools::createInfiniteSize2D(); // we're disposed
-
- // Map a one-by-one millimeter box to pixel
- const MapMode aOldMapMode( mpOutputWindow->GetMapMode() );
- mpOutputWindow->SetMapMode( MapMode(MAP_MM) );
- const Size aPixelSize( mpOutputWindow->LogicToPixel(Size(1,1)) );
- mpOutputWindow->SetMapMode( aOldMapMode );
-
- return ::vcl::unotools::size2DFromSize( aPixelSize );
- }
-
- geometry::RealSize2D SAL_CALL WindowGraphicDevice::getSize() throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return ::canvas::tools::createInfiniteSize2D(); // we're disposed
-
- // Map the pixel dimensions of the output window to millimeter
- const MapMode aOldMapMode( mpOutputWindow->GetMapMode() );
- mpOutputWindow->SetMapMode( MapMode(MAP_MM) );
- const Size aLogSize( mpOutputWindow->PixelToLogic(mpOutputWindow->GetOutputSizePixel()) );
- mpOutputWindow->SetMapMode( aOldMapMode );
-
- return ::vcl::unotools::size2DFromSize( aLogSize );
- }
-
- uno::Reference< rendering::XLinePolyPolygon2D > SAL_CALL WindowGraphicDevice::createCompatibleLinePolyPolygon( const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points ) throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return uno::Reference< rendering::XLinePolyPolygon2D >(); // we're disposed
-
- return uno::Reference< rendering::XLinePolyPolygon2D >(
- new LinePolyPolygon(
- ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points ) ) );
- }
-
- uno::Reference< rendering::XBezierPolyPolygon2D > SAL_CALL WindowGraphicDevice::createCompatibleBezierPolyPolygon( const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points ) throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return uno::Reference< rendering::XBezierPolyPolygon2D >(); // we're disposed
-
- return uno::Reference< rendering::XBezierPolyPolygon2D >(
- new LinePolyPolygon(
- ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) );
- }
-
- uno::Reference< rendering::XBitmap > SAL_CALL WindowGraphicDevice::createCompatibleBitmap( const geometry::IntegerSize2D& size ) throw (lang::IllegalArgumentException,uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return uno::Reference< rendering::XBitmap >(); // we're disposed
-
- return uno::Reference< rendering::XBitmap >( new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size),
- false,
- ImplRef(this) ) );
- }
-
- uno::Reference< rendering::XVolatileBitmap > SAL_CALL WindowGraphicDevice::createVolatileBitmap( const geometry::IntegerSize2D& size ) throw (lang::IllegalArgumentException,uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return uno::Reference< rendering::XVolatileBitmap >();
- }
-
- uno::Reference< rendering::XBitmap > SAL_CALL WindowGraphicDevice::createCompatibleAlphaBitmap( const geometry::IntegerSize2D& size ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( !mpOutputWindow )
- return uno::Reference< rendering::XBitmap >(); // we're disposed
-
- return uno::Reference< rendering::XBitmap >( new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size),
- true,
- ImplRef(this) ) );
- }
-
- uno::Reference< rendering::XVolatileBitmap > SAL_CALL WindowGraphicDevice::createVolatileAlphaBitmap( const geometry::IntegerSize2D& size ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return uno::Reference< rendering::XVolatileBitmap >();
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2DFactory > SAL_CALL WindowGraphicDevice::getParametricPolyPolygonFactory() throw (uno::RuntimeException)
- {
- return uno::Reference< rendering::XParametricPolyPolygon2DFactory >( this );
- }
-
- sal_Bool SAL_CALL WindowGraphicDevice::hasFullScreenMode() throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return false;
- }
-
- sal_Bool SAL_CALL WindowGraphicDevice::enterFullScreenMode( sal_Bool bEnter ) throw (uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return false;
- }
-
- // XParametricPolyPolygon2DFactory
- // =========================================================
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createLinearHorizontalGradient( const uno::Sequence< double >& leftColor, const uno::Sequence< double >& rightColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(P1): Could as well use static objects here,
- // XParametricPolyPolygon2D has no (externally visible)
- // state. OTOH, might as well leave that as it is, to allow
- // each XParametricPolyPolygon2D to hold a static
- // XPolyPolygon2D internally, and hand out the same
- // XPolyPolygon2D each time
- // XParametricPolyPolygon2D::getOutline() is called.
- return uno::Reference< rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createLinearHorizontalGradient( leftColor,
- rightColor,
- this ) );
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createAxialHorizontalGradient( const uno::Sequence< double >& middleColor, const uno::Sequence< double >& endColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(P1): Could as well use static objects here,
- // XParametricPolyPolygon2D has no (externally visible)
- // state. OTOH, might as well leave that as it is, to allow
- // each XParametricPolyPolygon2D to hold a static
- // XPolyPolygon2D internally, and hand out the same
- // XPolyPolygon2D each time
- // XParametricPolyPolygon2D::getOutline() is called.
- return uno::Reference< rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createAxialHorizontalGradient( middleColor,
- endColor,
- this ) );
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createEllipticalGradient( const uno::Sequence< double >& centerColor, const uno::Sequence< double >& endColor, const geometry::RealRectangle2D& boundRect ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(P1): Could as well use static objects here,
- // XParametricPolyPolygon2D has no (externally visible)
- // state. OTOH, might as well leave that as it is, to allow
- // each XParametricPolyPolygon2D to hold a static
- // XPolyPolygon2D internally, and hand out the same
- // XPolyPolygon2D each time
- // XParametricPolyPolygon2D::getOutline() is called.
- return uno::Reference< rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createEllipticalGradient( centerColor,
- endColor,
- boundRect,
- this ) );
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createRectangularGradient( const uno::Sequence< double >& centerColor, const uno::Sequence< double >& endColor, const geometry::RealRectangle2D& boundRect ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(P1): Could as well use static objects here,
- // XParametricPolyPolygon2D has no (externally visible)
- // state. OTOH, might as well leave that as it is, to allow
- // each XParametricPolyPolygon2D to hold a static
- // XPolyPolygon2D internally, and hand out the same
- // XPolyPolygon2D each time
- // XParametricPolyPolygon2D::getOutline() is called.
- return uno::Reference< rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createRectangularGradient( centerColor,
- endColor,
- boundRect,
- this ) );
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createVerticalLinesHatch( const uno::Sequence< double >& leftColor, const uno::Sequence< double >& rightColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return uno::Reference< rendering::XParametricPolyPolygon2D >();
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createOrthogonalLinesHatch( const uno::Sequence< double >& leftTopColor, const uno::Sequence< double >& rightBottomColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return uno::Reference< rendering::XParametricPolyPolygon2D >();
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createThreeCrossingLinesHatch( const uno::Sequence< double >& startColor, const uno::Sequence< double >& endColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return uno::Reference< rendering::XParametricPolyPolygon2D >();
- }
-
- uno::Reference< rendering::XParametricPolyPolygon2D > SAL_CALL WindowGraphicDevice::createFourCrossingLinesHatch( const uno::Sequence< double >& startColor, const uno::Sequence< double >& endColor ) throw (lang::IllegalArgumentException, uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return uno::Reference< rendering::XParametricPolyPolygon2D >();
- }
-
- // XPropertySet
- // ==============================================
-
- uno::Reference< beans::XPropertySetInfo > SAL_CALL WindowGraphicDevice::getPropertySetInfo( ) throw (uno::RuntimeException)
- {
- // This is a stealth property set
- return uno::Reference< beans::XPropertySetInfo >();
- }
-
- void SAL_CALL WindowGraphicDevice::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
- {
- // all our properties are read-only
- throw beans::PropertyVetoException();
- }
-
- uno::Any SAL_CALL WindowGraphicDevice::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( PropertyName.equalsAscii( "DeviceHandle" ) )
- return uno::makeAny( reinterpret_cast< sal_Int64 >( mpOutputWindow ) );
-
- throw beans::UnknownPropertyException();
- }
-
- void SAL_CALL WindowGraphicDevice::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( aPropertyName.equalsAscii( "DeviceHandle" ) )
- return; // ignore, we only have read-only properties, so
- // the listener won't notice the difference
-
- throw beans::UnknownPropertyException();
- }
-
- void SAL_CALL WindowGraphicDevice::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( aPropertyName.equalsAscii( "DeviceHandle" ) )
- return; // ignore, we only have read-only properties, so
- // the listener was not added in the first place
-
- throw beans::UnknownPropertyException();
- }
-
- void SAL_CALL WindowGraphicDevice::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( PropertyName.equalsAscii( "DeviceHandle" ) )
- return; // ignore, we only have read-only properties, so
- // the listener won't notice the difference
-
- throw beans::UnknownPropertyException();
- }
-
- void SAL_CALL WindowGraphicDevice::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if( PropertyName.equalsAscii( "DeviceHandle" ) )
- return; // ignore, we only have read-only properties, so
- // the listener was not added in the first place
-
- throw beans::UnknownPropertyException();
- }
-
-#define IMPLEMENTATION_NAME "CairoCanvas::WindowGraphicDevice"
-#define SERVICE_NAME "com.sun.star.rendering.GraphicDevice"
-
- ::rtl::OUString SAL_CALL WindowGraphicDevice::getImplementationName( ) throw (uno::RuntimeException)
- {
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
- }
-
- sal_Bool SAL_CALL WindowGraphicDevice::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
- {
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
-
- uno::Sequence< ::rtl::OUString > SAL_CALL WindowGraphicDevice::getSupportedServiceNames( ) throw (uno::RuntimeException)
- {
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
-
- return aRet;
- }
-
- void SAL_CALL WindowGraphicDevice::disposing()
- {
- printf("WindowGraphicDevice disposing\n");
-
- ::osl::MutexGuard aGuard( m_aMutex );
-
- // release all references
- mpOutputWindow = NULL;
-
- if( mpWindowSurface ) {
- printf( "going to destroy mpWindowSurface\n" );
- cairo_surface_destroy( mpWindowSurface );
- mpWindowSurface = NULL;
- }
- }
-
- OutputDevice* WindowGraphicDevice::getOutDev() const
- {
- return mpOutputWindow;
- }
-
- Surface* WindowGraphicDevice::getSurface()
- {
- if( !mpWindowSurface ) {
- Size aSize = getSurfaceSize();
- mpWindowSurface = (Surface*) cairoHelperGetSurface( mpSysData,
- mpOutputWindow->GetOutOffXPixel(), mpOutputWindow->GetOutOffYPixel(),
- aSize.Width(), aSize.Height() );
- }
- return mpWindowSurface;
- }
-
- Surface* WindowGraphicDevice::getSurface( Bitmap& rBitmap )
- {
- Surface *pSurface = NULL;
-
- BitmapSystemData aData;
- if( rBitmap.GetSystemData( aData ) ) {
- const Size& rSize = rBitmap.GetSizePixel();
-
- pSurface = (Surface *) cairoHelperGetSurface( mpSysData, aData, rSize.Width(), rSize.Height() );
- }
-
- return pSurface;
- }
-
- Size WindowGraphicDevice::getSurfaceSize()
- {
- return mpOutputWindow->GetOutputSizePixel();
- }
-
- Surface* WindowGraphicDevice::getSimilarSurface( Size aSize, Format aFormat )
- {
- printf( "called WindowGraphicDevice::getSimilarSurface %d x %d\n", aSize.Width(), aSize.Height() );
- return cairo_surface_create_similar( getSurface(), aFormat, aSize.Width(), aSize.Height() );
- }
-
- Surface* WindowGraphicDevice::getSimilarSurface( Format aFormat )
- {
- return getSimilarSurface( getSurfaceSize(), aFormat );
- }
-
- void WindowGraphicDevice::flush()
- {
- cairoHelperFlush( mpSysData );
- }
-}
diff --git a/scratch/canvas-cairo/cairo_windowgraphicdevice.hxx b/scratch/canvas-cairo/cairo_windowgraphicdevice.hxx
deleted file mode 100644
index 16388f57b..000000000
--- a/scratch/canvas-cairo/cairo_windowgraphicdevice.hxx
+++ /dev/null
@@ -1,205 +0,0 @@
-/*************************************************************************
- *
- * $RCSfile$
- *
- * $Revision$
- *
- * last change: $Author$ $Date$
- *
- * The Contents of this file are made available subject to the terms of
- * either of the following licenses
- *
- * - GNU Lesser General Public License Version 2.1
- * - Sun Industry Standards Source License Version 1.1
- *
- * Sun Microsystems Inc., October, 2000
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2000 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
- *
- *
- * Sun Industry Standards Source License Version 1.1
- * =================================================
- * The contents of this file are subject to the Sun Industry Standards
- * Source License Version 1.1 (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.openoffice.org/license.html.
- *
- * Software provided under this License is provided on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- * See the License for the specific provisions governing your rights and
- * obligations concerning the Software.
- *
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
- *
- * Copyright: 2000 by Sun Microsystems, Inc.
- *
- * All Rights Reserved.
- *
- * Contributor(s): _______________________________________
- *
- *
- ************************************************************************/
-
-#ifndef _VCLCANVAS_WINDOWGRAPHICDEVICE_HXX
-#define _VCLCANVAS_WINDOWGRAPHICDEVICE_HXX
-
-#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
-#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XGRAPHICDEVICE_HPP_
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XPARAMETRICPOLYPOLYGON2DFACTORY_HPP_
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_RENDERING_XCANVAS_HPP_
-#include <com/sun/star/rendering/XCanvas.hpp>
-#endif
-
-#ifndef _CPPUHELPER_COMPBASE4_HXX_
-#include <cppuhelper/compbase4.hxx>
-#endif
-#ifndef _COMPHELPER_BROADCASTHELPER_HXX_
-#include <comphelper/broadcasthelper.hxx>
-#endif
-
-#ifndef _COMPHELPER_IMPLEMENTATIONREFERENCE_HXX
-#include <comphelper/implementationreference.hxx>
-#endif
-
-#ifndef _SV_OUTDEV_HXX
-#include <vcl/outdev.hxx>
-#endif
-#ifndef _SV_WINDOW_HXX
-#include <vcl/window.hxx>
-#endif
-
-#include "cairo_cairo.hxx"
-
-namespace cairo {
-
-// including glitz here conflicts with boost headers
-// #ifdef CAIRO_HAS_GLITZ_SURFACE
-// #include <glitz.h>
-// #endif
-
- typedef struct _glitz_surface glitz_surface_t;
- typedef struct _glitz_drawable glitz_drawable_t;
-}
-
-/* Definition of WindowGraphicDevice class */
-
-namespace vclcanvas
-{
- typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
- ::com::sun::star::beans::XPropertySet,
- ::com::sun::star::lang::XServiceInfo > WindowGraphicDevice_Base;
-
- class WindowGraphicDevice : public ::comphelper::OBaseMutex, public WindowGraphicDevice_Base
- {
- public:
-
- typedef ::comphelper::ImplementationReference< WindowGraphicDevice,
- ::com::sun::star::rendering::XGraphicDevice > ImplRef;
-
- /** Create an XWindowGraphicDevice for given VCL window
- */
- WindowGraphicDevice( Window& rOutputWindow, const SystemEnvData* pSysData );
-
- /// Dispose all internal references
- virtual void SAL_CALL disposing();
-
- // XWindowGraphicDevice
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBufferController > SAL_CALL getBufferController( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace > SAL_CALL getDeviceColorSpace( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::geometry::RealSize2D SAL_CALL getPhysicalResolution( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::geometry::RealSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > SAL_CALL createCompatibleLinePolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > SAL_CALL createCompatibleBezierPolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL createCompatibleBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > SAL_CALL createVolatileBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL createCompatibleAlphaBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > SAL_CALL createVolatileAlphaBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2DFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasFullScreenMode( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL enterFullScreenMode( sal_Bool bEnter ) throw (::com::sun::star::uno::RuntimeException);
-
- // XParametricPolyPolygon2DFactory
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createLinearHorizontalGradient( const ::com::sun::star::uno::Sequence< double >& leftColor, const ::com::sun::star::uno::Sequence< double >& rightColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createAxialHorizontalGradient( const ::com::sun::star::uno::Sequence< double >& middleColor, const ::com::sun::star::uno::Sequence< double >& endColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createEllipticalGradient( const ::com::sun::star::uno::Sequence< double >& centerColor, const ::com::sun::star::uno::Sequence< double >& endColor, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createRectangularGradient( const ::com::sun::star::uno::Sequence< double >& centerColor, const ::com::sun::star::uno::Sequence< double >& endColor, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createVerticalLinesHatch( const ::com::sun::star::uno::Sequence< double >& leftColor, const ::com::sun::star::uno::Sequence< double >& rightColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createOrthogonalLinesHatch( const ::com::sun::star::uno::Sequence< double >& leftTopColor, const ::com::sun::star::uno::Sequence< double >& rightBottomColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createThreeCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& startColor, const ::com::sun::star::uno::Sequence< double >& endColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createFourCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& startColor, const ::com::sun::star::uno::Sequence< double >& endColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
-
- // XPropertySet
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
-
- // XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
-
- OutputDevice* getOutDev() const;
-
- Size getSurfaceSize();
- ::cairo::Surface* getSurface();
- ::cairo::Surface* getSurface( Bitmap& rBitmap );
-
- ::cairo::Surface* getSimilarSurface( ::cairo::Format aFormat = ::cairo::CAIRO_FORMAT_ARGB32 );
- ::cairo::Surface* getSimilarSurface( Size aSize, ::cairo::Format aFormat = ::cairo::CAIRO_FORMAT_ARGB32 );
-
- void flush();
-
- protected:
- ~WindowGraphicDevice(); // we're a ref-counted UNO class. _We_ destroy ourselves.
-
- private:
- // default: disabled copy/assignment
- WindowGraphicDevice(const WindowGraphicDevice&);
- WindowGraphicDevice& operator=( const WindowGraphicDevice& );
-
- // TODO(Q3): Lifetime issue. Cannot control pointer validity
- // over object lifetime, since we're a UNO component. Now that
- // we've changed the ::Window canvas reference to a weak ref,
- // might be okay to hold a uno::Reference to the VCL window
- // here.
- Window* mpOutputWindow;
-
- const SystemEnvData* mpSysData;
- ::cairo::Surface* mpWindowSurface;
- };
-}
-
-#endif /* _VCLCANVAS_WINDOWGRAPHICDEVICE_HXX */
diff --git a/scratch/canvas-cairo/exports.dxp b/scratch/canvas-cairo/exports.dxp
deleted file mode 100644
index 0c2e3e7cd..000000000
--- a/scratch/canvas-cairo/exports.dxp
+++ /dev/null
@@ -1,3 +0,0 @@
-component_getImplementationEnvironment
-component_writeInfo
-component_getFactory \ No newline at end of file
diff --git a/scratch/canvas-cairo/exports.map b/scratch/canvas-cairo/exports.map
deleted file mode 100644
index e15684fa6..000000000
--- a/scratch/canvas-cairo/exports.map
+++ /dev/null
@@ -1,9 +0,0 @@
-CAN_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- component_getDescriptionFunc;
- local:
- *;
-};
diff --git a/scratch/canvas-cairo/makefile.mk b/scratch/canvas-cairo/makefile.mk
deleted file mode 100644
index 64e838551..000000000
--- a/scratch/canvas-cairo/makefile.mk
+++ /dev/null
@@ -1,127 +0,0 @@
-#*************************************************************************
-#
-# $RCSfile: makefile.mk,v $
-#
-# $Revision: 1.3 $
-#
-# last change: $Author: rodo $ $Date: 2005/06/13 09:32:55 $
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 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
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): _______________________________________
-#
-#
-#
-#*************************************************************************
-
-PRJ=..$/..
-
-PRJNAME=canvas
-TARGET=cairocanvas
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings -----------------------------------------------------------
-
-.INCLUDE : settings.mk
-DLLPRE =
-SOLARLIB+=-L/usr/local/lib
-
-# --- Common ----------------------------------------------------------
-
-PKGCONFIG_MODULES=glitz glitz-glx cairo
-.INCLUDE: pkg_config.mk
-
-
-.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
-CDEFS+= -DVERBOSE
-.ENDIF
-
-# Disable optimization for SunCC SPARC
-.IF "$(OS)$(CPU)"=="SOLARISS" && "$(COM)"!="GCC"
-NOOPTFILES = $(SLO)$/cairo_canvashelper_texturefill.obj
-.ENDIF
-
-SLOFILES = $(SLO)$/cairo_spritecanvas.obj \
- $(SLO)$/cairo_linepolypolygon.obj \
- $(SLO)$/cairo_backbuffer.obj \
- $(SLO)$/cairo_bitmapbackbuffer.obj \
- $(SLO)$/cairo_canvasfont.obj \
- $(SLO)$/cairo_windowgraphicdevice.obj \
- $(SLO)$/cairo_canvasbitmap.obj \
- $(SLO)$/cairo_canvasbitmaphelper.obj \
- $(SLO)$/cairo_canvashelper.obj \
- $(SLO)$/cairo_canvashelper_texturefill.obj \
- $(SLO)$/cairo_textlayout.obj \
- $(SLO)$/cairo_canvascustomsprite.obj \
- $(SLO)$/cairo_cachedbitmap.obj \
- $(SLO)$/cairo_redrawmanager.obj \
- $(SLO)$/cairo_impltools.obj \
- $(SLO)$/cairo_parametricpolypolygon.obj \
- $(SLO)$/cairo_helper.obj
-
-
-SHL1TARGET=$(TARGET).uno
-
-SHL1STDLIBS= $(TOOLSLIB) $(CPPULIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) $(BASEGFXLIB) $(CANVASTOOLSLIB) $(GOODIESLIB) $(PKGCONFIG_LIBS)
-
-SHL1IMPLIB=i$(TARGET)
-SHL1LIBS=$(SLB)$/$(TARGET).lib
-SHL1DEF=$(MISC)$/$(SHL1TARGET).def
-
-.IF "$(OS)"=="MACOSX"
-.ELSE
-SHL1VERSIONMAP=exports.map
-.ENDIF
-
-DEF1NAME=$(SHL1TARGET)
-DEF1EXPORTFILE=exports.dxp
-
-# ==========================================================================
-
-.INCLUDE : target.mk