Bug 1377314 - Replace ImageKey when image size is changed r=kats
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 04 Jul 2017 11:56:04 +0900
changeset 367208 aba2f559df0f4a5df0a48a1de7f72dbfb79f3ab7
parent 367207 4630d37dca64531abe937f20139140e088398716
child 367209 006ce2d7356866befcc4f2d6467f0166a517a5a2
push id32125
push usercbook@mozilla.com
push dateTue, 04 Jul 2017 08:48:50 +0000
treeherdermozilla-central@fef489e8c2a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1377314
milestone56.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 1377314 - Replace ImageKey when image size is changed r=kats
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -630,16 +630,17 @@ protected:
   // Compositor thread only
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mResizerImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mCornerMaskImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mTitlebarImage;
   mozilla::UniquePtr<mozilla::widget::RectTextureImage> mBasicCompositorImage;
 
   // Main thread + webrender only
   mozilla::Maybe<mozilla::wr::ImageKey> mTitlebarImageKey;
+  mozilla::gfx::IntSize mTitlebarImageSize;
 
   // The area of mTitlebarCGContext that has changed and needs to be
   // uploaded to to mTitlebarImage. Main thread only.
   nsIntRegion           mDirtyTitlebarRegion;
 
   mozilla::ViewRegion   mNonDraggableRegion;
 
   // Cached value of [mView backingScaleFactor], to avoid sending two obj-c
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2091,19 +2091,27 @@ nsChildView::AddWindowOverlayWebRenderCo
                       CGBitmapContextGetHeight(mTitlebarCGContext));
     size_t stride = CGBitmapContextGetBytesPerRow(mTitlebarCGContext);
     size_t titlebarCGContextDataLength = stride * size.height;
     gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
     wr::ByteBuffer buffer(
       titlebarCGContextDataLength,
       static_cast<uint8_t *>(CGBitmapContextGetData(mTitlebarCGContext)));
 
+    if (mTitlebarImageKey &&
+        mTitlebarImageSize != size) {
+      // Delete wr::ImageKey. wr::ImageKey does not support size change.
+      CleanupWebRenderWindowOverlay(aWrBridge);
+      MOZ_ASSERT(mTitlebarImageKey.isNothing());
+    }
+
     if (!mTitlebarImageKey) {
       mTitlebarImageKey = Some(aWrBridge->GetNextImageKey());
       aWrBridge->SendAddImage(*mTitlebarImageKey, size, stride, format, buffer);
+      mTitlebarImageSize = size;
       updatedTitlebarRegion.SetEmpty();
     }
 
     if (!updatedTitlebarRegion.IsEmpty()) {
       aWrBridge->SendUpdateImage(*mTitlebarImageKey, size, format, buffer);
     }
 
     WrRect rect = wr::ToWrRect(mTitlebarRect);