Bug 1393077 - Part1. Round the transformed rectangles and transformed points in StackingContextHelper. r=kats
MozReview-Commit-ID: Gk5z6BwsuTM
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -154,43 +154,32 @@ wr::LayoutRect
StackingContextHelper::ToRelativeLayoutRect(const LayerRect& aRect) const
{
// Multiply by the scale inherited from ancestors if exits
LayerRect aMaybeScaledRect = aRect;
if (mXScale != 1.0f || mYScale != 1.0f) {
aMaybeScaledRect.Scale(mXScale, mYScale);
}
- return wr::ToLayoutRect(aMaybeScaledRect - mOrigin);
+ return wr::ToLayoutRect(RoundedToInt(aMaybeScaledRect - mOrigin));
}
wr::LayoutRect
StackingContextHelper::ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const
{
// Multiply by the scale inherited from ancestors if exits
LayoutDeviceRect aMaybeScaledRect = aRect;
if (mXScale != 1.0f || mYScale != 1.0f) {
aMaybeScaledRect.Scale(mXScale, mYScale);
}
- return wr::ToLayoutRect(ViewAs<LayerPixel>(aMaybeScaledRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin);
+ return wr::ToLayoutRect(RoundedToInt(ViewAs<LayerPixel>(aMaybeScaledRect,
+ PixelCastJustification::WebRenderHasUnitResolution) - mOrigin));
}
wr::LayoutPoint
StackingContextHelper::ToRelativeLayoutPoint(const LayerPoint& aPoint) const
{
return wr::ToLayoutPoint(aPoint - mOrigin);
}
-wr::LayoutRect
-StackingContextHelper::ToRelativeLayoutRectRounded(const LayoutDeviceRect& aRect) const
-{
- // Multiply by the scale inherited from ancestors if exits
- LayoutDeviceRect aMaybeScaledRect = aRect;
- if (mXScale != 1.0f || mYScale != 1.0f) {
- aMaybeScaledRect.Scale(mXScale, mYScale);
- }
-
- return wr::ToLayoutRect(RoundedToInt(ViewAs<LayerPixel>(aMaybeScaledRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin));
-}
-
} // namespace layers
} // namespace mozilla
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -71,22 +71,22 @@ public:
// When this StackingContextHelper is in scope, this function can be used
// to convert a rect from the layer system's coordinate space to a LayoutRect
// that is relative to the stacking context. This is useful because most
// things that are pushed inside the stacking context need to be relative
// to the stacking context.
// We allow passing in a LayoutDeviceRect for convenience because in a lot of
// cases with WebRender display item generate the layout device space is the
// same as the layer space. (TODO: try to make this more explicit somehow).
+ // We also round the rectangle to ints after transforming since the output
+ // is the final destination rect.
wr::LayoutRect ToRelativeLayoutRect(const LayerRect& aRect) const;
wr::LayoutRect ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const;
// Same but for points
wr::LayoutPoint ToRelativeLayoutPoint(const LayerPoint& aPoint) const;
- // Same but rounds the rectangle to ints after transforming.
- wr::LayoutRect ToRelativeLayoutRectRounded(const LayoutDeviceRect& aRect) const;
bool IsBackfaceVisible() const { return mTransform.IsBackfaceVisible(); }
private:
wr::DisplayListBuilder* mBuilder;
LayerPoint mOrigin;
gfx::Matrix4x4 mTransform;
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -205,17 +205,17 @@ nsDisplayButtonBoxShadowOuter::CreateWeb
LAYER_ACTIVE) {
return false;
}
}
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
nsRect shadowRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
LayoutDeviceRect deviceBox =
LayoutDeviceRect::FromAppUnits(shadowRect, appUnitsPerDevPixel);
- wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRectRounded(deviceBox);
+ wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRect(deviceBox);
LayoutDeviceRect clipRect =
LayoutDeviceRect::FromAppUnits(mVisibleRect, appUnitsPerDevPixel);
wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
bool hasBorderRadius;
Unused << nsCSSRendering::HasBoxShadowNativeTheme(mFrame, hasBorderRadius);
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -473,17 +473,17 @@ BulletRenderer::CreateWebRenderCommandsF
gfx::IntSize size;
Maybe<wr::ImageKey> key = aManager->CreateImageKey(aItem, container, aBuilder, aSc, size);
if (key.isNothing()) {
return;
}
const int32_t appUnitsPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(mDest, appUnitsPerDevPixel);
- wr::LayoutRect dest = aSc.ToRelativeLayoutRectRounded(destRect);
+ wr::LayoutRect dest = aSc.ToRelativeLayoutRect(destRect);
aBuilder.PushImage(dest,
dest,
wr::ImageRendering::Auto,
key.value());
}
void
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -4699,18 +4699,18 @@ nsDisplayCaret::CreateWebRenderCommands(
mCaret->ComputeCaretRects(frame, contentOffset, &caretRect, &hookRect);
gfx::Color color = ToDeviceColor(frame->GetCaretColorAt(contentOffset));
LayoutDeviceRect devCaretRect = LayoutDeviceRect::FromAppUnits(
caretRect + ToReferenceFrame(), appUnitsPerDevPixel);
LayoutDeviceRect devHookRect = LayoutDeviceRect::FromAppUnits(
hookRect + ToReferenceFrame(), appUnitsPerDevPixel);
- wr::LayoutRect caret = aSc.ToRelativeLayoutRectRounded(devCaretRect);
- wr::LayoutRect hook = aSc.ToRelativeLayoutRectRounded(devHookRect);
+ wr::LayoutRect caret = aSc.ToRelativeLayoutRect(devCaretRect);
+ wr::LayoutRect hook = aSc.ToRelativeLayoutRect(devHookRect);
// Note, WR will pixel snap anything that is layout aligned.
aBuilder.PushRect(caret,
caret,
wr::ToColorF(color));
if (!devHookRect.IsEmpty()) {
aBuilder.PushRect(hook,
@@ -4978,23 +4978,23 @@ nsDisplayBorder::CreateBorderImageWebRen
NS_FOR_CSS_SIDES(i) {
slice[i] = (float)(mBorderImageRenderer->mSlice.Side(i)) / appUnitsPerDevPixel;
widths[i] = (float)(mBorderImageRenderer->mWidths.Side(i)) / appUnitsPerDevPixel;
outset[i] = (float)(mBorderImageRenderer->mImageOutset.Side(i)) / appUnitsPerDevPixel;
}
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(
mBorderImageRenderer->mArea, appUnitsPerDevPixel);
- wr::LayoutRect dest = aSc.ToRelativeLayoutRectRounded(destRect);
+ wr::LayoutRect dest = aSc.ToRelativeLayoutRect(destRect);
wr::LayoutRect clip = dest;
if (!mBorderImageRenderer->mClip.IsEmpty()) {
LayoutDeviceRect clipRect = LayoutDeviceRect::FromAppUnits(
mBorderImageRenderer->mClip, appUnitsPerDevPixel);
- clip = aSc.ToRelativeLayoutRectRounded(clipRect);
+ clip = aSc.ToRelativeLayoutRect(clipRect);
}
switch (mBorderImageRenderer->mImageRenderer.GetType()) {
case eStyleImageType_Image:
{
uint32_t flags = aDisplayListBuilder->ShouldSyncDecodeImages() ?
imgIContainer::FLAG_SYNC_DECODE :
imgIContainer::FLAG_NONE;
@@ -5359,17 +5359,17 @@ nsDisplayBoxShadowOuter::CreateWebRender
// Now translate everything to device pixels.
nsRect shadowRect = frameRect;
Point shadowOffset;
shadowOffset.x = (shadow->mXOffset / appUnitsPerDevPixel);
shadowOffset.y = (shadow->mYOffset / appUnitsPerDevPixel);
LayoutDeviceRect deviceBox = LayoutDeviceRect::FromAppUnits(
shadowRect, appUnitsPerDevPixel);
- wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRectRounded(deviceBox);
+ wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRect(deviceBox);
wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
// TODO: support non-uniform border radius.
float borderRadius = hasBorderRadius ? borderRadii.TopLeft().width
: 0.0;
float spreadRadius = float(shadow->mSpread) / float(appUnitsPerDevPixel);
aBuilder.PushBoxShadow(deviceBoxRect,