Bug 1391689 - Simplify titlebar image update logic. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Thu, 07 Sep 2017 15:21:01 +0200
changeset 379738 71652e02591473209ca9232374b5bbeac78b0c7f
parent 379737 39dc0da77e09f839fc395bdeb019536c7dcf244d
child 379739 36d3a6cb40dbdea6fce75189df8f8d0b349eb2d7
push id32461
push userkwierso@gmail.com
push dateFri, 08 Sep 2017 20:15:32 +0000
treeherdermozilla-central@dd3736e98e4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1391689
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1391689 - Simplify titlebar image update logic. r=mattwoodrow MozReview-Commit-ID: 4HPBNazSHDY
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2078,19 +2078,17 @@ nsChildView::CleanupWindowEffects()
 }
 
 void
 nsChildView::AddWindowOverlayWebRenderCommands(layers::WebRenderBridgeChild* aWrBridge,
                                                wr::DisplayListBuilder& aBuilder)
 {
   PrepareWindowEffects();
 
-  LayoutDeviceIntRegion updatedTitlebarRegion;
-  updatedTitlebarRegion.And(mUpdatedTitlebarRegion, mTitlebarRect);
-  updatedTitlebarRegion.MoveBy(-mTitlebarRect.TopLeft());
+  bool needUpdate = mUpdatedTitlebarRegion.Intersects(mTitlebarRect);
   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;
@@ -2106,20 +2104,20 @@ nsChildView::AddWindowOverlayWebRenderCo
       MOZ_ASSERT(mTitlebarImageKey.isNothing());
     }
 
     if (!mTitlebarImageKey) {
       mTitlebarImageKey = Some(aWrBridge->GetNextImageKey());
       wr::ImageDescriptor descriptor(size, stride, format);
       aBuilder.Resources().AddImage(*mTitlebarImageKey, descriptor, buffer);
       mTitlebarImageSize = size;
-      updatedTitlebarRegion.SetEmpty();
+      needUpdate = false;
     }
 
-    if (!updatedTitlebarRegion.IsEmpty()) {
+    if (needUpdate) {
       wr::ImageDescriptor descriptor(size, stride, format);
       aBuilder.Resources().UpdateImageBuffer(*mTitlebarImageKey, descriptor, buffer);
     }
 
     wr::LayoutRect rect = wr::ToLayoutRect(mTitlebarRect);
     aBuilder.PushImage(wr::LayoutRect{ rect.origin, { float(size.width), float(size.height) } },
                        rect, wr::ImageRendering::Auto, *mTitlebarImageKey);
   }