From 40e0b92cb88d0df73ab88650d5c574b7df0c8fc4 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Mon, 18 Apr 2016 13:49:14 -0400 Subject: [PATCH] Bug 1236043 - Use TiledRegion for the invalid region of a layer. r=jrmuizel MozReview-Commit-ID: BNUyUPbrnU1 --HG-- extra : rebase_source : 80342a281d6fd30ba8d12b77b3af4aec60376294 --- gfx/layers/LayerTreeInvalidation.cpp | 4 +--- gfx/layers/Layers.h | 15 ++++++++++----- gfx/layers/basic/BasicPaintedLayer.h | 5 ++--- gfx/layers/client/ClientPaintedLayer.h | 5 ++--- gfx/layers/client/ClientTiledPaintedLayer.h | 8 ++++---- gfx/layers/ipc/ShadowLayers.cpp | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gfx/layers/LayerTreeInvalidation.cpp b/gfx/layers/LayerTreeInvalidation.cpp index 81ed9f263b65..77b99835d5ca 100644 --- a/gfx/layers/LayerTreeInvalidation.cpp +++ b/gfx/layers/LayerTreeInvalidation.cpp @@ -132,7 +132,6 @@ struct LayerPropertiesBase : public LayerProperties : mLayer(aLayer) , mMaskLayer(nullptr) , mVisibleRegion(mLayer->GetLocalVisibleRegion().ToUnknownRegion()) - , mInvalidRegion(aLayer->GetInvalidRegion()) , mPostXScale(aLayer->GetPostXScale()) , mPostYScale(aLayer->GetPostYScale()) , mOpacity(aLayer->GetLocalOpacity()) @@ -202,7 +201,7 @@ struct LayerPropertiesBase : public LayerProperties } AddRegion(result, ComputeChangeInternal(aCallback, aGeometryChanged)); - AddTransformedRegion(result, mLayer->GetInvalidRegion(), mTransform); + AddTransformedRegion(result, mLayer->GetInvalidRegion().GetRegion(), mTransform); if (mMaskLayer && otherMask) { AddTransformedRegion(result, mMaskLayer->ComputeChange(aCallback, aGeometryChanged), @@ -252,7 +251,6 @@ struct LayerPropertiesBase : public LayerProperties UniquePtr mMaskLayer; nsTArray> mAncestorMaskLayers; nsIntRegion mVisibleRegion; - nsIntRegion mInvalidRegion; Matrix4x4 mTransform; float mPostXScale; float mPostYScale; diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 09f739904f21..ed61bd5e6f1f 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -28,6 +28,7 @@ #include "mozilla/gfx/BaseMargin.h" // for BaseMargin #include "mozilla/gfx/BasePoint.h" // for BasePoint #include "mozilla/gfx/Point.h" // for IntSize +#include "mozilla/gfx/TiledRegion.h" // for TiledIntRegion #include "mozilla/gfx/Types.h" // for SurfaceFormat #include "mozilla/gfx/UserData.h" // for UserData, etc #include "mozilla/layers/LayersTypes.h" @@ -1662,20 +1663,24 @@ public: * Returns the current area of the layer (in layer-space coordinates) * marked as needed to be recomposited. */ - const nsIntRegion& GetInvalidRegion() { return mInvalidRegion; } + const gfx::TiledIntRegion& GetInvalidRegion() { return mInvalidRegion; } void AddInvalidRegion(const nsIntRegion& aRegion) { - mInvalidRegion.Or(mInvalidRegion, aRegion); + mInvalidRegion.Add(aRegion); } /** * Mark the entirety of the layer's visible region as being invalid. */ - void SetInvalidRectToVisibleRegion() { mInvalidRegion = GetVisibleRegion().ToUnknownRegion(); } + void SetInvalidRectToVisibleRegion() + { + mInvalidRegion.SetEmpty(); + mInvalidRegion.Add(GetVisibleRegion().ToUnknownRegion()); + } /** * Adds to the current invalid rect. */ - void AddInvalidRect(const gfx::IntRect& aRect) { mInvalidRegion.Or(mInvalidRegion, aRect); } + void AddInvalidRect(const gfx::IntRect& aRect) { mInvalidRegion.Add(aRect); } /** * Clear the invalid rect, marking the layer as being identical to what is currently @@ -1833,7 +1838,7 @@ protected: bool mForceIsolatedGroup; Maybe mClipRect; gfx::IntRect mTileSourceRect; - nsIntRegion mInvalidRegion; + gfx::TiledIntRegion mInvalidRegion; nsTArray > mApzcs; uint32_t mContentFlags; bool mUseTileSourceRect; diff --git a/gfx/layers/basic/BasicPaintedLayer.h b/gfx/layers/basic/BasicPaintedLayer.h index 4518b64fce9d..59f71b20ce07 100644 --- a/gfx/layers/basic/BasicPaintedLayer.h +++ b/gfx/layers/basic/BasicPaintedLayer.h @@ -54,9 +54,8 @@ public: { NS_ASSERTION(BasicManager()->InConstruction(), "Can only set properties in construction phase"); - mInvalidRegion.Or(mInvalidRegion, aRegion); - mInvalidRegion.SimplifyOutward(20); - mValidRegion.Sub(mValidRegion, mInvalidRegion); + mInvalidRegion.Add(aRegion); + mValidRegion.Sub(mValidRegion, mInvalidRegion.GetRegion()); } virtual void PaintThebes(gfxContext* aContext, diff --git a/gfx/layers/client/ClientPaintedLayer.h b/gfx/layers/client/ClientPaintedLayer.h index 7387ee1c13fd..949f746aea5f 100644 --- a/gfx/layers/client/ClientPaintedLayer.h +++ b/gfx/layers/client/ClientPaintedLayer.h @@ -60,9 +60,8 @@ public: { NS_ASSERTION(ClientManager()->InConstruction(), "Can only set properties in construction phase"); - mInvalidRegion.Or(mInvalidRegion, aRegion); - mInvalidRegion.SimplifyOutward(20); - mValidRegion.Sub(mValidRegion, mInvalidRegion); + mInvalidRegion.Add(aRegion); + mValidRegion.Sub(mValidRegion, mInvalidRegion.GetRegion()); } virtual void RenderLayer() override { RenderLayerWithReadback(nullptr); } diff --git a/gfx/layers/client/ClientTiledPaintedLayer.h b/gfx/layers/client/ClientTiledPaintedLayer.h index 30259f9802cd..9e1e003ee5df 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.h +++ b/gfx/layers/client/ClientTiledPaintedLayer.h @@ -54,10 +54,10 @@ public: // PaintedLayer virtual Layer* AsLayer() override { return this; } virtual void InvalidateRegion(const nsIntRegion& aRegion) override { - mInvalidRegion.Or(mInvalidRegion, aRegion); - mInvalidRegion.SimplifyOutward(20); - mValidRegion.Sub(mValidRegion, mInvalidRegion); - mLowPrecisionValidRegion.Sub(mLowPrecisionValidRegion, mInvalidRegion); + mInvalidRegion.Add(aRegion); + nsIntRegion invalidRegion = mInvalidRegion.GetRegion(); + mValidRegion.Sub(mValidRegion, invalidRegion); + mLowPrecisionValidRegion.Sub(mLowPrecisionValidRegion, invalidRegion); } // Shadow methods diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index c81284d8bd7a..700fa1e60426 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -844,7 +844,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray* aReplies, } common.maskLayerParent() = nullptr; common.animations() = mutant->GetAnimations(); - common.invalidRegion() = mutant->GetInvalidRegion(); + common.invalidRegion() = mutant->GetInvalidRegion().GetRegion(); common.scrollMetadata() = mutant->GetAllScrollMetadata(); for (size_t i = 0; i < mutant->GetAncestorMaskLayerCount(); i++) { auto layer = Shadow(mutant->GetAncestorMaskLayerAt(i)->AsShadowableLayer());