? wntmsci11 diff -u -p -r1.5 dx_9rm.cxx --- canvas/source/directx/dx_9rm.cxx 24 Jun 2008 10:30:05 -0000 1.5 +++ canvas/source/directx/dx_9rm.cxx 10 Dec 2008 14:51:17 -0000 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -956,11 +957,43 @@ namespace dxcanvas { if(hr != D3DERR_DEVICELOST) return false; - hr = mpDevice->Reset(&mad3dpp); - if(SUCCEEDED(hr)) - return true; - if(hr == D3DERR_DEVICELOST) - return true; + + // interestingly enough, sometimes the Reset() below + // *still* causes DeviceLost errors. So, cycle until + // DX was kind enough to really reset the device... + do + { + mpVertexBuffer.reset(); + hr = mpDevice->Reset(&mad3dpp); + if(SUCCEEDED(hr)) + { + IDirect3DVertexBuffer9 *pVB(NULL); + DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1); + if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices, + D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, + aFVF, + D3DPOOL_DEFAULT, + &pVB, + NULL)) ) + { + throw lang::NoSupportException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "Could not create DirectX device - out of memory!")),NULL); + } + mpVertexBuffer=COMReference(pVB); + + // retry after the restore + if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0))) + return true; + } + + TimeValue aTimeout; + aTimeout.Seconds=1; + aTimeout.Nanosec=0; + osl_waitThread(&aTimeout); + } + while(hr == D3DERR_DEVICELOST); + return false; } diff -u -p -r1.4 dx_surfacegraphics.cxx --- canvas/source/directx/dx_surfacegraphics.cxx 24 Jun 2008 10:39:29 -0000 1.4 +++ canvas/source/directx/dx_surfacegraphics.cxx 10 Dec 2008 14:51:25 -0000 @@ -34,6 +34,8 @@ #include "dx_surfacegraphics.hxx" #include "dx_impltools.hxx" +using namespace ::com::sun::star; + namespace dxcanvas { namespace @@ -75,11 +77,12 @@ namespace dxcanvas tools::setupGraphics( *pGraphics ); pRet.reset(pGraphics, GraphicsDeleter(rSurface, aHDC)); + return pRet; } else rSurface->ReleaseDC( aHDC ); } - return pRet; + throw uno::RuntimeException(); } }