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
This commit is contained in:
Markus Stange 2013-10-24 17:53:39 +02:00
parent 3b3acb5a88
commit 8b7f7bf981

View File

@ -35,32 +35,37 @@ gfxQuartzNativeDrawing::BeginNativeDrawing()
{
NS_ASSERTION(!mQuartzSurface, "BeginNativeDrawing called when drawing already in progress");
gfxPoint deviceOffset;
nsRefPtr<gfxASurface> 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<gfxASurface> surf = mContext->CurrentSurface(&deviceOffset.x, &deviceOffset.y);
if (!surf || surf->CairoStatus())
return nullptr;