mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 971744 - Move checks from GetAsDrawTarget to Lock in D3D9 TextureClient. r=mattwoodrow
This commit is contained in:
parent
52f8916e46
commit
7d5856737b
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user