summaryrefslogtreecommitdiff
path: root/canvas/source/vcl
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2005-11-02 12:04:13 +0000
committerKurt Zenker <kz@openoffice.org>2005-11-02 12:04:13 +0000
commitaaf62231a75359d356d04ab26fbee69ce8d5d371 (patch)
treef83267e13200c0dba5d3951098be215f121b85e0 /canvas/source/vcl
parent8d9949c7798774746e75e033448628ab96e7e543 (diff)
INTEGRATION: CWS canvas02 (1.8.4); FILE MERGED
2005/10/19 13:47:18 thb 1.8.4.6: #i48939# Adapted to GraphicDeviceBase changes; add screen dump facility; now providing the sprite bounds debug feature as a public property 2005/10/08 12:56:52 thb 1.8.4.5: RESYNC: (1.8-1.9); FILE MERGED 2005/07/21 14:52:49 thb 1.8.4.4: #i48939# Factored out round up/down to integer; removed backend specific methods from base Sprite interface; removed updateScreen overwrite from SpriteCanvasBase (too much backend specifics need to be passed to HW canvases); now passing the target OutputDevice directly via Sprite::redraw() method in VCL canvas; made XFont -> impl font conversion dynamic cast, too; removed the getSpriteTargetSurface crap from SpriteCanvas 2005/07/03 20:25:18 thb 1.8.4.3: #i48939# Reworked ParametricPolyPolygon, to extract state in an atomic operation; added more state checking 'isXDirty()' methods to canvascustomspritehelper; added various comments and notes 2005/06/28 11:22:49 thb 1.8.4.2: #i48939# Removed refcounted reference to device in canvashelper (leads to circular references for SpriteCanvas); improved docs; added drawBezier() implementation 2005/06/17 23:49:52 thb 1.8.4.1: #i48939# Huge refactoring of canvas; as much functionality as possible is now common in a bunch of shared base classes (input checking, locking, sprite redraw, etc.); added scroll update optimization, transparently to all canvas implementations
Diffstat (limited to 'canvas/source/vcl')
-rw-r--r--canvas/source/vcl/spritecanvas.cxx398
1 files changed, 116 insertions, 282 deletions
diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx
index c8b0d1e48a92..9e369642978c 100644
--- a/canvas/source/vcl/spritecanvas.cxx
+++ b/canvas/source/vcl/spritecanvas.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: spritecanvas.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: rt $ $Date: 2005-09-07 23:23:21 $
+ * last change: $Author: kz $ $Date: 2005-11-02 13:04:13 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -34,64 +34,29 @@
************************************************************************/
#include <canvas/debug.hxx>
+#include <canvas/verbosetrace.hxx>
+#include <canvas/canvastools.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_BITMAPEX_HXX
#include <vcl/bitmapex.hxx>
-#endif
-#include <algorithm>
+#include <basegfx/tools/canvastools.hxx>
-#include <canvas/verbosetrace.hxx>
-#include <canvas/canvastools.hxx>
+#include <algorithm>
#include "spritecanvas.hxx"
-#include "canvascustomsprite.hxx"
-#include "windowgraphicdevice.hxx"
-using namespace ::com::sun::star;
+using namespace ::com::sun::star;
#define IMPLEMENTATION_NAME "VCLCanvas::SpriteCanvas"
#define SERVICE_NAME "com.sun.star.rendering.VCLCanvas"
@@ -116,103 +81,81 @@ namespace
namespace vclcanvas
{
SpriteCanvas::SpriteCanvas( const uno::Reference< uno::XComponentContext >& rxContext ) :
- maBounds(),
- mxComponentContext( rxContext ),
- mxDevice(),
- mpBackBuffer(),
- mpRedrawManager(),
- mbIsVisible( false )
- {
+ mxComponentContext( rxContext )
+ {
+ OSL_TRACE( "SpriteCanvas created" );
+
+ // add our own property to GraphicDevice
+ maPropHelper.addProperties(
+ ::canvas::PropertySetHelper::MakeMap
+ ("UnsafeScrolling",
+ boost::bind(&SpriteCanvasHelper::isUnsafeScrolling,
+ boost::ref(maCanvasHelper)),
+ boost::bind(&SpriteCanvasHelper::enableUnsafeScrolling,
+ boost::ref(maCanvasHelper),
+ _1))
+ ("SpriteBounds",
+ boost::bind(&SpriteCanvasHelper::isSpriteBounds,
+ boost::ref(maCanvasHelper)),
+ boost::bind(&SpriteCanvasHelper::enableSpriteBounds,
+ boost::ref(maCanvasHelper),
+ _1)));
}
SpriteCanvas::~SpriteCanvas()
{
+ OSL_TRACE( "SpriteCanvas destroyed" );
}
+
void SAL_CALL SpriteCanvas::disposing()
{
tools::LocalGuard aGuard;
- dispose();
+ mxComponentContext.clear();
// forward to parent
- SpriteCanvas_Base::disposing();
+ SpriteCanvasBaseT::disposing();
}
- uno::Reference< rendering::XAnimatedSprite > SAL_CALL SpriteCanvas::createSpriteFromAnimation( const uno::Reference< rendering::XAnimation >& animation ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+ ::sal_Bool SAL_CALL SpriteCanvas::showBuffer( ::sal_Bool bUpdateAll ) throw (uno::RuntimeException)
{
tools::LocalGuard aGuard;
- return uno::Reference< rendering::XAnimatedSprite >(NULL);
+ // avoid repaints on hidden window (hidden: not mapped to
+ // screen). Return failure, since the screen really has _not_
+ // been updated (caller should try again later)
+ return !mbIsVisible ? false : SpriteCanvasBaseT::showBuffer( bUpdateAll );
}
- 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)
+ ::sal_Bool SAL_CALL SpriteCanvas::switchBuffer( ::sal_Bool bUpdateAll ) throw (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,
- 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);
+ // avoid repaints on hidden window (hidden: not mapped to
+ // screen). Return failure, since the screen really has _not_
+ // been updated (caller should try again later)
+ return !mbIsVisible ? false : SpriteCanvasBaseT::switchBuffer( bUpdateAll );
}
sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
{
tools::LocalGuard aGuard;
- 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 );
-
- // commit to screen
- 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;
+ // avoid repaints on hidden window (hidden: not mapped to
+ // screen). Return failure, since the screen really has _not_
+ // been updated (caller should try again later)
+ return !mbIsVisible ? false : maCanvasHelper.updateScreen(bUpdateAll,
+ mbSurfaceDirty);
}
+
void SAL_CALL SpriteCanvas::initialize( const uno::Sequence< uno::Any >& aArguments ) throw( uno::Exception,
uno::RuntimeException)
{
- VERBOSE_TRACE( "SpriteCanvas::initialize called" );
+ tools::LocalGuard aGuard;
+
+ VERBOSE_TRACE( "VCLSpriteCanvas::initialize called" );
CHECK_AND_THROW( aArguments.getLength() >= 1,
"SpriteCanvas::initialize: wrong number of arguments" );
@@ -228,239 +171,130 @@ namespace vclcanvas
CHECK_AND_THROW( pOutputWindow != NULL,
"SpriteCanvas::initialize: invalid Window pointer" );
- // setup graphic device
- mxDevice = WindowGraphicDevice::ImplRef( new WindowGraphicDevice( *pOutputWindow ) );
-
// setup helper
- maCanvasHelper.setGraphicDevice( mxDevice );
-
- // setup back buffer
- mpBackBuffer.reset( new BackBuffer( *pOutputWindow ) );
- mpBackBuffer->setSize( pOutputWindow->GetOutputSizePixel() );
-
- // always render into back buffer, don't preserve state
- // (it's our private VDev, after all)
- maCanvasHelper.setOutDev( mpBackBuffer, false );
-
- // setup RedrawManager
- mpRedrawManager.reset( new RedrawManager( *pOutputWindow,
- mpBackBuffer ) );
+ maDeviceHelper.init( *pOutputWindow,
+ *this );
+ maCanvasHelper.init( *this,
+ maDeviceHelper.getBackBuffer(),
+ false, // no OutDev state preservation
+ false ); // no alpha on surface
+ maCanvasHelper.setRedrawManager( maRedrawManager );
}
}
- void SAL_CALL SpriteCanvas::dispose( ) throw (uno::RuntimeException)
+ ::rtl::OUString SAL_CALL SpriteCanvas::getImplementationName() throw( uno::RuntimeException )
{
- tools::LocalGuard aGuard;
-
- maCanvasHelper.disposing();
-
- mxComponentContext.clear();
- mxDevice.reset();
- mpBackBuffer.reset(),
- mpRedrawManager.reset();
+ return getImplementationName_SpriteCanvas();
}
- void SAL_CALL SpriteCanvas::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw (uno::RuntimeException)
+ sal_Bool SAL_CALL SpriteCanvas::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
{
- // Ignored
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
}
- void SAL_CALL SpriteCanvas::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw (uno::RuntimeException)
+ uno::Sequence< ::rtl::OUString > SAL_CALL SpriteCanvas::getSupportedServiceNames() throw( uno::RuntimeException )
{
- // Ignored
+ return getSupportedServiceNames_SpriteCanvas();
}
- 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 )
+ ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
{
- maBounds.X = nX;
- maBounds.Y = nY;
- maBounds.Width = nWidth;
- maBounds.Height = nHeight;
-
- if( mpBackBuffer.get() )
- mpBackBuffer->setSize( Size( nWidth,
- nHeight ) );
- }
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
}
- awt::Rectangle SAL_CALL SpriteCanvas::getPosSize( ) throw (uno::RuntimeException)
+ uno::Reference< uno::XInterface > SAL_CALL SpriteCanvas::createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
{
- tools::LocalGuard aGuard;
-
- return maBounds;
+ return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new SpriteCanvas( xContext )) );
}
- void SAL_CALL SpriteCanvas::setVisible( ::sal_Bool bVisible ) throw (uno::RuntimeException)
+ bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
+ const ::Point& rPt,
+ const ::Size& rSz,
+ const GraphicAttr& rAttr ) const
{
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
+ return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
}
- void SAL_CALL SpriteCanvas::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) throw (uno::RuntimeException)
+ OutputDevice* SpriteCanvas::getOutDev() const
{
- // Ignored
- }
+ tools::LocalGuard aGuard;
- ::rtl::OUString SAL_CALL SpriteCanvas::getImplementationName() throw( uno::RuntimeException )
- {
- return getImplementationName_SpriteCanvas();
+ return maDeviceHelper.getOutDev();
}
- sal_Bool SAL_CALL SpriteCanvas::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
+ BackBufferSharedPtr SpriteCanvas::getBackBuffer() const
{
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
- }
+ tools::LocalGuard aGuard;
- uno::Sequence< ::rtl::OUString > SAL_CALL SpriteCanvas::getSupportedServiceNames() throw( uno::RuntimeException )
- {
- return getSupportedServiceNames_SpriteCanvas();
+ return maDeviceHelper.getBackBuffer();
}
- ::rtl::OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (::com::sun::star::uno::RuntimeException)
+ uno::Reference< beans::XPropertySetInfo > SAL_CALL SpriteCanvas::getPropertySetInfo() throw (uno::RuntimeException)
{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
+ tools::LocalGuard aGuard;
+ return maPropHelper.getPropertySetInfo();
}
- uno::Reference< uno::XInterface > SAL_CALL SpriteCanvas::createInstance( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::Exception )
+ void SAL_CALL SpriteCanvas::setPropertyValue( const ::rtl::OUString& aPropertyName,
+ const uno::Any& aValue ) throw (beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
- return uno::Reference< uno::XInterface >( static_cast<cppu::OWeakObject*>(new SpriteCanvas( xContext )) );
+ tools::LocalGuard aGuard;
+ maPropHelper.setPropertyValue( aPropertyName, aValue );
}
- // SpriteSurface
- void SpriteCanvas::showSprite( const Sprite::ImplRef& sprite )
+ uno::Any SAL_CALL SpriteCanvas::getPropertyValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->showSprite( sprite );
+ return maPropHelper.getPropertyValue( aPropertyName );
}
- void SpriteCanvas::hideSprite( const Sprite::ImplRef& sprite )
+ void SAL_CALL SpriteCanvas::addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->hideSprite( sprite );
+ maPropHelper.addPropertyChangeListener( aPropertyName,
+ xListener );
}
- void SpriteCanvas::moveSprite( const Sprite::ImplRef& sprite,
- const Point& rOldPos,
- const Point& rNewPos,
- const Size& rSpriteSize )
+ void SAL_CALL SpriteCanvas::removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->moveSprite( sprite, rOldPos, rNewPos, rSpriteSize );
+ maPropHelper.removePropertyChangeListener( aPropertyName,
+ xListener );
}
- void SpriteCanvas::updateSprite( const Sprite::ImplRef& sprite,
- const Point& rPos,
- const Rectangle& rUpdateArea )
+ void SAL_CALL SpriteCanvas::addVetoableChangeListener( const ::rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
tools::LocalGuard aGuard;
-
- if( !mpRedrawManager.get() )
- return; // we're disposed
-
- mpRedrawManager->updateSprite( sprite, rPos, rUpdateArea );
+ maPropHelper.addVetoableChangeListener( aPropertyName,
+ xListener );
}
- bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
- const ::Point& rPt,
- const ::Size& rSz,
- const GraphicAttr& rAttr ) const
+ void SAL_CALL SpriteCanvas::removeVetoableChangeListener( const ::rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& xListener ) throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
{
tools::LocalGuard aGuard;
-
- mbSurfaceDirty = true;
-
- return maCanvasHelper.repaint( rGrf, rPt, rSz, rAttr );
+ maPropHelper.removeVetoableChangeListener( aPropertyName,
+ xListener );
}
-
}
namespace