From b77a18712626bded9e12fb0c26881641965a4cf3 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Mon, 28 Dec 2015 10:46:25 +0100 Subject: [PATCH] Bug 1176024 - Have TextureClient::Lock check that it can expose a DrawTarget when it makes sense. r=Bas --- gfx/layers/client/TextureClient.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 3e2646111d6..13778783481 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -363,6 +363,15 @@ TextureClient::Lock(OpenMode aMode) mIsLocked = mData->Lock(aMode, mReleaseFenceHandle.IsValid() ? &mReleaseFenceHandle : nullptr); mOpenMode = aMode; + if (mIsLocked && CanExposeDrawTarget() && (aMode & OpenMode::OPEN_WRITE) && NS_IsMainThread()) { + if (!BorrowDrawTarget()) { + // Failed to get a DrawTarget, means we won't be able to write into the + // texture, might as well fail now. + Unlock(); + return false; + } + } + return mIsLocked; }