Bug 945655 - Improve FilterNodeSoftware debug logging. r=roc

This commit is contained in:
Markus Stange 2013-12-10 14:50:41 +01:00
Родитель 9bb2ea8eed
Коммит 3b7dad0997
2 изменённых файлов: 43 добавлений и 11 удалений

Просмотреть файл

@ -18,7 +18,6 @@
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "gfx2DGlue.h"
namespace mozilla { namespace mozilla {
namespace gfx { namespace gfx {
static void static void
@ -28,7 +27,8 @@ DumpAsPNG(SourceSurface* aSurface)
IntSize size = dataSource->GetSize(); IntSize size = dataSource->GetSize();
nsRefPtr<gfxImageSurface> imageSurface = nsRefPtr<gfxImageSurface> imageSurface =
new gfxImageSurface(dataSource->GetData(), gfxIntSize(size.width, size.height), new gfxImageSurface(dataSource->GetData(), gfxIntSize(size.width, size.height),
dataSource->Stride(), SurfaceFormatToImageFormat(aSurface->GetFormat())); dataSource->Stride(),
aSurface->GetFormat() == FORMAT_A8 ? gfxImageFormatA8 : gfxImageFormatARGB32);
imageSurface->PrintAsDataURL(); imageSurface->PrintAsDataURL();
} }
} // namespace gfx } // namespace gfx
@ -559,7 +559,7 @@ FilterNodeSoftware::Draw(DrawTarget* aDrawTarget,
const DrawOptions &aOptions) const DrawOptions &aOptions)
{ {
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("<pre>\nRendering...\n"); printf("<style>section{margin:10px;}</style><pre>\nRendering filter %s...\n", GetName());
#endif #endif
Rect renderRect = aSourceRect; Rect renderRect = aSourceRect;
@ -583,7 +583,7 @@ FilterNodeSoftware::Draw(DrawTarget* aDrawTarget,
} }
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("output:\n"); printf("output from %s:\n", GetName());
printf("<img src='"); DumpAsPNG(result); printf("'>\n"); printf("<img src='"); DumpAsPNG(result); printf("'>\n");
printf("</pre>\n"); printf("</pre>\n");
#endif #endif
@ -656,7 +656,7 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
const IntRect *aTransparencyPaddedSourceRect) const IntRect *aTransparencyPaddedSourceRect)
{ {
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("<h1>GetInputDataSourceSurface with aRect: %d, %d, %d, %d</h1>\n", printf("<section><h1>GetInputDataSourceSurface with aRect: %d, %d, %d, %d</h1>\n",
aRect.x, aRect.y, aRect.width, aRect.height); aRect.x, aRect.y, aRect.width, aRect.height);
#endif #endif
int32_t inputIndex = InputIndex(aInputEnumIndex); int32_t inputIndex = InputIndex(aInputEnumIndex);
@ -671,34 +671,42 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
RefPtr<SourceSurface> surface; RefPtr<SourceSurface> surface;
IntRect surfaceRect; IntRect surfaceRect;
if (mInputSurfaces[inputIndex]) { if (mInputSurfaces[inputIndex]) {
// Input from input surface
surface = mInputSurfaces[inputIndex]; surface = mInputSurfaces[inputIndex];
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("input from input surface:\n"); printf("input from input surface:\n");
printf("<img src='"); DumpAsPNG(surface); printf("'>\n");
#endif #endif
surfaceRect = IntRect(IntPoint(0, 0), surface->GetSize()); surfaceRect = IntRect(IntPoint(0, 0), surface->GetSize());
} else { } else {
// Input from input filter
#ifdef DEBUG_DUMP_SURFACES
printf("getting input from input filter %s...\n", mInputFilters[inputIndex]->GetName());
#endif
RefPtr<FilterNodeSoftware> filter = mInputFilters[inputIndex]; RefPtr<FilterNodeSoftware> filter = mInputFilters[inputIndex];
MOZ_ASSERT(filter, "missing input"); MOZ_ASSERT(filter, "missing input");
IntRect inputFilterOutput = filter->GetOutputRectInRect(aRect); IntRect inputFilterOutput = filter->GetOutputRectInRect(aRect);
if (!inputFilterOutput.IsEmpty()) { if (!inputFilterOutput.IsEmpty()) {
surface = filter->GetOutput(inputFilterOutput); surface = filter->GetOutput(inputFilterOutput);
} }
#ifdef DEBUG_DUMP_SURFACES
printf("input from input filter %s:\n", mInputFilters[inputIndex]->GetName());
#endif
surfaceRect = inputFilterOutput; surfaceRect = inputFilterOutput;
MOZ_ASSERT(!surface || surfaceRect.Size() == surface->GetSize()); MOZ_ASSERT(!surface || surfaceRect.Size() == surface->GetSize());
} }
if (surface && surface->GetFormat() == FORMAT_UNKNOWN) { if (surface && surface->GetFormat() == FORMAT_UNKNOWN) {
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("wrong input format\n\n"); printf("wrong input format</section>\n\n");
#endif #endif
return nullptr; return nullptr;
} }
if (!surfaceRect.IsEmpty() && !surface) { if (!surfaceRect.IsEmpty() && !surface) {
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf(" -- no input --\n\n"); printf(" -- no input --</section>\n\n");
#endif #endif
return nullptr; return nullptr;
} }
@ -714,7 +722,7 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
if (!result) { if (!result) {
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf(" -- no input --\n\n"); printf(" -- no input --</section>\n\n");
#endif #endif
return nullptr; return nullptr;
} }
@ -732,8 +740,7 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
} }
#ifdef DEBUG_DUMP_SURFACES #ifdef DEBUG_DUMP_SURFACES
printf("input:\n"); printf("<img src='"); DumpAsPNG(result); printf("'></section>");
printf("<img src='"); DumpAsPNG(result); printf("'>\n");
#endif #endif
MOZ_ASSERT(!result || result->GetSize() == aRect.Size(), "wrong surface size"); MOZ_ASSERT(!result || result->GetSize() == aRect.Size(), "wrong surface size");

