From 0e43c5e14d2c8c5b45eb8f9a016df4e576e89398 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 23 Mar 2015 13:01:02 -0400 Subject: [PATCH] Bug 1145764 - Add logging for tile retention inside a TiledLayerBuffer. r=nical --- gfx/layers/TiledLayerBuffer.h | 70 ++++++++++++++++++++++++ gfx/layers/client/TiledContentClient.cpp | 12 ++++ gfx/layers/client/TiledContentClient.h | 5 ++ gfx/layers/composite/TiledContentHost.h | 4 ++ 4 files changed, 91 insertions(+) diff --git a/gfx/layers/TiledLayerBuffer.h b/gfx/layers/TiledLayerBuffer.h index 829cf53b3905..4dbf7faf0705 100644 --- a/gfx/layers/TiledLayerBuffer.h +++ b/gfx/layers/TiledLayerBuffer.h @@ -8,10 +8,12 @@ // Debug defines //#define GFX_TILEDLAYER_DEBUG_OVERLAY //#define GFX_TILEDLAYER_PREF_WARNINGS +//#define GFX_TILEDLAYER_RETAINING_LOG #include // for uint16_t, uint32_t #include // for int32_t #include "gfxPlatform.h" // for GetTileWidth/GetTileHeight +#include "LayersLogging.h" // for print_stderr #include "mozilla/gfx/Logging.h" // for gfxCriticalError #include "nsDebug.h" // for NS_ASSERTION #include "nsPoint.h" // for nsIntPoint @@ -327,6 +329,22 @@ TiledLayerBuffer::Update(const nsIntRegion& newValidRegion, const nsIntRegion& oldValidRegion = mValidRegion; const int oldRetainedHeight = mRetainedHeight; +#ifdef GFX_TILEDLAYER_RETAINING_LOG + { // scope ss + std::stringstream ss; + ss << "TiledLayerBuffer " << this << " starting update" + << " on bounds "; + AppendToString(ss, newBound); + ss << " with mResolution=" << mResolution << "\n"; + for (size_t i = 0; i < mRetainedTiles.Length(); i++) { + ss << "mRetainedTiles[" << i << "] = "; + mRetainedTiles[i].Dump(ss); + ss << "\n"; + } + print_stderr(ss); + } +#endif + // Pass 1: Recycle valid content from the old buffer // Recycle tiles from the old buffer that contain valid regions. // Insert placeholders tiles if we have no valid area for that tile @@ -396,6 +414,21 @@ TiledLayerBuffer::Update(const nsIntRegion& newValidRegion, mRetainedWidth = tileX; mRetainedHeight = tileY; +#ifdef GFX_TILEDLAYER_RETAINING_LOG + { // scope ss + std::stringstream ss; + ss << "TiledLayerBuffer " << this << " finished pass 1 of update;" + << " tilesMissing=" << tilesMissing << "\n"; + for (size_t i = 0; i < oldRetainedTiles.Length(); i++) { + ss << "oldRetainedTiles[" << i << "] = "; + oldRetainedTiles[i].Dump(ss); + ss << "\n"; + } + print_stderr(ss); + } +#endif + + // Pass 1.5: Release excess tiles in oldRetainedTiles // Tiles in oldRetainedTiles that aren't in newRetainedTiles will be recycled // before creating new ones, but there could still be excess unnecessary @@ -436,6 +469,24 @@ TiledLayerBuffer::Update(const nsIntRegion& newValidRegion, nsIntRegion regionToPaint(aPaintRegion); +#ifdef GFX_TILEDLAYER_RETAINING_LOG + { // scope ss + std::stringstream ss; + ss << "TiledLayerBuffer " << this << " finished pass 1.5 of update\n"; + for (size_t i = 0; i < oldRetainedTiles.Length(); i++) { + ss << "oldRetainedTiles[" << i << "] = "; + oldRetainedTiles[i].Dump(ss); + ss << "\n"; + } + for (size_t i = 0; i < newRetainedTiles.Length(); i++) { + ss << "newRetainedTiles[" << i << "] = "; + newRetainedTiles[i].Dump(ss); + ss << "\n"; + } + print_stderr(ss); + } +#endif + // Pass 2: Validate // We know at this point that any tile in the new buffer that had valid content // from the previous buffer is placed correctly in the new buffer. @@ -530,6 +581,25 @@ TiledLayerBuffer::Update(const nsIntRegion& newValidRegion, AsDerived().UnlockTile(newRetainedTiles[i]); } +#ifdef GFX_TILEDLAYER_RETAINING_LOG + { // scope ss + std::stringstream ss; + ss << "TiledLayerBuffer " << this << " finished pass 2 of update;" + << " oldTileCount=" << oldTileCount << "\n"; + for (size_t i = 0; i < oldRetainedTiles.Length(); i++) { + ss << "oldRetainedTiles[" << i << "] = "; + oldRetainedTiles[i].Dump(ss); + ss << "\n"; + } + for (size_t i = 0; i < newRetainedTiles.Length(); i++) { + ss << "newRetainedTiles[" << i << "] = "; + newRetainedTiles[i].Dump(ss); + ss << "\n"; + } + print_stderr(ss); + } +#endif + // At this point, oldTileCount should be zero MOZ_ASSERT(oldTileCount == 0, "Failed to release old tiles"); diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 274a0d05e71f..8a3ae5899404 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -540,6 +540,18 @@ TileClient::operator=(const TileClient& o) return *this; } +void +TileClient::Dump(std::stringstream& aStream) +{ + aStream << "TileClient(bb=" << (TextureClient*)mBackBuffer << " fb=" << mFrontBuffer.get(); + if (mBackBufferOnWhite) { + aStream << " bbow=" << mBackBufferOnWhite.get(); + } + if (mFrontBufferOnWhite) { + aStream << " fbow=" << mFrontBufferOnWhite.get(); + } + aStream << ")"; +} void TileClient::Flip() diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 52620913c8cf..b54b0a95efdb 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -213,6 +213,11 @@ struct TileClient TileDescriptor GetTileDescriptor(); + /** + * For debugging. + */ + void Dump(std::stringstream& aStream); + /** * Swaps the front and back buffers. */ diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index ee7f221bc18b..359d89e3859d 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -106,6 +106,10 @@ public: } } + void Dump(std::stringstream& aStream) { + aStream << "TileHost(...)"; // fill in as needed + } + void DumpTexture(std::stringstream& aStream) { // TODO We should combine the OnWhite/OnBlack here an just output a single image. CompositableHost::DumpTextureHost(aStream, mTextureHost);