mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Add helper functions for dumping MLGTextures as files. (bug 1381666 part 2, r=mattwoodrow)
This commit is contained in:
parent
b05dbf58c2
commit
4d45c02ee0
@ -354,5 +354,42 @@ MLGDevice::DrawClearRegion(const ClearRegionHelper& aHelper)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MLGDevice::WriteAsPNG(MLGTexture* aTexture, const char* aPath)
|
||||||
|
{
|
||||||
|
MLGMappedResource map;
|
||||||
|
if (!Map(aTexture, MLGMapType::READ, &map)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<DataSourceSurface> surface = Factory::CreateWrappingDataSourceSurface(
|
||||||
|
map.mData,
|
||||||
|
map.mStride,
|
||||||
|
aTexture->GetSize(),
|
||||||
|
SurfaceFormat::B8G8R8A8);
|
||||||
|
gfxUtils::WriteAsPNG(surface, aPath);
|
||||||
|
|
||||||
|
Unmap(aTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<MLGTexture>
|
||||||
|
MLGDevice::CopyAndCreateReadbackTexture(MLGTexture* aTexture)
|
||||||
|
{
|
||||||
|
RefPtr<MLGTexture> copy = CreateTexture(
|
||||||
|
aTexture->GetSize(),
|
||||||
|
SurfaceFormat::B8G8R8A8,
|
||||||
|
MLGUsage::Staging,
|
||||||
|
MLGTextureFlags::None);
|
||||||
|
if (!copy) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
CopyTexture(
|
||||||
|
copy,
|
||||||
|
IntPoint(0, 0),
|
||||||
|
aTexture,
|
||||||
|
IntRect(IntPoint(0, 0), aTexture->GetSize()));
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -430,6 +430,12 @@ public:
|
|||||||
SetPSTexture(aSlot, nullTexture);
|
SetPSTexture(aSlot, nullTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debugging helper function for dumping an MLGTexture to a file.
|
||||||
|
void WriteAsPNG(MLGTexture* aTexture, const char* aPath);
|
||||||
|
|
||||||
|
// Debugging helper function for copying a texture for later dumping to a file.
|
||||||
|
RefPtr<MLGTexture> CopyAndCreateReadbackTexture(MLGTexture* aTexture);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~MLGDevice();
|
virtual ~MLGDevice();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user