Просмотреть файл

@ -51,6 +51,8 @@ public:
virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) MOZ_OVERRIDE; virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) MOZ_OVERRIDE;
virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) MOZ_OVERRIDE; virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) MOZ_OVERRIDE;
virtual const char* GetName() { return "Unknown"; }
virtual void AddInvalidationListener(FilterInvalidationListener* aListener); virtual void AddInvalidationListener(FilterInvalidationListener* aListener);
virtual void RemoveInvalidationListener(FilterInvalidationListener* aListener); virtual void RemoveInvalidationListener(FilterInvalidationListener* aListener);
@ -216,6 +218,7 @@ class FilterNodeTransformSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeTransformSoftware(); FilterNodeTransformSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Transform"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, uint32_t aGraphicsFilter) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aGraphicsFilter) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, const Matrix &aMatrix) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Matrix &aMatrix) MOZ_OVERRIDE;
@ -236,6 +239,7 @@ class FilterNodeBlendSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeBlendSoftware(); FilterNodeBlendSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Blend"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, uint32_t aBlendMode) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aBlendMode) MOZ_OVERRIDE;
@ -253,6 +257,7 @@ class FilterNodeMorphologySoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeMorphologySoftware(); FilterNodeMorphologySoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Morphology"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const IntSize &aRadii) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const IntSize &aRadii) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) MOZ_OVERRIDE;
@ -271,6 +276,7 @@ private:
class FilterNodeColorMatrixSoftware : public FilterNodeSoftware class FilterNodeColorMatrixSoftware : public FilterNodeSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "ColorMatrix"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &aMatrix) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Matrix5x4 &aMatrix) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, uint32_t aAlphaMode) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aAlphaMode) MOZ_OVERRIDE;
@ -289,6 +295,7 @@ private:
class FilterNodeFloodSoftware : public FilterNodeSoftware class FilterNodeFloodSoftware : public FilterNodeSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "Flood"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Color &aColor) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Color &aColor) MOZ_OVERRIDE;
@ -304,6 +311,7 @@ private:
class FilterNodeTileSoftware : public FilterNodeSoftware class FilterNodeTileSoftware : public FilterNodeSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "Tile"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const IntRect &aSourceRect) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const IntRect &aSourceRect) MOZ_OVERRIDE;
@ -346,6 +354,7 @@ protected:
class FilterNodeTableTransferSoftware : public FilterNodeComponentTransferSoftware class FilterNodeTableTransferSoftware : public FilterNodeComponentTransferSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "TableTransfer"; }
using FilterNodeComponentTransferSoftware::SetAttribute; using FilterNodeComponentTransferSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE;
@ -364,6 +373,7 @@ private:
class FilterNodeDiscreteTransferSoftware : public FilterNodeComponentTransferSoftware class FilterNodeDiscreteTransferSoftware : public FilterNodeComponentTransferSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "DiscreteTransfer"; }
using FilterNodeComponentTransferSoftware::SetAttribute; using FilterNodeComponentTransferSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE;
@ -383,6 +393,7 @@ class FilterNodeLinearTransferSoftware : public FilterNodeComponentTransferSoftw
{ {
public: public:
FilterNodeLinearTransferSoftware(); FilterNodeLinearTransferSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "LinearTransfer"; }
using FilterNodeComponentTransferSoftware::SetAttribute; using FilterNodeComponentTransferSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float aValue) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float aValue) MOZ_OVERRIDE;
@ -406,6 +417,7 @@ class FilterNodeGammaTransferSoftware : public FilterNodeComponentTransferSoftwa
{ {
public: public:
FilterNodeGammaTransferSoftware(); FilterNodeGammaTransferSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "GammaTransfer"; }
using FilterNodeComponentTransferSoftware::SetAttribute; using FilterNodeComponentTransferSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float aValue) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float aValue) MOZ_OVERRIDE;
@ -433,6 +445,7 @@ class FilterNodeConvolveMatrixSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeConvolveMatrixSoftware(); FilterNodeConvolveMatrixSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "ConvolveMatrix"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const IntSize &aKernelSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const IntSize &aKernelSize) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, const Float* aMatrix, uint32_t aSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Float* aMatrix, uint32_t aSize) MOZ_OVERRIDE;
@ -473,6 +486,7 @@ class FilterNodeDisplacementMapSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeDisplacementMapSoftware(); FilterNodeDisplacementMapSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "DisplacementMap"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float aScale) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float aScale) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) MOZ_OVERRIDE;
@ -495,6 +509,7 @@ class FilterNodeTurbulenceSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeTurbulenceSoftware(); FilterNodeTurbulenceSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Turbulence"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Size &aSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Size &aSize) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, const IntRect &aRenderRect) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const IntRect &aRenderRect) MOZ_OVERRIDE;
@ -519,6 +534,7 @@ class FilterNodeArithmeticCombineSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeArithmeticCombineSoftware(); FilterNodeArithmeticCombineSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "ArithmeticCombine"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, uint32_t aSize) MOZ_OVERRIDE;
@ -539,6 +555,7 @@ class FilterNodeCompositeSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeCompositeSoftware(); FilterNodeCompositeSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Composite"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aOperator) MOZ_OVERRIDE;
@ -571,6 +588,7 @@ class FilterNodeGaussianBlurSoftware : public FilterNodeBlurXYSoftware
{ {
public: public:
FilterNodeGaussianBlurSoftware(); FilterNodeGaussianBlurSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "GaussianBlur"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float aStdDeviation) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float aStdDeviation) MOZ_OVERRIDE;
@ -585,6 +603,7 @@ class FilterNodeDirectionalBlurSoftware : public FilterNodeBlurXYSoftware
{ {
public: public:
FilterNodeDirectionalBlurSoftware(); FilterNodeDirectionalBlurSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "DirectionalBlur"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float aStdDeviation) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float aStdDeviation) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, uint32_t aBlurDirection) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, uint32_t aBlurDirection) MOZ_OVERRIDE;
@ -600,6 +619,7 @@ private:
class FilterNodeCropSoftware : public FilterNodeSoftware class FilterNodeCropSoftware : public FilterNodeSoftware
{ {
public: public:
virtual const char* GetName() MOZ_OVERRIDE { return "Crop"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, const Rect &aSourceRect) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Rect &aSourceRect) MOZ_OVERRIDE;
@ -615,6 +635,8 @@ private:
class FilterNodePremultiplySoftware : public FilterNodeSoftware class FilterNodePremultiplySoftware : public FilterNodeSoftware
{ {
public:
virtual const char* GetName() MOZ_OVERRIDE { return "Premultiply"; }
protected: protected:
virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) MOZ_OVERRIDE; virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) MOZ_OVERRIDE;
virtual IntRect GetOutputRectInRect(const IntRect& aRect) MOZ_OVERRIDE; virtual IntRect GetOutputRectInRect(const IntRect& aRect) MOZ_OVERRIDE;
@ -624,6 +646,8 @@ protected:
class FilterNodeUnpremultiplySoftware : public FilterNodeSoftware class FilterNodeUnpremultiplySoftware : public FilterNodeSoftware
{ {
public:
virtual const char* GetName() MOZ_OVERRIDE { return "Unpremultiply"; }
protected: protected:
virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) MOZ_OVERRIDE; virtual TemporaryRef<DataSourceSurface> Render(const IntRect& aRect) MOZ_OVERRIDE;
virtual IntRect GetOutputRectInRect(const IntRect& aRect) MOZ_OVERRIDE; virtual IntRect GetOutputRectInRect(const IntRect& aRect) MOZ_OVERRIDE;
@ -636,6 +660,7 @@ class FilterNodeLightingSoftware : public FilterNodeSoftware
{ {
public: public:
FilterNodeLightingSoftware(); FilterNodeLightingSoftware();
virtual const char* GetName() MOZ_OVERRIDE { return "Lighting"; }
using FilterNodeSoftware::SetAttribute; using FilterNodeSoftware::SetAttribute;
virtual void SetAttribute(uint32_t aIndex, Float) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, Float) MOZ_OVERRIDE;
virtual void SetAttribute(uint32_t aIndex, const Size &) MOZ_OVERRIDE; virtual void SetAttribute(uint32_t aIndex, const Size &) MOZ_OVERRIDE;