Bug 970327 - Add PNG dump utils for SourceSurface. r=nical

This commit is contained in:
Ali Akhtarzada 2014-02-11 13:41:09 -05:00
parent 2b722685f9
commit ef197a24c4
2 changed files with 58 additions and 0 deletions

View File

@ -885,6 +885,46 @@ gfxUtils::CopyAsDataURL(DrawTarget* aDT)
} }
} }
/* static */ void
gfxUtils::WriteAsPNG(RefPtr<gfx::SourceSurface> aSourceSurface, const char* aFile)
{
RefPtr<gfx::DataSourceSurface> dataSurface = aSourceSurface->GetDataSurface();
RefPtr<gfx::DrawTarget> dt
= gfxPlatform::GetPlatform()
->CreateDrawTargetForData(dataSurface->GetData(),
dataSurface->GetSize(),
dataSurface->Stride(),
aSourceSurface->GetFormat());
gfxUtils::WriteAsPNG(dt.get(), aFile);
}
/* static */ void
gfxUtils::DumpAsDataURL(RefPtr<gfx::SourceSurface> aSourceSurface)
{
RefPtr<gfx::DataSourceSurface> dataSurface = aSourceSurface->GetDataSurface();
RefPtr<gfx::DrawTarget> dt
= gfxPlatform::GetPlatform()
->CreateDrawTargetForData(dataSurface->GetData(),
dataSurface->GetSize(),
dataSurface->Stride(),
aSourceSurface->GetFormat());
gfxUtils::DumpAsDataURL(dt.get());
}
/* static */ void
gfxUtils::CopyAsDataURL(RefPtr<gfx::SourceSurface> aSourceSurface)
{
RefPtr<gfx::DataSourceSurface> dataSurface = aSourceSurface->GetDataSurface();
RefPtr<gfx::DrawTarget> dt
= gfxPlatform::GetPlatform()
->CreateDrawTargetForData(dataSurface->GetData(),
dataSurface->GetSize(),
dataSurface->Stride(),
aSourceSurface->GetFormat());
gfxUtils::CopyAsDataURL(dt.get());
}
bool gfxUtils::sDumpPaintList = getenv("MOZ_DUMP_PAINT_LIST") != 0; bool gfxUtils::sDumpPaintList = getenv("MOZ_DUMP_PAINT_LIST") != 0;
bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0; bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0;
bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0; bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0;

View File

@ -177,6 +177,24 @@ public:
static bool sDumpPainting; static bool sDumpPainting;
static bool sDumpPaintingToFile; static bool sDumpPaintingToFile;
static FILE* sDumpPaintFile; static FILE* sDumpPaintFile;
/**
* Writes a binary PNG file.
* Expensive. Creates a DataSourceSurface, then a DrawTarget, then passes to DrawTarget overloads
*/
static void WriteAsPNG(mozilla::RefPtr<mozilla::gfx::SourceSurface> aSourceSurface, const char* aFile);
/**
* Write as a PNG encoded Data URL to stdout.
* Expensive. Creates a DataSourceSurface, then a DrawTarget, then passes to DrawTarget overloads
*/
static void DumpAsDataURL(mozilla::RefPtr<mozilla::gfx::SourceSurface> aSourceSurface);
/**
* Copy a PNG encoded Data URL to the clipboard.
* Expensive. Creates a DataSourceSurface, then a DrawTarget, then passes to DrawTarget overloads
*/
static void CopyAsDataURL(mozilla::RefPtr<mozilla::gfx::SourceSurface> aSourceSurface);
#endif #endif
}; };