Bug 1112476 - Support dumping texture data on the ClientLayerManager. r=mstange

--HG--
extra : rebase_source : 5d5cf3372993ca4af78e12236fc64836a56eff4b
This commit is contained in:
Benoit Girard 2014-12-18 13:32:45 -05:00
parent 750394807d
commit 948f5853f1
17 changed files with 202 additions and 33 deletions

View File

@ -176,6 +176,8 @@ public:
Iterator TilesBegin() { return mRetainedTiles.Elements(); } Iterator TilesBegin() { return mRetainedTiles.Elements(); }
Iterator TilesEnd() { return mRetainedTiles.Elements() + mRetainedTiles.Length(); } Iterator TilesEnd() { return mRetainedTiles.Elements() + mRetainedTiles.Length(); }
void Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml);
protected: protected:
// The implementor should call Update() to change // The implementor should call Update() to change
// the new valid region. This implementation will call // the new valid region. This implementation will call
@ -307,6 +309,38 @@ TiledLayerBuffer<Derived, Tile>::RemoveTile(int x, int y, Tile& aRemovedTile)
return false; return false;
} }
template<typename Derived, typename Tile> void
TiledLayerBuffer<Derived, Tile>::Dump(std::stringstream& aStream,
const char* aPrefix,
bool aDumpHtml)
{
nsIntRect visibleRect = GetValidRegion().GetBounds();
gfx::IntSize scaledTileSize = GetScaledTileSize();
for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) {
int32_t tileStartX = GetTileStart(x, scaledTileSize.width);
int32_t w = scaledTileSize.width - tileStartX;
for (int32_t y = visibleRect.y; y < visibleRect.y + visibleRect.height;) {
int32_t tileStartY = GetTileStart(y, scaledTileSize.height);
Tile tileTexture =
GetTile(nsIntPoint(RoundDownToTileEdge(x, scaledTileSize.width),
RoundDownToTileEdge(y, scaledTileSize.height)));
int32_t h = scaledTileSize.height - tileStartY;
aStream << "\n" << aPrefix << "Tile (x=" <<
RoundDownToTileEdge(x, scaledTileSize.width) << ", y=" <<
RoundDownToTileEdge(y, scaledTileSize.height) << "): ";
if (tileTexture != AsDerived().GetPlaceholderTile()) {
tileTexture.DumpTexture(aStream);
} else {
aStream << "empty tile";
}
y += h;
}
x += w;
}
}
template<typename Derived, typename Tile> void template<typename Derived, typename Tile> void
TiledLayerBuffer<Derived, Tile>::Update(const nsIntRegion& aNewValidRegion, TiledLayerBuffer<Derived, Tile>::Update(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion) const nsIntRegion& aPaintRegion)

View File

@ -176,6 +176,17 @@ ClientLayerManager::CreatePaintedLayerWithHint(PaintedLayerCreationHint aHint)
} }
} }
void
ClientPaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
PaintedLayer::PrintInfo(aStream, aPrefix);
if (mContentClient) {
aStream << "\n";
nsAutoCString pfx(aPrefix);
pfx += " ";
mContentClient->PrintInfo(aStream, pfx.get());
}
}
} }
} }

View File

@ -108,7 +108,9 @@ public:
protected: protected:
void PaintThebes(); void PaintThebes();
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) MOZ_OVERRIDE;
void DestroyBackBuffer() void DestroyBackBuffer()
{ {
mContentClient = nullptr; mContentClient = nullptr;

View File

@ -470,5 +470,17 @@ ClientTiledPaintedLayer::RenderLayer()
EndPaint(); EndPaint();
} }
void
ClientTiledPaintedLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
PaintedLayer::PrintInfo(aStream, aPrefix);
if (mContentClient) {
aStream << "\n";
nsAutoCString pfx(aPrefix);
pfx += " ";
mContentClient->PrintInfo(aStream, pfx.get());
}
}
} // mozilla } // mozilla
} // layers } // layers

View File

