mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 964794 - Remove extra Lock and minimize DT creation/destruction in D3D11 TextureClient. r=Bas
This commit is contained in:
parent
bbce6c3530
commit
298c0624fc
@ -146,6 +146,7 @@ TextureClientD3D11::TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags
|
||||
: TextureClient(aFlags)
|
||||
, mFormat(aFormat)
|
||||
, mIsLocked(false)
|
||||
, mNeedsClear(false)
|
||||
{}
|
||||
|
||||
TextureClientD3D11::~TextureClientD3D11()
|
||||
@ -159,6 +160,12 @@ TextureClientD3D11::Lock(OpenMode aMode)
|
||||
}
|
||||
MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");
|
||||
LockD3DTexture(mTexture.get());
|
||||
|
||||
if (mNeedsClear) {
|
||||
mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
|
||||
mNeedsClear = false;
|
||||
}
|
||||
|
||||
mIsLocked = true;
|
||||
return true;
|
||||
}
|
||||
@ -169,7 +176,6 @@ TextureClientD3D11::Unlock()
|
||||
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
|
||||
if (mDrawTarget) {
|
||||
mDrawTarget->Flush();
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
UnlockD3DTexture(mTexture.get());
|
||||
mIsLocked = false;
|
||||
@ -184,6 +190,8 @@ TextureClientD3D11::GetAsDrawTarget()
|
||||
return mDrawTarget;
|
||||
}
|
||||
|
||||
// The DrawTarget is created only once, and is only usable between calls
|
||||
// to Lock and Unlock.
|
||||
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, mFormat);
|
||||
return mDrawTarget;
|
||||
}
|
||||
@ -207,13 +215,8 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aFlags & ALLOC_CLEAR_BUFFER) {
|
||||
DebugOnly<bool> locked = Lock(OPEN_WRITE_ONLY);
|
||||
MOZ_ASSERT(locked);
|
||||
RefPtr<DrawTarget> dt = GetAsDrawTarget();
|
||||
dt->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
|
||||
Unlock();
|
||||
}
|
||||
// Defer clearing to the next time we lock to avoid an extra (expensive) lock.
|
||||
mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ protected:
|
||||
RefPtr<gfx::DrawTarget> mDrawTarget;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
bool mIsLocked;
|
||||
bool mNeedsClear;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user