From 5624b1e36ed594dc2b017d5238b3d342d7f6d26e Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Mon, 19 Nov 2018 23:03:32 +0000 Subject: [PATCH] Bug 1507021. Use SnappedRectangle in more places. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D11840 --HG-- extra : moz-landing-system : lando --- gfx/thebes/gfxContext.h | 6 ++++-- gfx/thebes/gfxTextRun.cpp | 4 ++-- layout/base/PresShell.cpp | 2 +- layout/painting/DisplayItemClip.cpp | 2 +- layout/painting/nsCSSRendering.cpp | 8 ++++---- layout/painting/nsDisplayList.cpp | 4 ++-- layout/svg/nsSVGIntegrationUtils.cpp | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index ebac5b8c21d4..148e80474e86 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -149,10 +149,12 @@ public: /** * Draws the rectangle given by rect. - * @param snapToPixels ? */ - void Rectangle(const gfxRect& rect, bool snapToPixels = false); + void Rectangle(const gfxRect& rect) { return Rectangle(rect, false); } void SnappedRectangle(const gfxRect& rect) { return Rectangle(rect, true); } +private: + void Rectangle(const gfxRect& rect, bool snapToPixels); +public: /** ** Transformation Matrix manipulation diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 4e9742f53b15..76802ba0053e 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -562,10 +562,10 @@ struct MOZ_STACK_CLASS BufferAlphaColor { { mContext->Save(); mContext->NewPath(); - mContext->Rectangle(gfxRect(aBounds.X() / appsPerDevUnit, + mContext->SnappedRectangle(gfxRect(aBounds.X() / appsPerDevUnit, aBounds.Y() / appsPerDevUnit, aBounds.Width() / appsPerDevUnit, - aBounds.Height() / appsPerDevUnit), true); + aBounds.Height() / appsPerDevUnit)); mContext->Clip(); mContext->SetColor(Color(aAlphaColor.r, aAlphaColor.g, aAlphaColor.b)); mContext->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, aAlphaColor.a); diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 83d0de9360b4..f75f5c31bb3a 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -4712,7 +4712,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags, nsPresContext::AppUnitsToFloatCSSPixels(aRect.height)); aThebesContext->NewPath(); #ifdef MOZ_GFX_OPTIMIZE_MOBILE - aThebesContext->Rectangle(r, true); + aThebesContext->SnappedRectangle(r); #else aThebesContext->Rectangle(r); #endif diff --git a/layout/painting/DisplayItemClip.cpp b/layout/painting/DisplayItemClip.cpp index d91e327a3f61..a371574306ff 100644 --- a/layout/painting/DisplayItemClip.cpp +++ b/layout/painting/DisplayItemClip.cpp @@ -101,7 +101,7 @@ DisplayItemClip::ApplyRectTo(gfxContext* aContext, int32_t A2D) const { aContext->NewPath(); gfxRect clip = nsLayoutUtils::RectToGfxRect(mClipRect, A2D); - aContext->Rectangle(clip, true); + aContext->SnappedRectangle(clip); aContext->Clip(); } diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index bf3f7635dc43..bc1215f967a5 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -2543,7 +2543,7 @@ SetupImageLayerClip(nsCSSRendering::ImageLayerClipState& aClipState, aAutoSR->EnsureSaved(aCtx); aCtx->NewPath(); - aCtx->Rectangle(bgAreaGfx, true); + aCtx->SnappedRectangle(bgAreaGfx); aCtx->Clip(); } @@ -2585,7 +2585,7 @@ DrawBackgroundColor(nsCSSRendering::ImageLayerClipState& aClipState, // table painting seems to depend on it. if (!aClipState.mHasRoundedCorners || aClipState.mCustomClip) { aCtx->NewPath(); - aCtx->Rectangle(aClipState.mDirtyRectInDevPx, true); + aCtx->SnappedRectangle(aClipState.mDirtyRectInDevPx); aCtx->Fill(); return; } @@ -2606,7 +2606,7 @@ DrawBackgroundColor(nsCSSRendering::ImageLayerClipState& aClipState, gfxRect dirty = ThebesRect(bgAreaGfx).Intersect(aClipState.mDirtyRectInDevPx); aCtx->NewPath(); - aCtx->Rectangle(dirty, true); + aCtx->SnappedRectangle(dirty); aCtx->Clip(); if (aClipState.mHasAdditionalBGClipArea) { @@ -2615,7 +2615,7 @@ DrawBackgroundColor(nsCSSRendering::ImageLayerClipState& aClipState, bgAdditionalAreaGfx.Round(); gfxUtils::ConditionRect(bgAdditionalAreaGfx); aCtx->NewPath(); - aCtx->Rectangle(bgAdditionalAreaGfx, true); + aCtx->SnappedRectangle(bgAdditionalAreaGfx); aCtx->Clip(); } diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 71b425cbdfe5..ded9c0ce549c 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -5120,7 +5120,7 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder, ctx->SetColor(mColor); ctx->NewPath(); - ctx->Rectangle(bounds, true); + ctx->SnappedRectangle(bounds); ctx->Fill(); ctx->PopGroupAndBlend(); return; @@ -5128,7 +5128,7 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder, ctx->SetColor(mColor); ctx->NewPath(); - ctx->Rectangle(bounds, true); + ctx->SnappedRectangle(bounds); ctx->Fill(); #endif } diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 37c7a8cf5ed2..9b5c46e04a6a 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -1053,7 +1053,7 @@ void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, const T& aPa gfxRect drawingRect = nsLayoutUtils::RectToGfxRect(aParams.borderArea, frame->PresContext()->AppUnitsPerDevPixel()); - context.Rectangle(drawingRect, true); + context.SnappedRectangle(drawingRect); Color overlayColor(0.0f, 0.0f, 0.0f, 0.8f); if (maskUsage.shouldGenerateMaskLayer) { overlayColor.r = 1.0f; // red represents css positioned mask.