diff options
Diffstat (limited to 'canvas/source/directx/dx_9rm.cxx')
-rw-r--r-- | canvas/source/directx/dx_9rm.cxx | 109 |
1 files changed, 51 insertions, 58 deletions
diff --git a/canvas/source/directx/dx_9rm.cxx b/canvas/source/directx/dx_9rm.cxx index 2dcebf36521c..1f58f2bd8349 100644 --- a/canvas/source/directx/dx_9rm.cxx +++ b/canvas/source/directx/dx_9rm.cxx @@ -74,7 +74,7 @@ namespace dxcanvas monitorSupport() : mhLibrary(LoadLibrary("user32.dll")), - mpMonitorFromWindow(NULL) + mpMonitorFromWindow(nullptr) { if(mhLibrary) mpMonitorFromWindow = reinterpret_cast<fMonitorFromWindow>( @@ -86,14 +86,14 @@ namespace dxcanvas { if(mhLibrary) FreeLibrary(mhLibrary); - mhLibrary=0; + mhLibrary=nullptr; } HMONITOR MonitorFromWindow( HWND hwnd ) { // return adapter_default in case something went wrong... if(!(mpMonitorFromWindow)) - return HMONITOR(0); + return HMONITOR(nullptr); // MONITOR_DEFAULTTONEAREST const DWORD dwFlags(0x00000002); return mpMonitorFromWindow(hwnd,dwFlags); @@ -127,15 +127,14 @@ namespace dxcanvas public: DXSurface( DXRenderModule& rRenderModule, const ::basegfx::B2ISize& rSize ); - ~DXSurface(); + ~DXSurface() override; - virtual bool selectTexture(); - virtual bool isValid(); + virtual bool selectTexture() override; + virtual bool isValid() override; virtual bool update( const ::basegfx::B2IPoint& rDestPos, const ::basegfx::B2IRange& rSourceRect, - ::canvas::IColorBuffer& rSource ); + ::canvas::IColorBuffer& rSource ) override; virtual ::basegfx::B2IVector getSize(); - COMReference<IDirect3DTexture9> getTexture() const; private: /// Guard local methods against concurrent access to RenderModule @@ -168,27 +167,27 @@ namespace dxcanvas { public: explicit DXRenderModule( const vcl::Window& rWindow ); - ~DXRenderModule(); + ~DXRenderModule() override; - virtual void lock() const { maMutex.acquire(); } - virtual void unlock() const { maMutex.release(); } + virtual void lock() const override { maMutex.acquire(); } + virtual void unlock() const override { maMutex.release(); } virtual COMReference<IDirect3DSurface9> - createSystemMemorySurface( const ::basegfx::B2IVector& rSize ); - virtual void disposing(); - virtual HWND getHWND() const { return mhWnd; } - virtual void screenShot(); + createSystemMemorySurface( const ::basegfx::B2IVector& rSize ) override; + virtual void disposing() override; + virtual HWND getHWND() const override { return mhWnd; } + virtual void screenShot() override; virtual bool flip( const ::basegfx::B2IRectangle& rUpdateArea, - const ::basegfx::B2IRectangle& rCurrWindowArea ); + const ::basegfx::B2IRectangle& rCurrWindowArea ) override; - virtual void resize( const ::basegfx::B2IRange& rect ); - virtual ::basegfx::B2IVector getPageSize(); - virtual ::std::shared_ptr<canvas::ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ); - virtual void beginPrimitive( PrimitiveType eType ); - virtual void endPrimitive(); - virtual void pushVertex( const ::canvas::Vertex& vertex ); - virtual bool isError(); + virtual void resize( const ::basegfx::B2IRange& rect ) override; + virtual ::basegfx::B2IVector getPageSize() override; + virtual ::std::shared_ptr<canvas::ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) override; + virtual void beginPrimitive( PrimitiveType eType ) override; + virtual void endPrimitive() override; + virtual void pushVertex( const ::canvas::Vertex& vertex ) override; + virtual bool isError() override; COMReference<IDirect3DDevice9> getDevice() { return mpDevice; } @@ -226,7 +225,7 @@ namespace dxcanvas ::basegfx::B2IVector maPageSize; D3DPRESENT_PARAMETERS mad3dpp; - inline bool isDisposed() const { return (mhWnd==NULL); } + inline bool isDisposed() const { return (mhWnd==nullptr); } struct dxvertex { @@ -268,7 +267,7 @@ namespace dxcanvas DXSurface::DXSurface( DXRenderModule& rRenderModule, const ::basegfx::B2ISize& rSize ) : mrRenderModule(rRenderModule), - mpTexture(NULL), + mpTexture(nullptr), maSize() { ImplRenderModuleGuard aGuard( mrRenderModule ); @@ -291,13 +290,13 @@ namespace dxcanvas COMReference<IDirect3DDevice9> pDevice(rRenderModule.getDevice()); - IDirect3DTexture9 *pTexture(NULL); + IDirect3DTexture9 *pTexture(nullptr); if(FAILED(pDevice->CreateTexture( rSize.getX(), rSize.getY(), 1,0,D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, - &pTexture,NULL))) + &pTexture,nullptr))) return; mpTexture=COMReference<IDirect3DTexture9>(pTexture); @@ -389,7 +388,7 @@ namespace dxcanvas pImage += rSourceRect.getMinX()*nSourceBytesPerPixel; // calculate the destination memory address - sal_uInt8 *pDst = (sal_uInt8*)aLockedRect.pBits; + sal_uInt8 *pDst = static_cast<sal_uInt8*>(aLockedRect.pBits); const sal_uInt32 nNumBytesToCopy( static_cast<sal_uInt32>( @@ -397,7 +396,7 @@ namespace dxcanvas nSourceBytesPerPixel); const sal_uInt64 nNumLines(rSourceRect.getHeight()); - for(sal_uInt32 i=0; i<nNumLines; ++i) + for(sal_uInt64 i=0; i<nNumLines; ++i) { memcpy(pDst,pImage,nNumBytesToCopy); @@ -430,7 +429,7 @@ namespace dxcanvas pImage += rSourceRect.getMinX()*nSourceBytesPerPixel; // calculate the destination memory address - sal_uInt8 *pDst = (sal_uInt8*)aLockedRect.pBits; + sal_uInt8 *pDst = static_cast<sal_uInt8*>(aLockedRect.pBits); const sal_Int32 nNumLines( sal::static_int_cast<sal_Int32>(rSourceRect.getHeight())); @@ -479,17 +478,11 @@ namespace dxcanvas return maSize; } - COMReference<IDirect3DTexture9> DXSurface::getTexture() const - { - return mpTexture; - } - - // DXRenderModule::DXRenderModule DXRenderModule::DXRenderModule( const vcl::Window& rWindow ) : - mhWnd(0), + mhWnd(nullptr), mpDevice(), mpDirect3D9(), mpSwapChain(), @@ -537,14 +530,14 @@ namespace dxcanvas } maPageSize=aPageSize; - IDirect3DVertexBuffer9 *pVB(NULL); + IDirect3DVertexBuffer9 *pVB(nullptr); DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1); if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, aFVF, D3DPOOL_DEFAULT, &pVB, - NULL)) ) + nullptr)) ) { throw lang::NoSupportException( "Could not create DirectX device - out of memory!" ); @@ -573,7 +566,7 @@ namespace dxcanvas mpTexture.reset(); mpWindow.disposeAndClear(); - mhWnd=NULL; + mhWnd=nullptr; // refrain from releasing the DX9 objects. We're the only // ones holding references to them, and it might be @@ -603,14 +596,14 @@ namespace dxcanvas mpWindow->SetParentClipMode(ParentClipMode::NoClip); // the system child window must not clear its background - mpWindow->EnableEraseBackground( sal_False ); + mpWindow->EnableEraseBackground( false ); mpWindow->SetControlForeground(); mpWindow->SetControlBackground(); const SystemEnvData *pData = mpWindow->GetSystemData(); const HWND hwnd(reinterpret_cast<HWND>(pData->hWnd)); - mhWnd = const_cast<HWND>(hwnd); + mhWnd = hwnd; ENSURE_OR_THROW( IsWindow( reinterpret_cast<HWND>(mhWnd) ), "DXRenderModule::create() No valid HWND given." ); @@ -760,7 +753,7 @@ namespace dxcanvas // now create the device, first try hardware vertex processing, // then software vertex processing. if both queries fail, we give up // and indicate failure. - IDirect3DDevice9 *pDevice(NULL); + IDirect3DDevice9 *pDevice(nullptr); if(FAILED(mpDirect3D9->CreateDevice(aAdapter, D3DDEVTYPE_HAL, mhWnd, @@ -781,7 +774,7 @@ namespace dxcanvas mpDevice=COMReference<IDirect3DDevice9>(pDevice); // After CreateDevice, the first swap chain already exists, so just get it... - IDirect3DSwapChain9 *pSwapChain(NULL); + IDirect3DSwapChain9 *pSwapChain(nullptr); pDevice->GetSwapChain(0,&pSwapChain); mpSwapChain=COMReference<IDirect3DSwapChain9>(pSwapChain); if( !mpSwapChain.is() ) @@ -792,10 +785,10 @@ namespace dxcanvas // please note that this is only possible since we created the // backbuffer with copy semantics [the content is preserved after // calls to Present()], which is an unnecessarily expensive operation. - LPDIRECT3DSURFACE9 pBackBuffer = NULL; + LPDIRECT3DSURFACE9 pBackBuffer = nullptr; mpSwapChain->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer); mpDevice->SetRenderTarget( 0, pBackBuffer ); - mpDevice->Clear(0,NULL,D3DCLEAR_TARGET,0,1.0f,0); + mpDevice->Clear(0,nullptr,D3DCLEAR_TARGET,0,1.0f,0); pBackBuffer->Release(); return true; @@ -808,19 +801,19 @@ namespace dxcanvas COMReference<IDirect3DSurface9> DXRenderModule::createSystemMemorySurface( const ::basegfx::B2IVector& rSize ) { if(isDisposed()) - return COMReference<IDirect3DSurface9>(NULL); + return COMReference<IDirect3DSurface9>(nullptr); // please note that D3DFMT_X8R8G8B8 is the only format we're // able to choose here, since GetDC() doesn't support any // other 32bit-format. - IDirect3DSurface9 *pSurface(NULL); + IDirect3DSurface9 *pSurface(nullptr); if( FAILED(mpDevice->CreateOffscreenPlainSurface( rSize.getX(), rSize.getY(), D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &pSurface, - NULL)) ) + nullptr)) ) { throw lang::NoSupportException( "Could not create offscreen surface - out of mem!" ); @@ -852,7 +845,7 @@ namespace dxcanvas rUpdateArea.getMaxX(), rUpdateArea.getMaxY() }; - HRESULT hr(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0)); + HRESULT hr(mpSwapChain->Present(&aRect,&aRect,nullptr,nullptr,0)); if(FAILED(hr)) { if(hr != D3DERR_DEVICELOST) @@ -867,14 +860,14 @@ namespace dxcanvas hr = mpDevice->Reset(&mad3dpp); if(SUCCEEDED(hr)) { - IDirect3DVertexBuffer9 *pVB(NULL); + IDirect3DVertexBuffer9 *pVB(nullptr); DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1); if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, aFVF, D3DPOOL_DEFAULT, &pVB, - NULL)) ) + nullptr)) ) { throw lang::NoSupportException( "Could not create DirectX device - out of memory!" ); @@ -882,7 +875,7 @@ namespace dxcanvas mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB); // retry after the restore - if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0))) + if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,nullptr,nullptr,0))) return true; } @@ -951,7 +944,7 @@ namespace dxcanvas // clear before, save resources mpSwapChain.reset(); - IDirect3DSwapChain9 *pSwapChain(NULL); + IDirect3DSwapChain9 *pSwapChain(nullptr); if(FAILED(mpDevice->CreateAdditionalSwapChain(&mad3dpp,&pSwapChain))) return; mpSwapChain=COMReference<IDirect3DSwapChain9>(pSwapChain); @@ -961,10 +954,10 @@ namespace dxcanvas // please note that this is only possible since we created the // backbuffer with copy semantics [the content is preserved after // calls to Present()], which is an unnecessarily expensive operation. - LPDIRECT3DSURFACE9 pBackBuffer = NULL; + LPDIRECT3DSURFACE9 pBackBuffer = nullptr; mpSwapChain->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer); mpDevice->SetRenderTarget( 0, pBackBuffer ); - mpDevice->Clear(0,NULL,D3DCLEAR_TARGET,0,1.0f,0); + mpDevice->Clear(0,nullptr,D3DCLEAR_TARGET,0,1.0f,0); pBackBuffer->Release(); } } @@ -1214,13 +1207,13 @@ namespace dxcanvas maReadIndex = 0; } - dxvertex *vertices(NULL); + dxvertex *vertices(nullptr); const std::size_t nNumVertices( std::min(maNumVertices - maWriteIndex, nSize)); if(FAILED(mpVertexBuffer->Lock(maWriteIndex*nVertexStride, nNumVertices*nVertexStride, - (void **)&vertices, + reinterpret_cast<void **>(&vertices), dwLockFlags))) return; |