Bug 1368386 - Make ProgressiveUpdate's aValidRegion parameter const to make it a bit easier to reason about. r?mattwoodrow
MozReview-Commit-ID: DOfJ8TTuL1t
--- a/gfx/layers/client/ClientTiledPaintedLayer.cpp
+++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp
@@ -317,18 +317,22 @@ ClientTiledPaintedLayer::RenderHighPreci
nsIntRegion oldValidRegion = mContentClient->GetTiledBuffer()->GetValidRegion();
oldValidRegion.And(oldValidRegion, aVisibleRegion);
if (mPaintData.mCriticalDisplayPort) {
oldValidRegion.And(oldValidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
}
TILING_LOG("TILING %p: Progressive update with old valid region %s\n", this, Stringify(oldValidRegion).c_str());
- return mContentClient->GetTiledBuffer()->ProgressiveUpdate(mValidRegion, aInvalidRegion,
- oldValidRegion, &mPaintData, aCallback, aCallbackData);
+ nsIntRegion drawnRegion;
+ bool updatedBuffer =
+ mContentClient->GetTiledBuffer()->ProgressiveUpdate(mValidRegion, aInvalidRegion,
+ oldValidRegion, drawnRegion, &mPaintData, aCallback, aCallbackData);
+ mValidRegion.OrWith(drawnRegion);
+ return updatedBuffer;
}
// Otherwise do a non-progressive paint. We must do this even when
// the region to paint is empty as the valid region may have shrunk.
mValidRegion = aVisibleRegion;
if (mPaintData.mCriticalDisplayPort) {
mValidRegion.And(mValidRegion, mPaintData.mCriticalDisplayPort->ToUnknownRect());
@@ -383,19 +387,21 @@ ClientTiledPaintedLayer::RenderLowPrecis
// Remove the valid high-precision region from the invalid low-precision
// region. We don't want to spend time drawing things twice.
invalidRegion.SubOut(mValidRegion);
TILING_LOG("TILING %p: Progressive paint: low-precision invalid region is %s\n", this, Stringify(invalidRegion).c_str());
TILING_LOG("TILING %p: Progressive paint: low-precision old valid region is %s\n", this, Stringify(oldValidRegion).c_str());
if (!invalidRegion.IsEmpty()) {
+ nsIntRegion drawnRegion;
updatedBuffer = mContentClient->GetLowPrecisionTiledBuffer()->ProgressiveUpdate(
mLowPrecisionValidRegion, invalidRegion, oldValidRegion,
- &mPaintData, aCallback, aCallbackData);
+ drawnRegion, &mPaintData, aCallback, aCallbackData);
+ mLowPrecisionValidRegion.OrWith(drawnRegion);
}
TILING_LOG("TILING %p: Progressive paint: low-precision new valid region is %s\n", this, Stringify(mLowPrecisionValidRegion).c_str());
return updatedBuffer;
}
if (!mLowPrecisionValidRegion.IsEmpty()) {
TILING_LOG("TILING %p: Clearing low-precision buffer\n", this);
// Clear the low precision tiled buffer.
--- a/gfx/layers/client/SingleTiledContentClient.h
+++ b/gfx/layers/client/SingleTiledContentClient.h
@@ -40,19 +40,20 @@ public:
void PaintThebes(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion,
const nsIntRegion& aDirtyRegion,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData,
bool aIsProgressive = false) override;
bool SupportsProgressiveUpdate() override { return false; }
- bool ProgressiveUpdate(nsIntRegion& aValidRegion,
+ bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
const nsIntRegion& aInvalidRegion,
const nsIntRegion& aOldValidRegion,
+ nsIntRegion& aOutDrawnRegion,
BasicTiledLayerPaintData* aPaintData,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData) override
{
MOZ_ASSERT(false, "ProgressiveUpdate not supported!");
return false;
}
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -1331,30 +1331,32 @@ ClientMultiTiledLayerBuffer::ComputeProg
// We're not repeating painting and we've not requested a repeat transaction,
// so the paint is finished. If there's still a separate low precision
// paint to do, it will get marked as unfinished later.
aPaintData->mPaintFinished = true;
return false;
}
bool
-ClientMultiTiledLayerBuffer::ProgressiveUpdate(nsIntRegion& aValidRegion,
+ClientMultiTiledLayerBuffer::ProgressiveUpdate(const nsIntRegion& aValidRegion,
const nsIntRegion& aInvalidRegion,
const nsIntRegion& aOldValidRegion,
+ nsIntRegion& aOutDrawnRegion,
BasicTiledLayerPaintData* aPaintData,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData)
{
TILING_LOG("TILING %p: Progressive update valid region %s\n", &mPaintedLayer, Stringify(aValidRegion).c_str());
TILING_LOG("TILING %p: Progressive update invalid region %s\n", &mPaintedLayer, Stringify(aInvalidRegion).c_str());
TILING_LOG("TILING %p: Progressive update old valid region %s\n", &mPaintedLayer, Stringify(aOldValidRegion).c_str());
bool repeat = false;
bool isBufferChanged = false;
nsIntRegion remainingInvalidRegion = aInvalidRegion;
+ nsIntRegion updatedValidRegion = aValidRegion;
do {
// Compute the region that should be updated. Repeat as many times as
// is required.
nsIntRegion regionToPaint;
repeat = ComputeProgressiveUpdateRegion(remainingInvalidRegion,
aOldValidRegion,
regionToPaint,
aPaintData,
@@ -1365,31 +1367,32 @@ ClientMultiTiledLayerBuffer::Progressive
// There's no further work to be done.
if (regionToPaint.IsEmpty()) {
break;
}
isBufferChanged = true;
// Keep track of what we're about to refresh.
- aValidRegion.Or(aValidRegion, regionToPaint);
+ aOutDrawnRegion.OrWith(regionToPaint);
+ updatedValidRegion.OrWith(regionToPaint);
// aValidRegion may have been altered by InvalidateRegion, but we still
// want to display stale content until it gets progressively updated.
// Create a region that includes stale content.
nsIntRegion validOrStale;
- validOrStale.Or(aValidRegion, aOldValidRegion);
+ validOrStale.Or(updatedValidRegion, aOldValidRegion);
// Paint the computed region and subtract it from the invalid region.
PaintThebes(validOrStale, regionToPaint, remainingInvalidRegion,
aCallback, aCallbackData, true);
remainingInvalidRegion.SubOut(regionToPaint);
} while (repeat);
- TILING_LOG("TILING %p: Progressive update final valid region %s buffer changed %d\n", &mPaintedLayer, Stringify(aValidRegion).c_str(), isBufferChanged);
+ TILING_LOG("TILING %p: Progressive update final valid region %s buffer changed %d\n", &mPaintedLayer, Stringify(updatedValidRegion).c_str(), isBufferChanged);
TILING_LOG("TILING %p: Progressive update final invalid region %s\n", &mPaintedLayer, Stringify(remainingInvalidRegion).c_str());
// Return false if nothing has been drawn, or give what has been drawn
// to the shadow layer to upload.
return isBufferChanged;
}
void
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -291,19 +291,20 @@ public:
virtual void PaintThebes(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion,
const nsIntRegion& aDirtyRegion,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData,
bool aIsProgressive = false) = 0;
virtual bool SupportsProgressiveUpdate() = 0;
- virtual bool ProgressiveUpdate(nsIntRegion& aValidRegion,
+ virtual bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
const nsIntRegion& aInvalidRegion,
const nsIntRegion& aOldValidRegion,
+ nsIntRegion& aOutDrawnRegion,
BasicTiledLayerPaintData* aPaintData,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData) = 0;
virtual void ResetPaintedAndValidState() = 0;
virtual const nsIntRegion& GetValidRegion() = 0;
virtual bool IsLowPrecision() const = 0;
@@ -349,20 +350,23 @@ public:
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData,
bool aIsProgressive = false) override;
virtual bool SupportsProgressiveUpdate() override { return true; }
/**
* Performs a progressive update of a given tiled buffer.
* See ComputeProgressiveUpdateRegion below for parameter documentation.
+ * aOutDrawnRegion is an outparameter that contains the region that was
+ * drawn, and which can now be added to the layer's valid region.
*/
- bool ProgressiveUpdate(nsIntRegion& aValidRegion,
+ bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
const nsIntRegion& aInvalidRegion,
const nsIntRegion& aOldValidRegion,
+ nsIntRegion& aOutDrawnRegion,
BasicTiledLayerPaintData* aPaintData,
LayerManager::DrawPaintedLayerCallback aCallback,
void* aCallbackData) override;
void ResetPaintedAndValidState() override {
mPaintedRegion.SetEmpty();
mValidRegion.SetEmpty();
mTiles.mSize.width = 0;