diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-06-24 10:00:24 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-06-24 10:00:24 +0000 |
commit | 24d338c3823352803c229c7cfe3127beef8e06f3 (patch) | |
tree | 81a7d90ca288fb5f5738c80c5754182cde10e0bc /canvas/source/vcl | |
parent | 29e5814277abb11cfe8e2aff8a49c86230588b56 (diff) |
INTEGRATION: CWS canvas05 (1.5.56); FILE MERGED
2008/06/23 13:49:27 thb 1.5.56.5: RESYNC: (1.6-1.7); FILE MERGED
2008/06/03 15:13:47 thb 1.5.56.4: #i85116# Change default fill rule for polygons generated from vclcanvas
2008/04/21 07:28:14 thb 1.5.56.3: RESYNC: (1.5-1.6); FILE MERGED
2007/12/20 22:18:59 thb 1.5.56.2: #i81092# #i78888# #i78925# #i79258# #i79437# #i84784# Large canvas rework, completing various areas such as color spaces, bitmap data access, true sprite and non-sprite implementations, and upstreaming the canvas parts of rodos emf+ rendering
2007/10/01 13:02:04 thb 1.5.56.1: #i78888# #i78925# #i79258# #i79437# Merge from CWS picom
Diffstat (limited to 'canvas/source/vcl')
-rw-r--r-- | canvas/source/vcl/devicehelper.cxx | 193 |
1 files changed, 80 insertions, 113 deletions
diff --git a/canvas/source/vcl/devicehelper.cxx b/canvas/source/vcl/devicehelper.cxx index d83fda6e9690..853ae52c32c8 100644 --- a/canvas/source/vcl/devicehelper.cxx +++ b/canvas/source/vcl/devicehelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: devicehelper.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.8 $ * * This file is part of OpenOffice.org. * @@ -32,12 +32,14 @@ #include "precompiled_canvas.hxx" #include <canvas/debug.hxx> +#include <tools/diagnose_ex.h> #include <canvas/canvastools.hxx> -#include <canvas/base/linepolypolygonbase.hxx> +#include <rtl/instance.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/canvastools.hxx> #include <basegfx/tools/canvastools.hxx> +#include <basegfx/tools/unopolypolygon.hxx> #include "devicehelper.hxx" #include "spritecanvas.hxx" @@ -50,52 +52,40 @@ using namespace ::com::sun::star; namespace vclcanvas { DeviceHelper::DeviceHelper() : - mpSpriteCanvas(NULL), - mpBackBuffer() - { - } + mpOutDev() + {} - void DeviceHelper::init( Window& rOutputWindow, - SpriteCanvas& rSpriteCanvas ) + void DeviceHelper::init( const OutDevProviderSharedPtr& rOutDev ) { - rSpriteCanvas.setWindow( - uno::Reference<awt::XWindow2>( - VCLUnoHelper::GetInterface(&rOutputWindow), - uno::UNO_QUERY_THROW) ); - - mpOutputWindow = &rOutputWindow; - mpSpriteCanvas = &rSpriteCanvas; - rOutputWindow.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | rOutputWindow.GetAntialiasing() ); - - // setup back buffer - mpBackBuffer.reset( new BackBuffer( rOutputWindow ) ); - mpBackBuffer->setSize( rOutputWindow.GetOutputSizePixel() ); + mpOutDev = rOutDev; } geometry::RealSize2D DeviceHelper::getPhysicalResolution() { - if( !mpOutputWindow ) + if( !mpOutDev ) 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 ); + OutputDevice& rOutDev = mpOutDev->getOutDev(); + const MapMode aOldMapMode( rOutDev.GetMapMode() ); + rOutDev.SetMapMode( MapMode(MAP_MM) ); + const Size aPixelSize( rOutDev.LogicToPixel(Size(1,1)) ); + rOutDev.SetMapMode( aOldMapMode ); return ::vcl::unotools::size2DFromSize( aPixelSize ); } geometry::RealSize2D DeviceHelper::getPhysicalSize() { - if( !mpOutputWindow ) + if( !mpOutDev ) 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 ); + OutputDevice& rOutDev = mpOutDev->getOutDev(); + const MapMode aOldMapMode( rOutDev.GetMapMode() ); + rOutDev.SetMapMode( MapMode(MAP_MM) ); + const Size aLogSize( rOutDev.PixelToLogic(rOutDev.GetOutputSizePixel()) ); + rOutDev.SetMapMode( aOldMapMode ); return ::vcl::unotools::size2DFromSize( aLogSize ); } @@ -104,37 +94,46 @@ namespace vclcanvas const uno::Reference< rendering::XGraphicDevice >& , const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points ) { - if( !mpOutputWindow ) - return uno::Reference< rendering::XLinePolyPolygon2D >(); // we're disposed + uno::Reference< rendering::XLinePolyPolygon2D > xPoly; + if( !mpOutDev ) + return xPoly; // we're disposed + + xPoly.set( new ::basegfx::unotools::UnoPolyPolygon( + ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points ) ) ); + // vcl only handles even_odd polygons + xPoly->setFillRule(rendering::FillRule_EVEN_ODD); - return uno::Reference< rendering::XLinePolyPolygon2D >( - new ::canvas::LinePolyPolygonBase( - ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points ) ) ); + return xPoly; } uno::Reference< rendering::XBezierPolyPolygon2D > DeviceHelper::createCompatibleBezierPolyPolygon( const uno::Reference< rendering::XGraphicDevice >& , const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points ) { - if( !mpOutputWindow ) - return uno::Reference< rendering::XBezierPolyPolygon2D >(); // we're disposed + uno::Reference< rendering::XBezierPolyPolygon2D > xPoly; + if( !mpOutDev ) + return xPoly; // we're disposed - return uno::Reference< rendering::XBezierPolyPolygon2D >( - new ::canvas::LinePolyPolygonBase( - ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) ); + xPoly.set( new ::basegfx::unotools::UnoPolyPolygon( + ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) ); + // vcl only handles even_odd polygons + xPoly->setFillRule(rendering::FillRule_EVEN_ODD); + + return xPoly; } uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleBitmap( - const uno::Reference< rendering::XGraphicDevice >& , - const geometry::IntegerSize2D& size ) + const uno::Reference< rendering::XGraphicDevice >& rDevice, + const geometry::IntegerSize2D& size ) { - if( !mpSpriteCanvas ) + if( !mpOutDev ) return uno::Reference< rendering::XBitmap >(); // we're disposed return uno::Reference< rendering::XBitmap >( new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size), false, - mpSpriteCanvas ) ); + *rDevice.get(), + mpOutDev ) ); } uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileBitmap( @@ -145,15 +144,17 @@ namespace vclcanvas } uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleAlphaBitmap( - const uno::Reference< rendering::XGraphicDevice >& , - const geometry::IntegerSize2D& size ) + const uno::Reference< rendering::XGraphicDevice >& rDevice, + const geometry::IntegerSize2D& size ) { - if( !mpSpriteCanvas ) + if( !mpOutDev ) return uno::Reference< rendering::XBitmap >(); // we're disposed - return uno::Reference< rendering::XBitmap >( new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size), - true, - mpSpriteCanvas ) ); + return uno::Reference< rendering::XBitmap >( + new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size), + true, + *rDevice.get(), + mpOutDev ) ); } uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileAlphaBitmap( @@ -165,85 +166,63 @@ namespace vclcanvas sal_Bool DeviceHelper::hasFullScreenMode() { - // TODO(F3): offer fullscreen mode the XCanvas way return false; } sal_Bool DeviceHelper::enterFullScreenMode( sal_Bool bEnter ) { (void)bEnter; - - // TODO(F3): offer fullscreen mode the XCanvas way return false; } - ::sal_Int32 DeviceHelper::createBuffers( ::sal_Int32 nBuffers ) - { - (void)nBuffers; - - // TODO(F3): implement XBufferStrategy interface. For now, we - // _always_ will have exactly one backbuffer - return 1; - } - - void DeviceHelper::destroyBuffers() - { - // TODO(F3): implement XBufferStrategy interface. For now, we - // _always_ will have exactly one backbuffer - } - - ::sal_Bool DeviceHelper::showBuffer( ::sal_Bool bUpdateAll ) - { - // forward to sprite canvas helper - if( !mpSpriteCanvas ) - return false; - - return mpSpriteCanvas->updateScreen( bUpdateAll ); - } - - ::sal_Bool DeviceHelper::switchBuffer( ::sal_Bool bUpdateAll ) + void DeviceHelper::disposing() { - // no difference for VCL canvas - return showBuffer( bUpdateAll ); + // release all references + mpOutDev.reset(); } - void DeviceHelper::disposing() + uno::Any DeviceHelper::isAccelerated() const { - // release all references - mpSpriteCanvas = NULL; - mpBackBuffer.reset(); + return ::com::sun::star::uno::makeAny(false); } uno::Any DeviceHelper::getDeviceHandle() const { - if( !mpOutputWindow ) + if( !mpOutDev ) return uno::Any(); return uno::makeAny( - reinterpret_cast< sal_Int64 >(mpOutputWindow) ); + reinterpret_cast< sal_Int64 >(&mpOutDev->getOutDev()) ); } uno::Any DeviceHelper::getSurfaceHandle() const { - if( !mpBackBuffer ) - return uno::Any(); + return getDeviceHandle(); + } - return uno::makeAny( - reinterpret_cast< sal_Int64 >(&mpBackBuffer->getOutDev()) ); + namespace + { + struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, + DeviceColorSpace> + { + uno::Reference<rendering::XColorSpace> operator()() + { + return vcl::unotools::createStandardColorSpace(); + } + }; } - void DeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds ) + uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const { - if( mpBackBuffer ) - mpBackBuffer->setSize( ::Size(rBounds.Width, - rBounds.Height) ); + // always the same + return DeviceColorSpace::get(); } void DeviceHelper::dumpScreenContent() const { static sal_uInt32 nFilePostfixCount(0); - if( mpOutputWindow ) + if( mpOutDev ) { String aFilename( String::CreateFromAscii("dbg_frontbuffer") ); aFilename += String::CreateFromInt32(nFilePostfixCount); @@ -252,24 +231,12 @@ namespace vclcanvas SvFileStream aStream( aFilename, STREAM_STD_READWRITE ); const ::Point aEmptyPoint; - bool bOldMap( mpOutputWindow->IsMapModeEnabled() ); - mpOutputWindow->EnableMapMode( FALSE ); - aStream << mpOutputWindow->GetBitmap(aEmptyPoint, - mpOutputWindow->GetOutputSizePixel()); - mpOutputWindow->EnableMapMode( bOldMap ); - - if( mpBackBuffer ) - { - String aFilename2( String::CreateFromAscii("dbg_backbuffer") ); - aFilename2 += String::CreateFromInt32(nFilePostfixCount); - aFilename2 += String::CreateFromAscii(".bmp"); - - SvFileStream aStream2( aFilename2, STREAM_STD_READWRITE ); - - mpBackBuffer->getOutDev().EnableMapMode( FALSE ); - aStream2 << mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, - mpBackBuffer->getOutDev().GetOutputSizePixel()); - } + OutputDevice& rOutDev = mpOutDev->getOutDev(); + bool bOldMap( rOutDev.IsMapModeEnabled() ); + rOutDev.EnableMapMode( FALSE ); + aStream << rOutDev.GetBitmap(aEmptyPoint, + rOutDev.GetOutputSizePixel()); + rOutDev.EnableMapMode( bOldMap ); ++nFilePostfixCount; } |