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
--- 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,