From 0d3a73d431a8fed3f52e4eedbb2398e5815499d1 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 9 Jun 2014 14:02:39 -0400 Subject: [PATCH] Bug 1018387 - Update various variables and comments to reflect the fact that the values are in layer pixels and not layout device pixels. r=Cwiiis --- gfx/layers/client/ClientTiledThebesLayer.cpp | 45 ++++++++++---------- gfx/layers/client/TiledContentClient.cpp | 33 +++++++------- gfx/layers/client/TiledContentClient.h | 15 +++---- layout/base/Units.h | 3 ++ 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/gfx/layers/client/ClientTiledThebesLayer.cpp b/gfx/layers/client/ClientTiledThebesLayer.cpp index be81bd6d977d..248d788c72fe 100644 --- a/gfx/layers/client/ClientTiledThebesLayer.cpp +++ b/gfx/layers/client/ClientTiledThebesLayer.cpp @@ -58,10 +58,10 @@ ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs) aAttrs = ThebesLayerAttributes(GetValidRegion()); } -static LayoutDeviceRect -ApplyParentLayerToLayoutTransform(const gfx3DMatrix& aTransform, const ParentLayerRect& aParentLayerRect) +static LayerRect +ApplyParentLayerToLayerTransform(const gfx3DMatrix& aTransform, const ParentLayerRect& aParentLayerRect) { - return TransformTo(aTransform, aParentLayerRect); + return TransformTo(aTransform, aParentLayerRect); } static gfx3DMatrix @@ -130,23 +130,22 @@ ClientTiledThebesLayer::BeginPaint() const FrameMetrics& displayportMetrics = displayPortAncestor->GetFrameMetrics(); // Calculate the transform required to convert ParentLayer space of our - // display port ancestor to the LayoutDevice space of this layer. - gfx3DMatrix layoutDeviceToDisplayPort = + // display port ancestor to the Layer space of this layer. + gfx3DMatrix transformToDisplayPort = GetTransformToAncestorsParentLayer(this, displayPortAncestor); - layoutDeviceToDisplayPort.ScalePost(scrollMetrics.mCumulativeResolution.scale, - scrollMetrics.mCumulativeResolution.scale, - 1.f); + transformToDisplayPort.ScalePost(scrollMetrics.mCumulativeResolution.scale, + scrollMetrics.mCumulativeResolution.scale, + 1.f); - mPaintData.mTransformDisplayPortToLayoutDevice = layoutDeviceToDisplayPort.Inverse(); + mPaintData.mTransformDisplayPortToLayer = transformToDisplayPort.Inverse(); // Compute the critical display port that applies to this layer in the // LayoutDevice space of this layer. ParentLayerRect criticalDisplayPort = (displayportMetrics.mCriticalDisplayPort * displayportMetrics.GetZoomToParent()) + displayportMetrics.mCompositionBounds.TopLeft(); - mPaintData.mCriticalDisplayPort = LayoutDeviceIntRect::ToUntyped(RoundedOut( - ApplyParentLayerToLayoutTransform(mPaintData.mTransformDisplayPortToLayoutDevice, - criticalDisplayPort))); + mPaintData.mCriticalDisplayPort = RoundedOut( + ApplyParentLayerToLayerTransform(mPaintData.mTransformDisplayPortToLayer, criticalDisplayPort)); TILING_PRLOG_OBJ(("TILING 0x%p: Critical displayport %s\n", this, tmpstr.get()), mPaintData.mCriticalDisplayPort); // Compute the viewport that applies to this layer in the LayoutDevice @@ -154,8 +153,8 @@ ClientTiledThebesLayer::BeginPaint() ParentLayerRect viewport = (displayportMetrics.mViewport * displayportMetrics.GetZoomToParent()) + displayportMetrics.mCompositionBounds.TopLeft(); - mPaintData.mViewport = ApplyParentLayerToLayoutTransform( - mPaintData.mTransformDisplayPortToLayoutDevice, viewport); + mPaintData.mViewport = ApplyParentLayerToLayerTransform( + mPaintData.mTransformDisplayPortToLayer, viewport); TILING_PRLOG_OBJ(("TILING 0x%p: Viewport %s\n", this, tmpstr.get()), mPaintData.mViewport); // Store the resolution from the displayport ancestor layer. Because this is Gecko-side, @@ -163,11 +162,11 @@ ClientTiledThebesLayer::BeginPaint() mPaintData.mResolution = displayportMetrics.GetZoomToParent(); TILING_PRLOG(("TILING 0x%p: Resolution %f\n", this, mPaintData.mResolution.scale)); - // Store the applicable composition bounds in this layer's LayoutDevice units. - gfx3DMatrix layoutDeviceToCompBounds = + // Store the applicable composition bounds in this layer's Layer units. + gfx3DMatrix transformToCompBounds = GetTransformToAncestorsParentLayer(this, scrollAncestor); - mPaintData.mCompositionBounds = TransformTo( - layoutDeviceToCompBounds.Inverse(), + mPaintData.mCompositionBounds = TransformTo( + transformToCompBounds.Inverse(), scrollMetrics.mCompositionBounds / scrollMetrics.GetParentResolution()); TILING_PRLOG_OBJ(("TILING 0x%p: Composition bounds %s\n", this, tmpstr.get()), mPaintData.mCompositionBounds); @@ -267,7 +266,7 @@ ClientTiledThebesLayer::RenderLayer() if (!mPaintData.mCriticalDisplayPort.IsEmpty()) { // Make sure that tiles that fall outside of the critical displayport are // discarded on the first update. - mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort); + mValidRegion.And(mValidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); } } @@ -283,7 +282,7 @@ ClientTiledThebesLayer::RenderLayer() } // Clip the invalid region to the critical display-port - invalidRegion.And(invalidRegion, mPaintData.mCriticalDisplayPort); + invalidRegion.And(invalidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); if (invalidRegion.IsEmpty() && lowPrecisionInvalidRegion.IsEmpty()) { EndPaint(true); return; @@ -304,7 +303,7 @@ ClientTiledThebesLayer::RenderLayer() nsIntRegion oldValidRegion = mContentClient->mTiledBuffer.GetValidRegion(); oldValidRegion.And(oldValidRegion, mVisibleRegion); if (!mPaintData.mCriticalDisplayPort.IsEmpty()) { - oldValidRegion.And(oldValidRegion, mPaintData.mCriticalDisplayPort); + oldValidRegion.And(oldValidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); } TILING_PRLOG_OBJ(("TILING 0x%p: Progressive update with old valid region %s\n", this, tmpstr.get()), oldValidRegion); @@ -317,7 +316,7 @@ ClientTiledThebesLayer::RenderLayer() updatedBuffer = true; mValidRegion = mVisibleRegion; if (!mPaintData.mCriticalDisplayPort.IsEmpty()) { - mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort); + mValidRegion.And(mValidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); } TILING_PRLOG_OBJ(("TILING 0x%p: Painting: valid region %s\n", this, tmpstr.get()), mValidRegion); @@ -354,7 +353,7 @@ ClientTiledThebesLayer::RenderLayer() // visible region is larger than the critical display port. bool updatedLowPrecision = false; if (!lowPrecisionInvalidRegion.IsEmpty() && - !nsIntRegion(mPaintData.mCriticalDisplayPort).Contains(mVisibleRegion)) { + !nsIntRegion(LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)).Contains(mVisibleRegion)) { nsIntRegion oldValidRegion = mContentClient->mLowPrecisionTiledBuffer.GetValidRegion(); oldValidRegion.And(oldValidRegion, mVisibleRegion); diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 05a33ddb8657..b7d7176a27c7 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -889,29 +889,29 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile, return aTile; } -static LayoutDeviceRect +static LayerRect TransformCompositionBounds(const ParentLayerRect& aCompositionBounds, const CSSToParentLayerScale& aZoom, const ParentLayerPoint& aScrollOffset, const CSSToParentLayerScale& aResolution, - const gfx3DMatrix& aTransformDisplayPortToLayoutDevice) + const gfx3DMatrix& aTransformDisplayPortToLayer) { // Transform the composition bounds from the space of the displayport ancestor - // layer into the LayoutDevice space of this layer. Do this by + // layer into the Layer space of this layer. Do this by // compensating for the difference in resolution and subtracting the // old composition bounds origin. ParentLayerRect offsetViewportRect = (aCompositionBounds / aZoom) * aResolution; offsetViewportRect.MoveBy(-aScrollOffset); gfxRect transformedViewport = - aTransformDisplayPortToLayoutDevice.TransformBounds( + aTransformDisplayPortToLayer.TransformBounds( gfxRect(offsetViewportRect.x, offsetViewportRect.y, offsetViewportRect.width, offsetViewportRect.height)); - return LayoutDeviceRect(transformedViewport.x, - transformedViewport.y, - transformedViewport.width, - transformedViewport.height); + return LayerRect(transformedViewport.x, + transformedViewport.y, + transformedViewport.width, + transformedViewport.height); } bool @@ -976,26 +976,27 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval } } - LayoutDeviceRect transformedCompositionBounds = + LayerRect transformedCompositionBounds = TransformCompositionBounds(compositionBounds, zoom, aPaintData->mScrollOffset, - aPaintData->mResolution, aPaintData->mTransformDisplayPortToLayoutDevice); + aPaintData->mResolution, aPaintData->mTransformDisplayPortToLayer); // Paint tiles that have stale content or that intersected with the screen // at the time of issuing the draw command in a single transaction first. // This is to avoid rendering glitches on animated page content, and when // layers change size/shape. - LayoutDeviceRect typedCoherentUpdateRect = + LayerRect typedCoherentUpdateRect = transformedCompositionBounds.Intersect(aPaintData->mCompositionBounds); // Offset by the viewport origin, as the composition bounds are stored in // Layer space and not LayoutDevice space. + // TODO(kats): does this make sense? typedCoherentUpdateRect.MoveBy(aPaintData->mViewport.TopLeft()); // Convert to untyped to intersect with the invalid region. - nsIntRect roundedCoherentUpdateRect = - LayoutDeviceIntRect::ToUntyped(RoundedOut(typedCoherentUpdateRect)); + nsIntRect untypedCoherentUpdateRect(LayerIntRect::ToUntyped( + RoundedOut(typedCoherentUpdateRect))); - aRegionToPaint.And(aInvalidRegion, roundedCoherentUpdateRect); + aRegionToPaint.And(aInvalidRegion, untypedCoherentUpdateRect); aRegionToPaint.Or(aRegionToPaint, staleRegion); bool drawingStale = !aRegionToPaint.IsEmpty(); if (!drawingStale) { @@ -1004,8 +1005,8 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval // Prioritise tiles that are currently visible on the screen. bool paintVisible = false; - if (aRegionToPaint.Intersects(roundedCoherentUpdateRect)) { - aRegionToPaint.And(aRegionToPaint, roundedCoherentUpdateRect); + if (aRegionToPaint.Intersects(untypedCoherentUpdateRect)) { + aRegionToPaint.And(aRegionToPaint, untypedCoherentUpdateRect); paintVisible = true; } diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index cf1d7ac03681..2bb33930ebdb 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -255,26 +255,23 @@ struct BasicTiledLayerPaintData { /* * The transform matrix to go from the display port layer's ParentLayer - * units to this layer's LayoutDevice units. The "display port layer" is + * units to this layer's Layer units. The "display port layer" is * the closest ancestor layer with a displayport. */ - gfx3DMatrix mTransformDisplayPortToLayoutDevice; + gfx3DMatrix mTransformDisplayPortToLayer; /* * The critical displayport of the content from the nearest ancestor layer * that represents scrollable content with a display port set. Empty if a * critical displayport is not set. - * - * This is in LayoutDevice coordinates, but is stored as an nsIntRect for - * convenience when intersecting with the layer's mValidRegion. */ - nsIntRect mCriticalDisplayPort; + LayerIntRect mCriticalDisplayPort; /* * The viewport of the content from the nearest ancestor layer that * represents scrollable content with a display port set. */ - LayoutDeviceRect mViewport; + LayerRect mViewport; /* * The render resolution of the document that the content this layer @@ -283,11 +280,11 @@ struct BasicTiledLayerPaintData { CSSToParentLayerScale mResolution; /* - * The composition bounds of the layer, in LayoutDevice coordinates. This is + * The composition bounds of the layer, in Layer coordinates. This is * used to make sure that tiled updates to regions that are visible to the * user are grouped coherently. */ - LayoutDeviceRect mCompositionBounds; + LayerRect mCompositionBounds; /* * Low precision updates are always executed a tile at a time in repeated diff --git a/layout/base/Units.h b/layout/base/Units.h index f7c26d292c40..fa9f8aacaa3d 100644 --- a/layout/base/Units.h +++ b/layout/base/Units.h @@ -189,6 +189,9 @@ struct LayoutDevicePixel { * 3) the "widget scale" (see nsIWidget::GetDefaultScale) */ struct LayerPixel { + static nsIntRect ToUntyped(const LayerIntRect& aRect) { + return nsIntRect(aRect.x, aRect.y, aRect.width, aRect.height); + } }; /*