mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Use RAII for more TextureClient locking cases. (bug 1222863 part 2, r=nical)
This commit is contained in:
parent
f9923890d2
commit
5a26bddd1f
@ -98,22 +98,20 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
bufferCreated = true;
|
||||
}
|
||||
|
||||
if (!mBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) {
|
||||
mBuffer = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
bool updated = false;
|
||||
{
|
||||
// Restrict drawTarget to a scope so that terminates before Unlock.
|
||||
RefPtr<DrawTarget> target =
|
||||
mBuffer->BorrowDrawTarget();
|
||||
TextureClientAutoLock autoLock(mBuffer, OpenMode::OPEN_WRITE_ONLY);
|
||||
if (!autoLock.Succeeded()) {
|
||||
mBuffer = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> target = mBuffer->BorrowDrawTarget();
|
||||
if (target) {
|
||||
aLayer->UpdateTarget(target);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
mBuffer->Unlock();
|
||||
|
||||
if (bufferCreated && !AddTextureClient(mBuffer)) {
|
||||
mBuffer = nullptr;
|
||||
@ -286,7 +284,9 @@ TexClientFromReadback(SharedSurface* src, ISurfaceAllocator* allocator,
|
||||
return nullptr;
|
||||
|
||||
// With a texClient, we can lock for writing.
|
||||
MOZ_ALWAYS_TRUE( texClient->Lock(OpenMode::OPEN_WRITE) );
|
||||
TextureClientAutoLock autoLock(texClient, OpenMode::OPEN_WRITE);
|
||||
DebugOnly<bool> succeeded = autoLock.Succeeded();
|
||||
MOZ_ASSERT(succeeded, "texture should have locked");
|
||||
|
||||
uint8_t* lockedBytes = texClient->GetLockedData();
|
||||
|
||||
@ -318,8 +318,6 @@ TexClientFromReadback(SharedSurface* src, ISurfaceAllocator* allocator,
|
||||
|
||||
texClient->RemoveFlags(TextureFlags::RB_SWAPPED);
|
||||
}
|
||||
|
||||
texClient->Unlock();
|
||||
}
|
||||
|
||||
return texClient.forget();
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "gfxUtils.h" // for gfxUtils
|
||||
#include "ipc/ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget, Factory
|
||||
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
||||
@ -570,33 +571,30 @@ ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
|
||||
|
||||
// We need to ensure that we lock these two buffers in the same
|
||||
// order as the compositor to prevent deadlocks.
|
||||
if (!mFrontClient->Lock(OpenMode::OPEN_READ_ONLY)) {
|
||||
TextureClientAutoLock frontLock(mFrontClient, OpenMode::OPEN_READ_ONLY);
|
||||
if (!frontLock.Succeeded()) {
|
||||
return;
|
||||
}
|
||||
if (mFrontClientOnWhite &&
|
||||
!mFrontClientOnWhite->Lock(OpenMode::OPEN_READ_ONLY)) {
|
||||
mFrontClient->Unlock();
|
||||
return;
|
||||
}
|
||||
{
|
||||
// Restrict the DrawTargets and frontBuffer to a scope to make
|
||||
// sure there is no more external references to the DrawTargets
|
||||
// when we Unlock the TextureClients.
|
||||
RefPtr<SourceSurface> surf = mFrontClient->BorrowDrawTarget()->Snapshot();
|
||||
RefPtr<SourceSurface> surfOnWhite = mFrontClientOnWhite
|
||||
? mFrontClientOnWhite->BorrowDrawTarget()->Snapshot()
|
||||
: nullptr;
|
||||
SourceRotatedBuffer frontBuffer(surf,
|
||||
surfOnWhite,
|
||||
mFrontBufferRect,
|
||||
mFrontBufferRotation);
|
||||
UpdateDestinationFrom(frontBuffer, updateRegion);
|
||||
Maybe<TextureClientAutoLock> frontOnWhiteLock;
|
||||
if (mFrontClientOnWhite) {
|
||||
frontOnWhiteLock.emplace(mFrontClientOnWhite, OpenMode::OPEN_READ_ONLY);
|
||||
if (!frontOnWhiteLock->Succeeded()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mFrontClient->Unlock();
|
||||
if (mFrontClientOnWhite) {
|
||||
mFrontClientOnWhite->Unlock();
|
||||
}
|
||||
// Restrict the DrawTargets and frontBuffer to a scope to make
|
||||
// sure there is no more external references to the DrawTargets
|
||||
// when we Unlock the TextureClients.
|
||||
RefPtr<SourceSurface> surf = mFrontClient->BorrowDrawTarget()->Snapshot();
|
||||
RefPtr<SourceSurface> surfOnWhite = mFrontClientOnWhite
|
||||
? mFrontClientOnWhite->BorrowDrawTarget()->Snapshot()
|
||||
: nullptr;
|
||||
SourceRotatedBuffer frontBuffer(surf,
|
||||
surfOnWhite,
|
||||
mFrontBufferRect,
|
||||
mFrontBufferRotation);
|
||||
UpdateDestinationFrom(frontBuffer, updateRegion);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -185,17 +185,20 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
|
||||
data->mYSize, data->mCbCrSize, data->mStereoMode,
|
||||
TextureFlags::DEFAULT | mTextureFlags
|
||||
);
|
||||
if (!texture || !texture->Lock(OpenMode::OPEN_WRITE_ONLY)) {
|
||||
if (!texture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TextureClientAutoLock autoLock(texture, OpenMode::OPEN_WRITE_ONLY);
|
||||
if (!autoLock.Succeeded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool status = texture->AsTextureClientYCbCr()->UpdateYCbCr(*data);
|
||||
MOZ_ASSERT(status);
|
||||
|
||||
texture->Unlock();
|
||||
if (!status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else if (image->GetFormat() == ImageFormat::SURFACE_TEXTURE ||
|
||||
image->GetFormat() == ImageFormat::EGLIMAGE) {
|
||||
gfx::IntSize size = image->GetSize();
|
||||
|
@ -601,7 +601,8 @@ CopyFrontToBack(TextureClient* aFront,
|
||||
TextureClient* aBack,
|
||||
const gfx::IntRect& aRectToCopy)
|
||||
{
|
||||
if (!aFront->Lock(OpenMode::OPEN_READ)) {
|
||||
TextureClientAutoLock frontLock(aFront, OpenMode::OPEN_READ);
|
||||
if (!frontLock.Succeeded()) {
|
||||
gfxCriticalError() << "[Tiling:Client] Failed to lock the tile's front buffer";
|
||||
return false;
|
||||
}
|
||||
@ -613,8 +614,6 @@ CopyFrontToBack(TextureClient* aFront,
|
||||
|
||||
gfx::IntPoint rectToCopyTopLeft = aRectToCopy.TopLeft();
|
||||
aFront->CopyToTextureClient(aBack, &aRectToCopy, &rectToCopyTopLeft);
|
||||
|
||||
aFront->Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user