Bug 971744 - Move checks from GetAsDrawTarget to Lock in D3D9 TextureClient. r=mattwoodrow

This commit is contained in:
Nicolas Silva 2014-02-13 11:45:13 +01:00
parent 52f8916e46
commit 7d5856737b

View File

@ -1274,12 +1274,30 @@ CairoTextureClientD3D9::Lock(OpenMode)
if (!IsValid() || !IsAllocated()) {
return false;
}
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
// If the device has failed then we should not lock the surface,
// even if we could.
mD3D9Surface = nullptr;
return false;
}
if (!mD3D9Surface) {
HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(mD3D9Surface));
if (FAILED(hr)) {
NS_WARNING("Failed to get texture surface level.");
return false;
}
}
mIsLocked = true;
if (mNeedsClear) {
mDrawTarget = GetAsDrawTarget();
mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
mNeedsClear = false;
}
mIsLocked = true;
return true;
}
@ -1318,27 +1336,11 @@ CairoTextureClientD3D9::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
TemporaryRef<gfx::DrawTarget>
CairoTextureClientD3D9::GetAsDrawTarget()
{
MOZ_ASSERT(mIsLocked && mTexture);
MOZ_ASSERT(mIsLocked && mD3D9Surface);
if (mDrawTarget) {
return mDrawTarget;
}
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
// If the device has failed then we should not lock the surface,
// even if we could.
mD3D9Surface = nullptr;
mTexture = nullptr;
return nullptr;
}
if (!mD3D9Surface) {
HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(mD3D9Surface));
if (FAILED(hr)) {
NS_WARNING("Failed to get texture surface level.");
return nullptr;
}
}
if (ContentForFormat(mFormat) == gfxContentType::COLOR) {
mSurface = new gfxWindowsSurface(mD3D9Surface);
if (!mSurface || mSurface->CairoStatus()) {