update dev300-m58
[ooovba.git] / applied_patches / 0543-canvas-directx-lostdevice-fix.diff
blob97424f2a99e76817f766a7af068ccabeef8a34c1
1 ? wntmsci11
2 diff -u -p -r1.5 dx_9rm.cxx
3 --- canvas/source/directx/dx_9rm.cxx 24 Jun 2008 10:30:05 -0000 1.5
4 +++ canvas/source/directx/dx_9rm.cxx 10 Dec 2008 14:51:17 -0000
5 @@ -53,6 +53,7 @@
6 #include <canvas/debug.hxx>
7 #include <canvas/verbosetrace.hxx>
8 #include <tools/diagnose_ex.h>
9 +#include <osl/thread.h>
11 #include <canvas/elapsedtime.hxx>
12 #include <canvas/canvastools.hxx>
13 @@ -956,11 +957,43 @@ namespace dxcanvas
15 if(hr != D3DERR_DEVICELOST)
16 return false;
17 - hr = mpDevice->Reset(&mad3dpp);
18 - if(SUCCEEDED(hr))
19 - return true;
20 - if(hr == D3DERR_DEVICELOST)
21 - return true;
23 + // interestingly enough, sometimes the Reset() below
24 + // *still* causes DeviceLost errors. So, cycle until
25 + // DX was kind enough to really reset the device...
26 + do
27 + {
28 + mpVertexBuffer.reset();
29 + hr = mpDevice->Reset(&mad3dpp);
30 + if(SUCCEEDED(hr))
31 + {
32 + IDirect3DVertexBuffer9 *pVB(NULL);
33 + DWORD aFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
34 + if( FAILED(mpDevice->CreateVertexBuffer(sizeof(dxvertex)*maNumVertices,
35 + D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,
36 + aFVF,
37 + D3DPOOL_DEFAULT,
38 + &pVB,
39 + NULL)) )
40 + {
41 + throw lang::NoSupportException(
42 + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
43 + "Could not create DirectX device - out of memory!")),NULL);
44 + }
45 + mpVertexBuffer=COMReference<IDirect3DVertexBuffer9>(pVB);
47 + // retry after the restore
48 + if(SUCCEEDED(mpSwapChain->Present(&aRect,&aRect,NULL,NULL,0)))
49 + return true;
50 + }
52 + TimeValue aTimeout;
53 + aTimeout.Seconds=1;
54 + aTimeout.Nanosec=0;
55 + osl_waitThread(&aTimeout);
56 + }
57 + while(hr == D3DERR_DEVICELOST);
59 return false;
62 diff -u -p -r1.4 dx_surfacegraphics.cxx
63 --- canvas/source/directx/dx_surfacegraphics.cxx 24 Jun 2008 10:39:29 -0000 1.4
64 +++ canvas/source/directx/dx_surfacegraphics.cxx 10 Dec 2008 14:51:25 -0000
65 @@ -34,6 +34,8 @@
66 #include "dx_surfacegraphics.hxx"
67 #include "dx_impltools.hxx"
69 +using namespace ::com::sun::star;
71 namespace dxcanvas
73 namespace
74 @@ -75,11 +77,12 @@ namespace dxcanvas
75 tools::setupGraphics( *pGraphics );
76 pRet.reset(pGraphics,
77 GraphicsDeleter(rSurface, aHDC));
78 + return pRet;
80 else
81 rSurface->ReleaseDC( aHDC );
84 - return pRet;
85 + throw uno::RuntimeException();