From 6792ac37c1b65333d28fa553d84bddb61a8b9604 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Thu, 24 Oct 2013 17:53:39 +0200 Subject: [PATCH] Bug 924194 - Make gfxQuartzNativeDrawing::BeginNativeDrawing able to handle DrawTargets with a different backend than BACKEND_COREGRAPHICS (e.g. BACKEND_CAIRO). r=jrmuizel --HG-- extra : rebase_source : d284993fae8681854b73f4d9f935427b98731dfa --- gfx/thebes/gfxQuartzNativeDrawing.cpp | 41 +++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/gfx/thebes/gfxQuartzNativeDrawing.cpp b/gfx/thebes/gfxQuartzNativeDrawing.cpp index c483dda13e92..315624f9a06f 100644 --- a/gfx/thebes/gfxQuartzNativeDrawing.cpp +++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp @@ -35,32 +35,37 @@ gfxQuartzNativeDrawing::BeginNativeDrawing() { NS_ASSERTION(!mQuartzSurface, "BeginNativeDrawing called when drawing already in progress"); + gfxPoint deviceOffset; + nsRefPtr surf; + if (!mContext->IsCairo()) { DrawTarget *dt = mContext->GetDrawTarget(); - if (mContext->GetDrawTarget()->IsDualDrawTarget()) { - IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale), - NSToIntFloor(mNativeRect.height * mBackingScale)); + if (dt->GetType() == BACKEND_COREGRAPHICS) { + if (dt->IsDualDrawTarget()) { + IntSize backingSize(NSToIntFloor(mNativeRect.width * mBackingScale), + NSToIntFloor(mNativeRect.height * mBackingScale)); - if (backingSize.IsEmpty()) - return nullptr; + if (backingSize.IsEmpty()) + return nullptr; - mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, FORMAT_B8G8R8A8); + mDrawTarget = Factory::CreateDrawTarget(BACKEND_COREGRAPHICS, backingSize, FORMAT_B8G8R8A8); - Matrix transform; - transform.Scale(mBackingScale, mBackingScale); - transform.Translate(-mNativeRect.x, -mNativeRect.y); + Matrix transform; + transform.Scale(mBackingScale, mBackingScale); + transform.Translate(-mNativeRect.x, -mNativeRect.y); - mDrawTarget->SetTransform(transform); - dt = mDrawTarget; + mDrawTarget->SetTransform(transform); + dt = mDrawTarget; + } + + mCGContext = mBorrowedContext.Init(dt); + MOZ_ASSERT(mCGContext); + return mCGContext; } - - mCGContext = mBorrowedContext.Init(dt); - MOZ_ASSERT(mCGContext); - return mCGContext; + surf = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(dt); + } else { + surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y); } - - gfxPoint deviceOffset; - nsRefPtr surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y); if (!surf || surf->CairoStatus()) return nullptr;