diff options
author | Underground78 <underground78@users.sourceforge.net> | 2014-04-24 19:26:26 +0400 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2014-07-18 01:58:39 +0400 |
commit | f6b62a2e2d9f67b755c897ad0d5331a474a8ebec (patch) | |
tree | a932d2afd054bc7f254a8c9682b62b747ff626c6 /src/SubPic/DX7SubPic.cpp | |
parent | 125ae11ac46ca542fcbbec179b5cc9df2eb3607b (diff) |
DX7 Subpic: Avoid resetting the static subpicture when possible.
Also use safer locking.
Diffstat (limited to 'src/SubPic/DX7SubPic.cpp')
-rw-r--r-- | src/SubPic/DX7SubPic.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/SubPic/DX7SubPic.cpp b/src/SubPic/DX7SubPic.cpp index 0cd5c5ac9..cc135168c 100644 --- a/src/SubPic/DX7SubPic.cpp +++ b/src/SubPic/DX7SubPic.cpp @@ -73,7 +73,7 @@ STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic) }
CPoint p = m_rcDirty.TopLeft();
- hr = m_pD3DDev->Load((IDirectDrawSurface7*)pSubPic->GetObject(), &p, (IDirectDrawSurface7*)GetObject(), m_rcDirty, 0);
+ hr = m_pD3DDev->Load((IDirectDrawSurface7*)pSubPic->GetObject(), &p, m_pSurface, m_rcDirty, 0);
return SUCCEEDED(hr) ? S_OK : E_FAIL;
}
@@ -191,7 +191,6 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) m_pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
/*//
-
D3DDEVICEDESC7 d3ddevdesc;
m_pD3DDev->GetCaps(&d3ddevdesc);
if (d3ddevdesc.dpcTriCaps.dwAlphaCmpCaps & D3DPCMPCAPS_LESS)
@@ -200,7 +199,6 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, D3DPCMPCAPS_LESS);
}
-
*///
if (FAILED(hr = m_pD3DDev->BeginScene())) {
@@ -212,8 +210,6 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) pVertices, 4, D3DDP_WAIT);
m_pD3DDev->EndScene();
- //
-
m_pD3DDev->SetTexture(0, nullptr);
return S_OK;
@@ -235,21 +231,26 @@ CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
- if (!pD3DDev) {
- return E_NOINTERFACE;
- }
+ CheckPointer(pD3DDev, E_NOINTERFACE);
CAutoLock cAutoLock(this);
- m_pD3DDev = pD3DDev;
+ HRESULT hr = S_FALSE;
+ if (m_pD3DDev != pD3DDev) {
+ m_pD3DDev = pD3DDev;
+ hr = __super::ChangeDevice(pDev);
+ }
- return __super::ChangeDevice(pDev);
+ return hr;
}
-STDMETHODIMP CDX7SubPicAllocator::SetMaxTextureSize(SIZE MaxTextureSize)
+STDMETHODIMP CDX7SubPicAllocator::SetMaxTextureSize(SIZE maxTextureSize)
{
- m_maxsize = MaxTextureSize;
- SetCurSize(MaxTextureSize);
- return S_OK;
+ CAutoLock cAutoLock(this);
+ if (m_maxsize != maxTextureSize) {
+ m_maxsize = maxTextureSize;
+ }
+
+ return SetCurSize(m_maxsize);
}
// ISubPicAllocatorImpl
@@ -291,7 +292,6 @@ bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic) }
}
-
CComPtr<IDirect3D7> pD3D;
CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
|