Bug 1465590 - Kill the nesting in ValidateBackBufferFromFront. r?nical
Just a cleanup patch, this function would be cleaner without the
nesting.
MozReview-Commit-ID: DD48E2HSQOL
--- a/gfx/layers/client/MultiTiledContentClient.cpp
+++ b/gfx/layers/client/MultiTiledContentClient.cpp
@@ -321,17 +321,16 @@ void ClientMultiTiledLayerBuffer::Update
// Reset
mPaintTiles.clear();
mTilingOrigin = IntPoint(std::numeric_limits<int32_t>::max(),
std::numeric_limits<int32_t>::max());
}
bool edgePaddingEnabled = gfxPrefs::TileEdgePaddingEnabled();
-
for (uint32_t i = 0; i < mRetainedTiles.Length(); ++i) {
TileClient& tile = mRetainedTiles[i];
// Only worry about padding when not doing low-res because it simplifies
// the math and the artifacts won't be noticable
// Edge padding prevents sampling artifacts when compositing.
if (edgePaddingEnabled && mResolution == 1 &&
tile.mFrontBuffer && tile.mFrontBuffer->IsLocked()) {
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -478,55 +478,59 @@ CopyFrontToBack(TextureClient* aFront,
void
TileClient::ValidateBackBufferFromFront(const nsIntRegion& aDirtyRegion,
const nsIntRegion& aVisibleRegion,
nsIntRegion& aAddPaintedRegion,
TilePaintFlags aFlags,
std::vector<CapturedTiledPaintState::Copy>* aCopies,
std::vector<RefPtr<TextureClient>>* aClients)
{
- if (mBackBuffer && mFrontBuffer) {
- gfx::IntSize tileSize = mFrontBuffer->GetSize();
- const IntRect tileRect = IntRect(0, 0, tileSize.width, tileSize.height);
+ if (!mBackBuffer || !mFrontBuffer) {
+ return;
+ }
+
+ gfx::IntSize tileSize = mFrontBuffer->GetSize();
+ const IntRect tileRect = IntRect(0, 0, tileSize.width, tileSize.height);
- if (aDirtyRegion.Contains(tileRect)) {
- // The dirty region means that we no longer need the front buffer, so
- // discard it.
- DiscardFrontBuffer();
- } else {
- // Region that needs copying.
- nsIntRegion regionToCopy = mInvalidBack;
+ if (aDirtyRegion.Contains(tileRect)) {
+ // The dirty region means that we no longer need the front buffer, so
+ // discard it.
+ DiscardFrontBuffer();
+ return;
+ }
- regionToCopy.Sub(regionToCopy, aDirtyRegion);
- regionToCopy.And(regionToCopy, aVisibleRegion);
+ // Region that needs copying.
+ nsIntRegion regionToCopy = mInvalidBack;
- aAddPaintedRegion = regionToCopy;
+ regionToCopy.Sub(regionToCopy, aDirtyRegion);
+ regionToCopy.And(regionToCopy, aVisibleRegion);
- if (regionToCopy.IsEmpty()) {
- // Just redraw it all.
- return;
- }
+ aAddPaintedRegion = regionToCopy;
+
+ if (regionToCopy.IsEmpty()) {
+ // Just redraw it all.
+ return;
+ }
- // Copy the bounding rect of regionToCopy. As tiles are quite small, it
- // is unlikely that we'd save much by copying each individual rect of the
- // region, but we can reevaluate this if it becomes an issue.
- const IntRect rectToCopy = regionToCopy.GetBounds();
- gfx::IntRect gfxRectToCopy(rectToCopy.X(), rectToCopy.Y(), rectToCopy.Width(), rectToCopy.Height());
- if (CopyFrontToBack(mFrontBuffer, mBackBuffer, gfxRectToCopy, aFlags, aCopies, aClients)) {
- if (mBackBufferOnWhite) {
- MOZ_ASSERT(mFrontBufferOnWhite);
- if (CopyFrontToBack(mFrontBufferOnWhite, mBackBufferOnWhite, gfxRectToCopy, aFlags, aCopies, aClients)) {
- mInvalidBack.Sub(mInvalidBack, aVisibleRegion);
- }
- } else {
- mInvalidBack.Sub(mInvalidBack, aVisibleRegion);
- }
- }
+ // Copy the bounding rect of regionToCopy. As tiles are quite small, it
+ // is unlikely that we'd save much by copying each individual rect of the
+ // region, but we can reevaluate this if it becomes an issue.
+ const IntRect rectToCopy = regionToCopy.GetBounds();
+ if (!CopyFrontToBack(mFrontBuffer, mBackBuffer, rectToCopy, aFlags, aCopies, aClients)) {
+ return;
+ }
+
+ if (mBackBufferOnWhite) {
+ MOZ_ASSERT(mFrontBufferOnWhite);
+ if (!CopyFrontToBack(mFrontBufferOnWhite, mBackBufferOnWhite, rectToCopy, aFlags, aCopies, aClients)) {
+ return;
}
}
+
+ mInvalidBack.Sub(mInvalidBack, aVisibleRegion);
}
void
TileClient::DiscardFrontBuffer()
{
if (mFrontBuffer) {
MOZ_ASSERT(mFrontBuffer->GetReadLock());