Bug 1390888 - Correctly draw into mTitlebarCGContext and invalidate the right parts if mTitlebarRect is not located at (0, 0). r?spohl draft
authorMarkus Stange <mstange@themasta.com>
Wed, 16 Aug 2017 13:16:34 -0400
changeset 647609 6ff0b8be00d0e0c34520f3e8be81a8d3bb6995ff
parent 647606 dee7fbeb9adbe5ee68d60450f1cda60dd5648f5b
child 647610 57454297f0b3ee472a8e60a50b0e291f32839b85
push id74477
push userbmo:mstange@themasta.com
push dateWed, 16 Aug 2017 17:22:21 +0000
reviewersspohl
bugs1390888
milestone57.0a1
Bug 1390888 - Correctly draw into mTitlebarCGContext and invalidate the right parts if mTitlebarRect is not located at (0, 0). r?spohl MozReview-Commit-ID: Jf0pt1wZxUo
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2084,16 +2084,17 @@ nsChildView::CleanupWindowEffects()
 void
 nsChildView::AddWindowOverlayWebRenderCommands(layers::WebRenderBridgeChild* aWrBridge,
                                                wr::DisplayListBuilder& aBuilder)
 {
   PrepareWindowEffects();
 
   LayoutDeviceIntRegion updatedTitlebarRegion;
   updatedTitlebarRegion.And(mUpdatedTitlebarRegion, mTitlebarRect);
+  updatedTitlebarRegion.MoveBy(-mTitlebarRect.TopLeft());
   mUpdatedTitlebarRegion.SetEmpty();
 
   if (mTitlebarCGContext) {
     gfx::IntSize size(CGBitmapContextGetWidth(mTitlebarCGContext),
                       CGBitmapContextGetHeight(mTitlebarCGContext));
     size_t stride = CGBitmapContextGetBytesPerRow(mTitlebarCGContext);
     size_t titlebarCGContextDataLength = stride * size.height;
     gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
@@ -2342,16 +2343,18 @@ nsChildView::UpdateTitlebarCGContext()
   if (NSIsEmptyRect(dirtyTitlebarRect)) {
     return;
   }
 
   CGContextRef ctx = mTitlebarCGContext;
 
   CGContextSaveGState(ctx);
 
+  CGContextTranslateCTM(ctx, -mTitlebarRect.x, -mTitlebarRect.y);
+
   double scale = BackingScaleFactor();
   CGContextScaleCTM(ctx, scale, scale);
 
   CGContextClipToRect(ctx, NSRectToCGRect(dirtyTitlebarRect));
   CGContextClearRect(ctx, NSRectToCGRect(dirtyTitlebarRect));
 
   NSGraphicsContext* oldContext = [NSGraphicsContext currentContext];
 
@@ -2453,16 +2456,17 @@ nsChildView::MaybeDrawTitlebar(GLManager
 {
   MutexAutoLock lock(mEffectsLock);
   if (!mIsCoveringTitlebar || mIsFullscreen) {
     return;
   }
 
   LayoutDeviceIntRegion updatedTitlebarRegion;
   updatedTitlebarRegion.And(mUpdatedTitlebarRegion, mTitlebarRect);
+  updatedTitlebarRegion.MoveBy(-mTitlebarRect.TopLeft());
   mUpdatedTitlebarRegion.SetEmpty();
 
   if (!mTitlebarImage) {
     mTitlebarImage = MakeUnique<RectTextureImage>();
   }
 
   mTitlebarImage->UpdateFromCGContext(mTitlebarRect.Size(),
                                       updatedTitlebarRegion,