@ -47,6 +47,8 @@ public:
protected: protected:
~ClientTiledPaintedLayer(); ~ClientTiledPaintedLayer();
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) MOZ_OVERRIDE;
public: public:
// Override name to distinguish it from ClientPaintedLayer in layer dumps // Override name to distinguish it from ClientPaintedLayer in layer dumps
virtual const char* Name() const { return "TiledPaintedLayer"; } virtual const char* Name() const { return "TiledPaintedLayer"; }

View File

@ -16,6 +16,7 @@
#include "mozilla/layers/TextureD3D11.h" #include "mozilla/layers/TextureD3D11.h"
#include "mozilla/layers/TextureD3D9.h" #include "mozilla/layers/TextureD3D9.h"
#endif #endif
#include "gfxUtils.h"
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -258,5 +259,18 @@ CompositableClient::GetTextureClientRecycler()
return mTextureClientRecycler; return mTextureClientRecycler;
} }
void
CompositableClient::DumpTextureClient(std::stringstream& aStream, TextureClient* aTexture)
{
if (!aTexture) {
return;
}
RefPtr<gfx::DataSourceSurface> dSurf = aTexture->GetAsSurface();
if (!dSurf) {
return;
}
aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
}
} // namespace layers } // namespace layers
} // namespace mozilla } // namespace mozilla

View File

@ -232,6 +232,7 @@ public:
TextureClientRecycleAllocator* GetTextureClientRecycler(); TextureClientRecycleAllocator* GetTextureClientRecycler();
static void DumpTextureClient(std::stringstream& aStream, TextureClient* aTexture);
protected: protected:
CompositableChild* mCompositableChild; CompositableChild* mCompositableChild;
CompositableForwarder* mForwarder; CompositableForwarder* mForwarder;

View File

