diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-06-24 09:34:00 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-06-24 09:34:00 +0000 |
commit | 0ceb6f008feb96c9a380fed76a6f0395dc16d9a2 (patch) | |
tree | 2106ce19440c42c692b9a22143825115d676be01 | |
parent | c97765204dea3cc8fa467242decfd6a623bab091 (diff) |
INTEGRATION: CWS canvas05 (1.2.2); FILE MERGED
2008/04/21 07:29:29 thb 1.2.2.5: RESYNC: (1.2-1.3); FILE MERGED
2008/02/08 00:26:39 thb 1.2.2.4: #81092# Finishing cooperative canvas output stuff
2008/01/25 14:27:08 thb 1.2.2.3: Intermediate dump
2008/01/22 00:25:23 thb 1.2.2.2: #i81092# Making gdiplus and dx canvas more independent
2007/12/20 22:18:57 thb 1.2.2.1: #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
-rwxr-xr-x | canvas/source/directx/dx_devicehelper.cxx | 184 |
1 files changed, 43 insertions, 141 deletions
diff --git a/canvas/source/directx/dx_devicehelper.cxx b/canvas/source/directx/dx_devicehelper.cxx index 5cadaf05338b..f08609a3b1f9 100755 --- a/canvas/source/directx/dx_devicehelper.cxx +++ b/canvas/source/directx/dx_devicehelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dx_devicehelper.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.4 $ * * This file is part of OpenOffice.org. * @@ -28,11 +28,16 @@ * ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_canvas.hxx" + #include <ctype.h> // don't ask. msdev breaks otherwise... #include <vcl/window.hxx> +#include <vcl/canvastools.hxx> #include <canvas/debug.hxx> #include <canvas/verbosetrace.hxx> #include <canvas/canvastools.hxx> +#include <tools/diagnose_ex.h> #include <osl/mutex.hxx> #include <cppuhelper/compbase1.hxx> @@ -58,74 +63,32 @@ using namespace ::com::sun::star; namespace dxcanvas { DeviceHelper::DeviceHelper() : - mpSpriteCanvas( NULL ), - mpSurfaceProxyManager(), - mpRenderModule(), - mpBackBuffer() + mpDevice( NULL ), + mnHDC(0) { } - void DeviceHelper::init( Window& rWindow, - SpriteCanvas& rSpriteCanvas, - const awt::Rectangle& rRect, - bool /*bFullscreen*/ ) + void DeviceHelper::init( HDC hdc, + rendering::XGraphicDevice& rDevice ) { - // #i60490# ensure backbuffer has sensible minimal size - const sal_Int32 w( ::std::max(sal_Int32(1),sal_Int32(rRect.Width))); - const sal_Int32 h( ::std::max(sal_Int32(1),sal_Int32(rRect.Height))); - - rSpriteCanvas.setWindow( - uno::Reference<awt::XWindow2>( - VCLUnoHelper::GetInterface(&rWindow), - uno::UNO_QUERY_THROW) ); - - const SystemEnvData *pData = rWindow.GetSystemData(); - const HWND hWnd = reinterpret_cast<HWND>(pData->hWnd); - - ENSURE_AND_THROW( IsWindow( hWnd ), - "DeviceHelper::init No valid HWND given." ); - - mpSpriteCanvas = &rSpriteCanvas; - - try - { - // setup directx rendermodule - mpRenderModule = createRenderModule( rWindow ); - } - catch (...) { - - throw lang::NoSupportException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Could not create DirectX device!") ), - static_cast< ::cppu::OWeakObject* >(&rSpriteCanvas) ); - } - - // create the surfaceproxy manager - mpSurfaceProxyManager = ::canvas::createSurfaceProxyManager( mpRenderModule ); - - // #i60490# ensure backbuffer has sensible minimal size - mpBackBuffer.reset(new DXBitmap( - ::basegfx::B2ISize(w,h), - mpSurfaceProxyManager,mpRenderModule,false)); + mnHDC = hdc; + mpDevice = &rDevice; } void DeviceHelper::disposing() { // release all references - mpBackBuffer.reset(); - mpSurfaceProxyManager.reset(); - mpRenderModule.reset(); - mpSpriteCanvas = NULL; + mnHDC = 0; + mpDevice = NULL; } geometry::RealSize2D DeviceHelper::getPhysicalResolution() { - HWND hwnd( getHwnd() ); - if( !hwnd ) + if( !mpDevice ) return ::canvas::tools::createInfiniteSize2D(); // we're disposed - HDC hDC = GetDC( hwnd ); - ENSURE_AND_THROW( hDC, + HDC hDC = getHDC(); + ENSURE_OR_THROW( hDC, "DeviceHelper::getPhysicalResolution(): cannot retrieve HDC from window" ); const int nHorzRes( GetDeviceCaps( hDC, @@ -133,20 +96,17 @@ namespace dxcanvas const int nVertRes( GetDeviceCaps( hDC, LOGPIXELSY ) ); - ReleaseDC( hwnd, hDC ); - return geometry::RealSize2D( nHorzRes*25.4, nVertRes*25.4 ); } geometry::RealSize2D DeviceHelper::getPhysicalSize() { - HWND hwnd( getHwnd() ); - if( !hwnd ) + if( !mpDevice ) return ::canvas::tools::createInfiniteSize2D(); // we're disposed - HDC hDC=GetDC( hwnd ); - ENSURE_AND_THROW( hDC, + HDC hDC=getHDC(); + ENSURE_OR_THROW( hDC, "DeviceHelper::getPhysicalSize(): cannot retrieve HDC from window" ); const int nHorzSize( GetDeviceCaps( hDC, @@ -154,8 +114,6 @@ namespace dxcanvas const int nVertSize( GetDeviceCaps( hDC, VERTSIZE ) ); - ReleaseDC( hwnd, hDC ); - return geometry::RealSize2D( nHorzSize, nVertSize ); } @@ -164,8 +122,7 @@ namespace dxcanvas const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points ) { - HWND hwnd( getHwnd() ); - if( !hwnd ) + if( !mpDevice ) return uno::Reference< rendering::XLinePolyPolygon2D >(); // we're disposed return uno::Reference< rendering::XLinePolyPolygon2D >( @@ -177,8 +134,7 @@ namespace dxcanvas const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points ) { - HWND hwnd( getHwnd() ); - if( !hwnd ) + if( !mpDevice ) return uno::Reference< rendering::XBezierPolyPolygon2D >(); // we're disposed return uno::Reference< rendering::XBezierPolyPolygon2D >( @@ -190,19 +146,16 @@ namespace dxcanvas const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, const geometry::IntegerSize2D& size ) { - HWND hwnd( getHwnd() ); - if( !hwnd || !mpSpriteCanvas ) + if( !mpDevice ) return uno::Reference< rendering::XBitmap >(); // we're disposed DXBitmapSharedPtr pBitmap( new DXBitmap( ::basegfx::unotools::b2ISizeFromIntegerSize2D(size), - mpSurfaceProxyManager, - mpRenderModule, false)); // create a 24bit RGB system memory surface - return uno::Reference< rendering::XBitmap >(new CanvasBitmap(pBitmap,mpSpriteCanvas)); + return uno::Reference< rendering::XBitmap >(new CanvasBitmap(pBitmap,mpDevice)); } uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileBitmap( @@ -216,19 +169,16 @@ namespace dxcanvas const uno::Reference< rendering::XGraphicDevice >& /*rDevice*/, const geometry::IntegerSize2D& size ) { - HWND hwnd( getHwnd() ); - if( !hwnd || !mpSpriteCanvas ) + if( !mpDevice ) return uno::Reference< rendering::XBitmap >(); // we're disposed DXBitmapSharedPtr pBitmap( new DXBitmap( ::basegfx::unotools::b2ISizeFromIntegerSize2D(size), - mpSurfaceProxyManager, - mpRenderModule, true)); // create a 32bit ARGB system memory surface - return uno::Reference< rendering::XBitmap >(new CanvasBitmap(pBitmap,mpSpriteCanvas)); + return uno::Reference< rendering::XBitmap >(new CanvasBitmap(pBitmap,mpDevice)); } uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileAlphaBitmap( @@ -240,98 +190,50 @@ namespace dxcanvas sal_Bool DeviceHelper::hasFullScreenMode() { - // TODO(F3): offer fullscreen mode the XCanvas way return false; } sal_Bool DeviceHelper::enterFullScreenMode( sal_Bool /*bEnter*/ ) { - // TODO(F3): offer fullscreen mode the XCanvas way return false; } - ::sal_Int32 DeviceHelper::createBuffers( ::sal_Int32 /*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 ) + uno::Any DeviceHelper::isAccelerated() const { - // no difference for VCL canvas - return showBuffer( bUpdateAll ); + return ::com::sun::star::uno::makeAny(false); } uno::Any DeviceHelper::getDeviceHandle() const { - HWND hwnd( getHwnd() ); - if( hwnd ) - return uno::makeAny( reinterpret_cast< sal_Int64 >(hwnd) ); + HDC hdc( getHDC() ); + if( hdc ) + return uno::makeAny( reinterpret_cast< sal_Int64 >(hdc) ); else return uno::Any(); } uno::Any DeviceHelper::getSurfaceHandle() const { - if( !mpRenderModule ) - return uno::Any(); - // TODO(F1): expose DirectDraw object //return mpBackBuffer->getBitmap().get(); return uno::Any(); } - void DeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds ) - { - // #i60490# ensure backbuffer has sensible minimal size - const sal_Int32 x(rBounds.X); - const sal_Int32 y(rBounds.Y); - const sal_Int32 w(::std::max(sal_Int32(1),sal_Int32(rBounds.Width))); - const sal_Int32 h(::std::max(sal_Int32(1),sal_Int32(rBounds.Height))); - - if( mpRenderModule ) - mpRenderModule->resize(::basegfx::B2IRange(x,y,x+w,y+h)); - - resizeBackBuffer(::basegfx::B2ISize(w,h)); - } - - void DeviceHelper::resizeBackBuffer( const ::basegfx::B2ISize& rNewSize ) - { - // disposed? - if(!(mpBackBuffer)) - return; - - mpBackBuffer->resize(rNewSize); - mpBackBuffer->clear(); - } - - HWND DeviceHelper::getHwnd() const + namespace { - if( mpRenderModule ) - return mpRenderModule->getHWND(); - else - return 0; + struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>, + DeviceColorSpace> + { + uno::Reference<rendering::XColorSpace> operator()() + { + return vcl::unotools::createStandardColorSpace(); + } + }; } - void DeviceHelper::dumpScreenContent() const + uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const { - if( mpRenderModule ) - mpRenderModule->screenShot(); + // always the same + return DeviceColorSpace::get(); } } |