diff options
Diffstat (limited to 'canvas/source/directx/dx_5rm.cxx')
-rw-r--r-- | canvas/source/directx/dx_5rm.cxx | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/canvas/source/directx/dx_5rm.cxx b/canvas/source/directx/dx_5rm.cxx index 000cc41e90ce..4adcb09de4cf 100644 --- a/canvas/source/directx/dx_5rm.cxx +++ b/canvas/source/directx/dx_5rm.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -75,7 +75,7 @@ #include "dx_impltools.hxx" #include <malloc.h> -#if defined(DX_DEBUG_IMAGES) +#if defined(DX_DEBUG_IMAGES) # if OSL_DEBUG_LEVEL > 0 # include <imdebug.h> # undef min @@ -453,8 +453,8 @@ namespace dxcanvas return pDirectDraw2; } - HRESULT WINAPI EnumTextureFormatsCallback( LPDDSURFACEDESC pSurfaceDesc, - LPVOID pContext ) + HRESULT WINAPI EnumTextureFormatsCallback( LPDDSURFACEDESC pSurfaceDesc, + LPVOID pContext ) { // dirty cast of given context back to result ModeSelectContext DDPIXELFORMAT* pResult = (DDPIXELFORMAT*)pContext; @@ -587,7 +587,7 @@ namespace dxcanvas struct ModeSelectContext { DDSURFACEDESC selectedDesc; - ::basegfx::B2ISize requestedSize; + ::basegfx::B2ISize requestedSize; }; /** Query actual size of the device @@ -607,7 +607,7 @@ namespace dxcanvas @return the amount of free surface mem */ - std::size_t getAvailableSurfaceMem( bool bWithAGPMem=true ) const; + std::size_t getAvailableSurfaceMem( bool bWithAGPMem=true ) const; /** Query the amount of memory available for new textures @@ -643,15 +643,15 @@ namespace dxcanvas to serialize access to DirectX's global state, a global mutex is required. */ - static ::osl::Mutex maMutex; + static ::osl::Mutex maMutex; HWND mhWnd; - ::boost::scoped_ptr<SystemChildWindow> mpWindow; - ::basegfx::B2IVector maSize; - - ModeSelectContext maSelectedFullscreenMode; + ::boost::scoped_ptr<SystemChildWindow> mpWindow; + ::basegfx::B2IVector maSize; + + ModeSelectContext maSelectedFullscreenMode; DDPIXELFORMAT maTextureFormat; - + MONITORINFO maMonitorInfo; // monitor info for mpDirectDraw's monitor COMReference<IDirectDraw2> mpDirectDraw; COMReference<IDirectDrawSurface> mpPrimarySurface; @@ -660,23 +660,23 @@ namespace dxcanvas COMReference< IDirect3D2 > mpDirect3D; COMReference< IDirect3DDevice2 > mpDirect3DDevice; - mutable ::canvas::tools::ElapsedTime maLastUpdate; // for the frame counter + mutable ::canvas::tools::ElapsedTime maLastUpdate; // for the frame counter D3DDEVICEDESC maDeviceDesc; - typedef std::vector<canvas::Vertex> vertexCache_t; - vertexCache_t maVertexCache; - std::size_t mnCount; + typedef std::vector<canvas::Vertex> vertexCache_t; + vertexCache_t maVertexCache; + std::size_t mnCount; int mnBeginSceneCount; - - const bool mbPageFlipping; - bool mbHasNoTearingBlt; - bool mbError; - PrimitiveType meType; - - ::canvas::ISurfaceSharedPtr mpTexture; - ::basegfx::B2IVector maPageSize; + + const bool mbPageFlipping; + bool mbHasNoTearingBlt; + bool mbError; + PrimitiveType meType; + + ::canvas::ISurfaceSharedPtr mpTexture; + ::basegfx::B2IVector maPageSize; }; ::osl::Mutex DXRenderModule::maMutex; @@ -685,7 +685,7 @@ namespace dxcanvas // DXSurface::ImplRenderModuleGuard ////////////////////////////////////////////////////////////////////////////////// - inline DXSurface::ImplRenderModuleGuard::ImplRenderModuleGuard( + inline DXSurface::ImplRenderModuleGuard::ImplRenderModuleGuard( DXRenderModule& rRenderModule ) : mrRenderModule( rRenderModule ) { @@ -726,7 +726,7 @@ namespace dxcanvas ////////////////////////////////////////////////////////////////////////////////// DXSurface::DXSurface( DXRenderModule& rRenderModule, - const ::basegfx::B2ISize& rSize ) : + const ::basegfx::B2ISize& rSize ) : mrRenderModule(rRenderModule), mpTexture(NULL), mpSurface(NULL), @@ -747,7 +747,7 @@ namespace dxcanvas return; #endif - ENSURE_ARG_OR_THROW(rSize.getX() > 0 && rSize.getY() > 0, + ENSURE_ARG_OR_THROW(rSize.getX() > 0 && rSize.getY() > 0, "DXSurface::DXSurface(): request for zero-sized surface"); const D3DDEVICEDESC &deviceDesc = rRenderModule.getDeviceDesc(); @@ -839,7 +839,7 @@ namespace dxcanvas return false; } -#if defined(DX_DEBUG_IMAGES) +#if defined(DX_DEBUG_IMAGES) # if OSL_DEBUG_LEVEL > 0 if( mpSurface.is() ) { @@ -847,14 +847,14 @@ namespace dxcanvas rtl_fillMemory( &aSurfaceDesc,sizeof(DDSURFACEDESC),0 ); aSurfaceDesc.dwSize = sizeof(DDSURFACEDESC); - if( SUCCEEDED(mpSurface->Lock( NULL, - &aSurfaceDesc, + if( SUCCEEDED(mpSurface->Lock( NULL, + &aSurfaceDesc, DDLOCK_NOSYSLOCK|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT|DDLOCK_READONLY, NULL)) ) { - imdebug( "rgba w=%d h=%d %p", - aSurfaceDesc.dwWidth, - aSurfaceDesc.dwHeight, + imdebug( "rgba w=%d h=%d %p", + aSurfaceDesc.dwWidth, + aSurfaceDesc.dwHeight, aSurfaceDesc.lpSurface ); mpSurface->Unlock(NULL); @@ -877,7 +877,7 @@ namespace dxcanvas if(!(mpSurface.is())) return false; - if(mpSurface->IsLost() == DDERR_SURFACELOST) + if(mpSurface->IsLost() == DDERR_SURFACELOST) { mpSurface->Restore(); return false; @@ -906,8 +906,8 @@ namespace dxcanvas aSurfaceDesc.dwSize = sizeof(DDSURFACEDESC); // TODO(P2): only lock the region we want to update - if( FAILED(mpSurface->Lock( NULL, - &aSurfaceDesc, + if( FAILED(mpSurface->Lock( NULL, + &aSurfaceDesc, DDLOCK_NOSYSLOCK|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL)) ) return false; @@ -925,7 +925,7 @@ namespace dxcanvas // calculate the destination memory address sal_uInt8 *pDst = ((sal_uInt8*)aSurfaceDesc.lpSurface+ - (rDestPos.getY()*aSurfaceDesc.lPitch) + + (rDestPos.getY()*aSurfaceDesc.lPitch) + (4*rDestPos.getX())); const sal_uInt32 nNumBytesToCopy( @@ -953,7 +953,7 @@ namespace dxcanvas // calculate the destination memory address sal_uInt8 *pDst = ((sal_uInt8*)aSurfaceDesc.lpSurface+ - (rDestPos.getY()*aSurfaceDesc.lPitch) + + (rDestPos.getY()*aSurfaceDesc.lPitch) + (4*rDestPos.getX())); const sal_uInt64 nNumColumns(rSourceRect.getWidth()); @@ -987,7 +987,7 @@ namespace dxcanvas // calculate the destination memory address sal_uInt8 *pDst = ((sal_uInt8*)aSurfaceDesc.lpSurface+ - (rDestPos.getY()*aSurfaceDesc.lPitch) + + (rDestPos.getY()*aSurfaceDesc.lPitch) + (4*rDestPos.getX())); const sal_uInt64 nNumLines(rSourceRect.getHeight()); @@ -1006,7 +1006,7 @@ namespace dxcanvas break; default: - ENSURE_OR_RETURN_FALSE(false, + ENSURE_OR_RETURN_FALSE(false, "DXSurface::update(): Unknown/unimplemented buffer format" ); break; } @@ -1020,7 +1020,7 @@ namespace dxcanvas ////////////////////////////////////////////////////////////////////////////////// // DXSurface::getSize ////////////////////////////////////////////////////////////////////////////////// - + ::basegfx::B2IVector DXSurface::getSize() { return maSize; @@ -1104,19 +1104,19 @@ namespace dxcanvas maVertexCache.reserve(1024); - mpWindow.reset( + mpWindow.reset( new SystemChildWindow( const_cast<Window *>(&rWindow), 0) ); // system child window must not receive mouse events mpWindow->SetMouseTransparent( TRUE ); - + // parent should receive paint messages as well // [PARENTCLIPMODE_NOCLIP], the argument is here // passed as plain numeric value since the stupid // define utilizes a USHORT cast. mpWindow->SetParentClipMode(0x0002); - + // the system child window must not clear its background mpWindow->EnableEraseBackground( FALSE ); @@ -1144,7 +1144,7 @@ namespace dxcanvas MonitorList aMonitorList; fillMonitorList( aMonitorList ); - + mpDirectDraw = COMReference<IDirectDraw2>( createDirectDraw(aMonitorList, maMonitorInfo, mhWnd)); @@ -1192,8 +1192,8 @@ namespace dxcanvas // check for supported primary surface formats... unsigned int nDisplayFormat = getDisplayFormat() & 0x00000FFF; - if(nDisplayFormat != 0x888 && nDisplayFormat != 0x565) - { + if(nDisplayFormat != 0x888 && nDisplayFormat != 0x565) + { // go defunct, and exit VERBOSE_TRACE( "Device::Device(): Unsupported DisplayFormat" ); mpDirectDraw.reset(); @@ -1201,7 +1201,7 @@ namespace dxcanvas } // create primary surface reference - DDSURFACEDESC aSurfaceDesc; + DDSURFACEDESC aSurfaceDesc; IDirectDrawSurface* pPrimarySurface; rtl_fillMemory( &aSurfaceDesc, @@ -1349,7 +1349,7 @@ namespace dxcanvas { // create and setup 3D device // ========================== - LPDIRECT3D2 pDirect3D; + LPDIRECT3D2 pDirect3D; if( FAILED( mpDirectDraw->QueryInterface( IID_IDirect3D2, (LPVOID*)&pDirect3D ) ) ) { // go defunct, and exit @@ -1361,8 +1361,8 @@ namespace dxcanvas LPDIRECT3DDEVICE2 pDirect3DDevice; // try HW-accelerated device first - if( FAILED(mpDirect3D->CreateDevice( IID_IDirect3DHALDevice, - mpBackBufferSurface.get(), + if( FAILED(mpDirect3D->CreateDevice( IID_IDirect3DHALDevice, + mpBackBufferSurface.get(), &pDirect3DDevice )) ) { // no HW 3D support - go defunct, and exit @@ -1376,7 +1376,7 @@ namespace dxcanvas rtl_fillMemory(&aHELDeviceDesc,sizeof(aHELDeviceDesc),0); maDeviceDesc.dwSize = sizeof(maDeviceDesc); aHELDeviceDesc.dwSize = sizeof(aHELDeviceDesc); - if(FAILED(pDirect3DDevice->GetCaps(&maDeviceDesc,&aHELDeviceDesc))) + if(FAILED(pDirect3DDevice->GetCaps(&maDeviceDesc,&aHELDeviceDesc))) { // go defunct, and exit VERBOSE_TRACE( "Device::setup3DDevice(): GetCaps() for Direct3DDevice failed" ); @@ -1404,7 +1404,7 @@ namespace dxcanvas else if(maTextureFormat.dwBBitMask != 0x000000FF) bSupportedFormat = false; - if(bSupportedFormat) + if(bSupportedFormat) { VERBOSE_TRACE( "Device::setup3DDevice(): chose texture format dwRGBBitCount %d, dwRBitMask %x, " "dwGBitMask %x, dwBBitMask %x and dwRGBAlphaBitMask %x. The texture uses %s alpha.", @@ -1414,11 +1414,11 @@ namespace dxcanvas maTextureFormat.dwBBitMask, maTextureFormat.dwRGBAlphaBitMask, maTextureFormat.dwFlags & DDPF_ALPHAPREMULT ? "premultiplied" : "non-premultiplied" ); - + // setup the device (with as much as we can possibly do here) // ========================================================== - LPDIRECT3DVIEWPORT2 pViewport; + LPDIRECT3DVIEWPORT2 pViewport; if( SUCCEEDED(mpDirect3D->CreateViewport( &pViewport, NULL )) ) { @@ -1500,8 +1500,8 @@ namespace dxcanvas bool DXRenderModule::queryCaps() { - DDCAPS aHWCaps; - DDCAPS aHELCaps; + DDCAPS aHWCaps; + DDCAPS aHELCaps; rtl_fillMemory( &aHWCaps, sizeof(aHWCaps), 0 ); @@ -1519,12 +1519,12 @@ namespace dxcanvas mbHasNoTearingBlt = aHWCaps.dwFXCaps & DDBLTFX_NOTEARING; VERBOSE_TRACE( "dxcanvas initialization: %d bytes VRAM free for surfaces (%d with AGP mem), " - "%d bytes VRAM free for textures (%d with AGP mem)", + "%d bytes VRAM free for textures (%d with AGP mem)", getAvailableSurfaceMem( false ), getAvailableSurfaceMem( true ), getAvailableTextureMem( false ), getAvailableTextureMem( true ) ); - + return true; } @@ -1560,7 +1560,7 @@ namespace dxcanvas // DXRenderModule::getDisplayFormat ////////////////////////////////////////////////////////////////////////////////// - unsigned int DXRenderModule::getDisplayFormat() const + unsigned int DXRenderModule::getDisplayFormat() const { unsigned int nFormat; nFormat = ::canvas::tools::bitcount32(maSelectedFullscreenMode.selectedDesc.ddpfPixelFormat.dwRGBAlphaBitMask)<<12; @@ -1582,7 +1582,7 @@ namespace dxcanvas std::size_t nRes( 0 ); DDSCAPS aSurfaceCaps; - DWORD nTotal, nFree; + DWORD nTotal, nFree; // real VRAM (const_cast, since GetAvailableVidMem is non-const) aSurfaceCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM; @@ -1597,7 +1597,7 @@ namespace dxcanvas aSurfaceCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM; if( FAILED(const_cast<IDirectDraw2&>(*mpDirectDraw).GetAvailableVidMem( &aSurfaceCaps, &nTotal, &nFree )) ) return 0; - + nRes += nFree; } @@ -1616,7 +1616,7 @@ namespace dxcanvas std::size_t nRes( 0 ); DDSCAPS aSurfaceCaps; - DWORD nTotal, nFree; + DWORD nTotal, nFree; // TODO(F1): Check if flags are applicable @@ -1633,7 +1633,7 @@ namespace dxcanvas aSurfaceCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM; if( FAILED(const_cast<IDirectDraw2&>(*mpDirectDraw).GetAvailableVidMem( &aSurfaceCaps, &nTotal, &nFree )) ) return 0; - + nRes += nFree; } @@ -1651,13 +1651,13 @@ namespace dxcanvas { POINT aPoint = { 0, 0 }; ClientToScreen( mhWnd, &aPoint ); - + // i52230 make sure given screen coordinate is relative to // this monitor's area (the device rendering is always // contained to a single monitor) aPoint.x -= maMonitorInfo.rcMonitor.left; aPoint.y -= maMonitorInfo.rcMonitor.top; - + io_rDestPos.setX( io_rDestPos.getX() + aPoint.x ); io_rDestPos.setY( io_rDestPos.getY() + aPoint.y ); @@ -1685,7 +1685,7 @@ namespace dxcanvas COMReference<IDirectDrawSurface> DXRenderModule::createSystemMemorySurface( const ::basegfx::B2IVector& rSize ) { - DDSURFACEDESC aSurfaceDesc; + DDSURFACEDESC aSurfaceDesc; IDirectDrawSurface* pSurface; aSurfaceDesc.dwSize = sizeof(DDSURFACEDESC); @@ -1696,7 +1696,7 @@ namespace dxcanvas rtl_copyMemory( &aSurfaceDesc.ddpfPixelFormat, &maTextureFormat, sizeof(DDPIXELFORMAT) ); aSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - + HRESULT nRes = mpDirectDraw->CreateSurface(&aSurfaceDesc, &pSurface, NULL); if(FAILED(nRes)) return COMReference<IDirectDrawSurface>(NULL); @@ -1740,7 +1740,7 @@ namespace dxcanvas renderMemAvailable(); #endif VERBOSE_TRACE( "Device::flip(): Using true page flipping" ); - + // use true page flipping. Hopefully, the 3D hardware // is flushed on this flip call (rumours have it that // way), otherwise, perform the Lock hack as for the @@ -1775,7 +1775,7 @@ namespace dxcanvas // target (the backbuffer in this case). OTOH, I've // found that this tends to degrade performance // significantly on complying cards... - + // TODO(P1): Up until rev. 1.3, this method contained // code to make sure the blit will start _immediately_ // after the Blt call. If this is not warranted, wait @@ -1799,14 +1799,14 @@ namespace dxcanvas DDBLTFX* pBltFX = NULL; if( mbHasNoTearingBlt ) { - // Blt can internally schedule for no-tearing - // =========================================== - + // Blt can internally schedule for no-tearing + // =========================================== + rtl_fillMemory( &aBltFx, sizeof(aBltFx), 0 ); aBltFx.dwSize = sizeof(aBltFx); aBltFx.dwDDFX = DDBLTFX_NOTEARING; - + pBltFX = &aBltFx; } @@ -1864,7 +1864,7 @@ namespace dxcanvas // DXRenderModule::validateMainSurfaces ////////////////////////////////////////////////////////////////////////////////// - bool DXRenderModule::validateMainSurfaces() + bool DXRenderModule::validateMainSurfaces() { if(mpPrimarySurface.get()) { if(mpPrimarySurface->IsLost() == DDERR_SURFACELOST) { @@ -1874,20 +1874,20 @@ namespace dxcanvas } if(mpBackBufferSurface.get()) { - if(mpBackBufferSurface->IsLost() == DDERR_SURFACELOST) - { + if(mpBackBufferSurface->IsLost() == DDERR_SURFACELOST) + { // TODO(F1): simply restoring the backbuffer does not // work as expected, we need to re-create everything // from scratch. find out why... //if(SUCCEEDED(mpBackBufferSurface->Restore())) - // return setup3DDevice(); + // return setup3DDevice(); mpBackBufferSurface.reset(); // get us a backbuffer for simulated flipping IDirectDrawSurface* pSurface; - // TODO(P2): Strictly speaking, we don't need a full screen worth of + // TODO(P2): Strictly speaking, we don't need a full screen worth of // backbuffer here. We could also scale dynamically with the current // window size, but this will make it necessary to temporarily have two // buffers while copying from the old to the new one. YMMV. @@ -1950,16 +1950,16 @@ namespace dxcanvas if( mbPageFlipping ) { - // render on top of backbuffer. We have + // render on top of backbuffer. We have // page flipping, anyway, thus this will // cost us nothing. pGraphics = createSurfaceGraphics( mpBackBufferSurface ); } else { - // render FPS directly to front buffer. + // render FPS directly to front buffer. // That saves us another explicit blit, - // and for me, the FPS counter can blink, + // and for me, the FPS counter can blink, // if it likes to... pGraphics = createSurfaceGraphics( mpPrimarySurface ); } @@ -1969,16 +1969,16 @@ namespace dxcanvas // clear background. We might be doing optimized redraws, // and the background under the FPS count will then not be // cleared. - Gdiplus::SolidBrush aBrush( + Gdiplus::SolidBrush aBrush( Gdiplus::Color( 255, 255, 255 ) ); pGraphics->FillRectangle( &aBrush, rPos.X, rPos.Y, 80.0, 20.0 ); } - Gdiplus::SolidBrush aBrush( + Gdiplus::SolidBrush aBrush( Gdiplus::Color( 255, 0, 255 ) ); - Gdiplus::Font aFont( NULL, + Gdiplus::Font aFont( NULL, 16, Gdiplus::FontStyleRegular, Gdiplus::UnitWorld, @@ -2000,7 +2000,7 @@ namespace dxcanvas "DXRenderModule::renderMemAvailable(): within 3D scene" ); const double nSurfaceMem( getAvailableSurfaceMem()/1024 ); - + ::rtl::OUString text( ::rtl::math::doubleToUString( nSurfaceMem, rtl_math_StringFormat_F, 2,'.',NULL,' ') ); @@ -2029,7 +2029,7 @@ namespace dxcanvas renderInfoText( text, Gdiplus::PointF( 0.0, 40) ); - VERBOSE_TRACE( "dxcanvas: %f free surface mem, %f free texture mem", + VERBOSE_TRACE( "dxcanvas: %f free surface mem, %f free texture mem", nSurfaceMem, nTexMem ); } @@ -2044,7 +2044,7 @@ namespace dxcanvas 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,' ') ); @@ -2056,9 +2056,9 @@ namespace dxcanvas text += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM (" fps")); renderInfoText( text, - Gdiplus::PointF() ); + Gdiplus::PointF() ); - VERBOSE_TRACE( "dxcanvas: %f FPS", + VERBOSE_TRACE( "dxcanvas: %f FPS", denominator == 0.0 ? 100.0 : 1.0/denominator ); } @@ -2112,7 +2112,7 @@ namespace dxcanvas if(mpTexture.use_count() == 1) return mpTexture; - return ::canvas::ISurfaceSharedPtr( + return ::canvas::ISurfaceSharedPtr( new DXSurface(*this, aSize) ); } @@ -2265,7 +2265,7 @@ namespace dxcanvas maVertexCache.clear(); - mbError |= FAILED(mpDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, + mbError |= FAILED(mpDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DVT_TLVERTEX, (LPVOID)vertices, size, |