@ -118,6 +118,20 @@ ContentClient::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
OnTransaction(); OnTransaction();
} }
void
ContentClient::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
aStream << aPrefix;
aStream << nsPrintfCString("ContentClient (0x%p)", this).get();
if (profiler_feature_active("displaylistdump")) {
nsAutoCString pfx(aPrefix);
pfx += " ";
Dump(aStream, pfx.get(), false);
}
}
// We pass a null pointer for the ContentClient Forwarder argument, which means // We pass a null pointer for the ContentClient Forwarder argument, which means
// this client will not have a ContentHost on the other side. // this client will not have a ContentHost on the other side.
ContentClientBasic::ContentClientBasic() ContentClientBasic::ContentClientBasic()
@ -401,6 +415,15 @@ ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
mFrontAndBackBufferDiffer = true; mFrontAndBackBufferDiffer = true;
} }
void
ContentClientRemoteBuffer::Dump(std::stringstream& aStream,
const char* aPrefix,
bool aDumpHtml)
{
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
CompositableClient::DumpTextureClient(aStream, mTextureClient);
}
void void
ContentClientDoubleBuffered::DestroyFrontBuffer() ContentClientDoubleBuffered::DestroyFrontBuffer()
{ {

View File

@ -89,6 +89,11 @@ public:
virtual ~ContentClient() virtual ~ContentClient()
{} {}
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
virtual void Dump(std::stringstream& aStream,
const char* aPrefix="",
bool aDumpHtml=false) {};
virtual void Clear() = 0; virtual void Clear() = 0;
virtual RotatedContentBuffer::PaintState BeginPaintBuffer(PaintedLayer* aLayer, virtual RotatedContentBuffer::PaintState BeginPaintBuffer(PaintedLayer* aLayer,
@ -208,6 +213,10 @@ public:
mTextureClientOnWhite = nullptr; mTextureClientOnWhite = nullptr;
} }
virtual void Dump(std::stringstream& aStream,
const char* aPrefix="",
bool aDumpHtml=false) MOZ_OVERRIDE;
virtual PaintState BeginPaintBuffer(PaintedLayer* aLayer, virtual PaintState BeginPaintBuffer(PaintedLayer* aLayer,
uint32_t aFlags) MOZ_OVERRIDE uint32_t aFlags) MOZ_OVERRIDE
{ {

View File

@ -22,6 +22,10 @@
#include "mozilla/layers/PTextureChild.h" #include "mozilla/layers/PTextureChild.h"
#include "SharedSurface.h" #include "SharedSurface.h"
#include "GLContext.h" #include "GLContext.h"
#include "mozilla/gfx/DataSurfaceHelpers.h" // for CreateDataSourceSurfaceByCloning
#include "nsPrintfCString.h" // for nsPrintfCString
#include "LayersLogging.h" // for AppendToString
#include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str
#ifdef XP_WIN #ifdef XP_WIN
#include "mozilla/layers/TextureD3D9.h" #include "mozilla/layers/TextureD3D9.h"
@ -572,6 +576,28 @@ TextureClient::ShouldDeallocateInDestructor() const
return !IsSharedWithCompositor() || (GetFlags() & TextureFlags::DEALLOCATE_CLIENT); return !IsSharedWithCompositor() || (GetFlags() & TextureFlags::DEALLOCATE_CLIENT);
} }
void
TextureClient::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
aStream << aPrefix;
aStream << nsPrintfCString("TextureClient (0x%p)", this).get();
AppendToString(aStream, GetSize(), " [size=", "]");
AppendToString(aStream, GetFormat(), " [format=", "]");
AppendToString(aStream, mFlags, " [flags=", "]");
#ifdef MOZ_DUMP_PAINTING
if (gfxPrefs::LayersDumpTexture() || profiler_feature_active("layersdump")) {
nsAutoCString pfx(aPrefix);
pfx += " ";
aStream << "\n" << pfx.get() << "Surface: ";
RefPtr<gfx::DataSourceSurface> dSurf = GetAsSurface();
if (dSurf) {
aStream << gfxUtils::GetAsLZ4Base64Str(dSurf).get();
}
}
#endif
}
bool bool
ShmemTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) ShmemTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor)
{ {
@ -866,6 +892,20 @@ BufferTextureClient::GetLockedData() const
return serializer.GetData(); return serializer.GetData();
} }
TemporaryRef<gfx::DataSourceSurface>
BufferTextureClient::GetAsSurface()
{
ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
MOZ_ASSERT(serializer.IsValid());
RefPtr<gfx::DataSourceSurface> wrappingSurf =
gfx::Factory::CreateWrappingDataSourceSurface(serializer.GetData(),
serializer.GetStride(),
serializer.GetSize(),
serializer.GetFormat());
return gfx::CreateDataSourceSurfaceByCloning(wrappingSurf);
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// SharedSurfaceTextureClient // SharedSurfaceTextureClient

View File

@ -281,6 +281,10 @@ public:
return gfx::SurfaceFormat::UNKNOWN; return gfx::SurfaceFormat::UNKNOWN;
} }
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() { return nullptr; }
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
/** /**
* Copies a rectangle from this texture client to a position in aTarget. * Copies a rectangle from this texture client to a position in aTarget.
* It is assumed that the necessary locks are in place; so this should at * It is assumed that the necessary locks are in place; so this should at
@ -584,6 +588,8 @@ public:
gfx::IntSize aCbCrSize, gfx::IntSize aCbCrSize,
StereoMode aStereoMode) MOZ_OVERRIDE; StereoMode aStereoMode) MOZ_OVERRIDE;
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
// XXX - Bug 908196 - Make Allocate(uint32_t) and GetBufferSize() protected. // XXX - Bug 908196 - Make Allocate(uint32_t) and GetBufferSize() protected.

View File

@ -1598,5 +1598,27 @@ ClientTiledLayerBuffer::ProgressiveUpdate(nsIntRegion& aValidRegion,
return isBufferChanged; return isBufferChanged;
} }
void
TiledContentClient::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{
aStream << aPrefix;
aStream << nsPrintfCString("TiledContentClient (0x%p)", this).get();
if (profiler_feature_active("displaylistdump")) {
nsAutoCString pfx(aPrefix);
pfx += " ";
Dump(aStream, pfx.get(), false);
}
}
void
TiledContentClient::Dump(std::stringstream& aStream,
const char* aPrefix,
bool aDumpHtml)
{
mTiledBuffer.Dump(aStream, aPrefix, aDumpHtml);
}
} }
} }

View File

@ -218,6 +218,11 @@ struct TileClient
*/ */
void Flip(); void Flip();
void DumpTexture(std::stringstream& aStream) {
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
CompositableClient::DumpTextureClient(aStream, mFrontBuffer);
}
/** /**
* Returns an unlocked TextureClient that can be used for writing new * Returns an unlocked TextureClient that can be used for writing new
* data to the tile. This may flip the front-buffer to the back-buffer if * data to the tile. This may flip the front-buffer to the back-buffer if
@ -527,6 +532,12 @@ protected:
mLowPrecisionTiledBuffer.Release(); mLowPrecisionTiledBuffer.Release();
} }
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix);
virtual void Dump(std::stringstream& aStream,
const char* aPrefix="",
bool aDumpHtml=false);
public: public:
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{ {

View File

@ -642,38 +642,7 @@ TiledContentHost::Dump(std::stringstream& aStream,
const char* aPrefix, const char* aPrefix,
bool aDumpHtml) bool aDumpHtml)
{ {
nsIntRect visibleRect = mTiledBuffer.GetValidRegion().GetBounds(); mTiledBuffer.Dump(aStream, aPrefix, aDumpHtml);
gfx::IntSize scaledTileSize = mTiledBuffer.GetScaledTileSize();
for (int32_t x = visibleRect.x; x < visibleRect.x + visibleRect.width;) {
int32_t tileStartX = mTiledBuffer.GetTileStart(x, scaledTileSize.width);
int32_t w = scaledTileSize.width - tileStartX;
if (x + w > visibleRect.x + visibleRect.width) {
w = visibleRect.x + visibleRect.width - x;
}
for (int32_t y = visibleRect.y; y < visibleRect.y + visibleRect.height;) {
int32_t tileStartY = mTiledBuffer.GetTileStart(y, scaledTileSize.height);
TileHost tileTexture = mTiledBuffer.
GetTile(nsIntPoint(mTiledBuffer.RoundDownToTileEdge(x, scaledTileSize.width),
mTiledBuffer.RoundDownToTileEdge(y, scaledTileSize.height)));
int32_t h = scaledTileSize.height - tileStartY;
if (y + h > visibleRect.y + visibleRect.height) {
h = visibleRect.y + visibleRect.height - y;
}
aStream << "\n" << aPrefix << "Tile (x=" <<
mTiledBuffer.RoundDownToTileEdge(x, scaledTileSize.width) << ", y=" <<
mTiledBuffer.RoundDownToTileEdge(y, scaledTileSize.height) << "): ";
if (tileTexture != mTiledBuffer.GetPlaceholderTile()) {
DumpTextureHost(aStream, tileTexture.mTextureHost);
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
} else {
aStream << "empty tile";
}
y += h;
}
x += w;
}
} }
} // namespace } // namespace

View File

@ -106,6 +106,11 @@ public:
} }
} }
void DumpTexture(std::stringstream& aStream) {
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
CompositableHost::DumpTextureHost(aStream, mTextureHost);
}
RefPtr<gfxSharedReadLock> mSharedLock; RefPtr<gfxSharedReadLock> mSharedLock;
CompositableTextureHostRef mTextureHost; CompositableTextureHostRef mTextureHost;
CompositableTextureHostRef mTextureHostOnWhite; CompositableTextureHostRef mTextureHostOnWhite;

View File

@ -65,5 +65,11 @@ MacIOSurfaceTextureClientOGL::GetSize() const
return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight()); return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight());
} }
TemporaryRef<gfx::DataSourceSurface>
MacIOSurfaceTextureClientOGL::GetAsSurface()
{
RefPtr<gfx::SourceSurface> surf = mSurface->GetAsSurface();
return surf->GetDataSurface();
}
} }
} }

View File

@ -36,6 +36,8 @@ public:
virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; } virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
// This TextureClient should not be used in a context where we use CreateSimilar // This TextureClient should not be used in a context where we use CreateSimilar
// (ex. component alpha) because the underlying texture data is always created by // (ex. component alpha) because the underlying texture data is always created by
// an external producer. // an external producer.