Bug 1369949 - Only push device aligned clips. draft
authorMarkus Stange <mstange@themasta.com>
Tue, 06 Jun 2017 19:19:51 -0400
changeset 589843 c8b4cf3de7245a4d07e1120d580db74a7cdf7793
parent 589842 df1372d65f98f316fe53434b57db39de34d464a0
child 632041 b9341938677ad1b4ad27d262eacd1e80118d4fa2
push id62544
push userbmo:mstange@themasta.com
push dateTue, 06 Jun 2017 23:28:54 +0000
bugs1369949
milestone55.0a1
Bug 1369949 - Only push device aligned clips. MozReview-Commit-ID: BO9zds8fiKI
gfx/thebes/gfxQuartzNativeDrawing.cpp
--- a/gfx/thebes/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/gfxQuartzNativeDrawing.cpp
@@ -45,16 +45,22 @@ gfxQuartzNativeDrawing::BeginNativeDrawi
 
     transform.PostTranslate(-mNativeRect.x, -mNativeRect.y);
     mTempDrawTarget->SetTransform(transform);
 
     dt = mTempDrawTarget;
   } else {
     // Clip the DT in case BorrowedCGContext needs to create a new layer.
     // This prevents it from creating a new layer the size of the window.
+    // But make sure that this clip is device pixel aligned.
+    Matrix transform = dt->GetTransform();
+
+    Rect deviceRect = transform.TransformBounds(mNativeRect);
+    deviceRect.RoundOut();
+    mNativeRect = transform.Inverse().TransformBounds(deviceRect);
     mDrawTarget->PushClipRect(mNativeRect);
   }
 
   MOZ_ASSERT(dt->GetBackendType() == BackendType::SKIA);
   mCGContext = mBorrowedContext.Init(dt);
 
   if (NS_WARN_IF(!mCGContext)) {
     // Failed borrowing CG context, so we need to clean up.