Bug 923290 - Don't use the window CGContext as a source with Moz2D. r=Bas

This commit is contained in:
Matt Woodrow 2013-10-10 17:44:09 +13:00
parent a567cd9101
commit 043a00f400
3 changed files with 9 additions and 2 deletions

View File

@ -31,6 +31,8 @@
using namespace mozilla;
using namespace mozilla::gfx;
UserDataKey gfxContext::sDontUseAsSourceKey;
/* This class lives on the stack and allows gfxContext users to easily, and
* performantly get a gfx::Pattern to use for drawing in their current context.
*/
@ -1614,8 +1616,9 @@ gfxContext::PushGroupAndCopyBackground(gfxContentType content)
gfxRect clipRect = GetRoundOutDeviceClipExtents(this);
clipExtents = IntRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
}
if (mDT->GetFormat() == FORMAT_B8G8R8X8 ||
mDT->GetOpaqueRect().Contains(clipExtents)) {
if ((mDT->GetFormat() == FORMAT_B8G8R8X8 ||
mDT->GetOpaqueRect().Contains(clipExtents)) &&
!mDT->GetUserData(&sDontUseAsSourceKey)) {
DrawTarget *oldDT = mDT;
RefPtr<SourceSurface> source = mDT->Snapshot();
Point oldDeviceOffset = CurrentState().deviceOffset;

View File

@ -708,6 +708,8 @@ public:
void CopyAsDataURL();
#endif
static mozilla::gfx::UserDataKey sDontUseAsSourceKey;
private:
friend class GeneralPattern;
friend struct GlyphBufferAzure;

View File

@ -3377,12 +3377,14 @@ NSEvent* gLastDragMouseDownEvent = nil;
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
gfx::IntSize(backingSize.width,
backingSize.height));
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
targetContext = new gfxContext(dt);
} else if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BACKEND_COREGRAPHICS)) {
RefPtr<gfx::DrawTarget> dt =
gfx::Factory::CreateDrawTargetForCairoCGContext(aContext,
gfx::IntSize(backingSize.width,
backingSize.height));
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
targetContext = new gfxContext(dt);
} else {
targetContext = new gfxContext(targetSurface);