diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 5ca53977cecf..021853298084 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -1464,6 +1464,8 @@ class DrawTargetCapture : public DrawTarget public: virtual bool IsCaptureDT() const override { return true; } + virtual void Dump() = 0; + /** * Returns true if the recording only contains FillGlyph calls with * a single font and color. Returns the list of Glyphs along with diff --git a/gfx/2d/CaptureCommandList.h b/gfx/2d/CaptureCommandList.h index 6c1b406eb5dd..b514364ccbf0 100644 --- a/gfx/2d/CaptureCommandList.h +++ b/gfx/2d/CaptureCommandList.h @@ -12,6 +12,7 @@ #include #include "DrawCommand.h" +#include "Logging.h" namespace mozilla { namespace gfx { @@ -87,6 +88,15 @@ public: uint8_t* mEnd; }; + void Log(TreeLog& aStream) + { + for (iterator iter(*this); !iter.Done(); iter.Next()) { + DrawingCommand* cmd = iter.Get(); + cmd->Log(aStream); + aStream << "\n"; + } + } + private: CaptureCommandList(const CaptureCommandList& aOther) = delete; void operator =(const CaptureCommandList& aOther) = delete; diff --git a/gfx/2d/DrawCommand.h b/gfx/2d/DrawCommand.h index fc9dedef0edd..07dca044a857 100644 --- a/gfx/2d/DrawCommand.h +++ b/gfx/2d/DrawCommand.h @@ -14,6 +14,7 @@ #include "Filters.h" #include #include "FilterNodeCapture.h" +#include "Logging.h" namespace mozilla { namespace gfx { @@ -55,6 +56,7 @@ public: virtual void ExecuteOnDT(DrawTarget* aDT, const Matrix* aTransform = nullptr) const = 0; virtual bool GetAffectedRect(Rect& aDeviceRect, const Matrix& aTransform) const { return false; } virtual void CloneInto(CaptureCommandList* aList) = 0; + virtual void Log(TreeLog& aLog) const = 0; CommandType GetType() { return mType; } diff --git a/gfx/2d/DrawCommands.h b/gfx/2d/DrawCommands.h index fcc11fd10433..d363b39b18cc 100644 --- a/gfx/2d/DrawCommands.h +++ b/gfx/2d/DrawCommands.h @@ -16,6 +16,7 @@ #include "CaptureCommandList.h" #include "DrawCommand.h" #include "FilterNodeCapture.h" +#include "Logging.h" namespace mozilla { namespace gfx { @@ -81,6 +82,16 @@ public: reinterpret_cast(mPattern)->~Pattern(); } + Pattern* Get() + { + return reinterpret_cast(mPattern); + } + + const Pattern* Get() const + { + return reinterpret_cast(mPattern); + } + operator Pattern&() { return *reinterpret_cast(mPattern); @@ -135,6 +146,16 @@ public: aDT->DrawSurface(mSurface, mDest, mSource, mSurfOptions, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[DrawSurface surf=" << mSurface; + aStream << " dest=" << mDest; + aStream << " src=" << mSource; + aStream << " surfOpt=" << mSurfOptions; + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::DRAWSURFACE; @@ -175,6 +196,17 @@ public: aDT->DrawSurfaceWithShadow(mSurface, mDest, mColor, mOffset, mSigma, mOperator); } + void Log(TreeLog& aStream) const override + { + aStream << "[DrawSurfaceWithShadow surf=" << mSurface; + aStream << " dest=" << mDest; + aStream << " color=" << mColor; + aStream << " offset=" << mOffset; + aStream << " sigma=" << mSigma; + aStream << " op=" << mOperator; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::DRAWSURFACEWITHSHADOW; @@ -212,6 +244,15 @@ public: aDT->DrawFilter(filter, mSourceRect, mDestPoint, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[DrawFilter surf=" << mFilter; + aStream << " src=" << mSourceRect; + aStream << " dest=" << mDestPoint; + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::DRAWFILTER; @@ -241,6 +282,11 @@ public: aDT->ClearRect(mRect); } + void Log(TreeLog& aStream) const override + { + aStream << "[ClearRect rect=" << mRect << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::CLEARRECT; @@ -276,6 +322,14 @@ public: aDT->CopySurface(mSurface, mSourceRect, IntPoint(uint32_t(dest.x), uint32_t(dest.y))); } + void Log(TreeLog& aStream) const override + { + aStream << "[CopySurface surf=" << mSurface; + aStream << " src=" << mSourceRect; + aStream << " dest=" << mDestination; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::COPYSURFACE; @@ -314,6 +368,14 @@ public: return true; } + void Log(TreeLog& aStream) const override + { + aStream << "[FillRect rect=" << mRect; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::FILLRECT; @@ -347,6 +409,14 @@ public: aDT->StrokeRect(mRect, mPattern, mStrokeOptions, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[StrokeRect rect=" << mRect; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::STROKERECT; @@ -382,6 +452,15 @@ public: aDT->StrokeLine(mStart, mEnd, mPattern, mStrokeOptions, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[StrokeLine start=" << mStart; + aStream << " end=" << mEnd; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::STROKELINE; @@ -421,6 +500,14 @@ public: return true; } + void Log(TreeLog& aStream) const override + { + aStream << "[FillCommand path=" << mPath; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::FILL; @@ -501,6 +588,14 @@ public: return true; } + void Log(TreeLog& aStream) const override + { + aStream << "[Stroke path=" << mPath; + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::STROKE; @@ -544,6 +639,15 @@ public: aDT->FillGlyphs(mFont, buf, mPattern, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[FillGlyphs font=" << mFont; + aStream << " glyphCount=" << mGlyphs.size(); + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::FILLGLYPHS; @@ -589,6 +693,15 @@ public: aDT->StrokeGlyphs(mFont, buf, mPattern, mStrokeOptions, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[StrokeGlyphs font=" << mFont; + aStream << " glyphCount=" << mGlyphs.size(); + aStream << " pattern=" << mPattern.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::STROKEGLYPHS; @@ -622,6 +735,14 @@ public: aDT->Mask(mSource, mMask, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[Mask source=" << mSource.Get(); + aStream << " mask=" << mMask.Get(); + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::MASK; @@ -656,6 +777,15 @@ public: aDT->MaskSurface(mSource, mMask, mOffset, mOptions); } + void Log(TreeLog& aStream) const override + { + aStream << "[Mask source=" << mSource.Get(); + aStream << " mask=" << mMask; + aStream << " offset=" << &mOffset; + aStream << " opt=" << mOptions; + aStream << "]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::MASKSURFACE; @@ -685,6 +815,11 @@ public: aDT->PushClip(mPath); } + void Log(TreeLog& aStream) const override + { + aStream << "[PushClip path=" << mPath << "]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::PUSHCLIP; @@ -711,6 +846,11 @@ public: aDT->PushClipRect(mRect); } + void Log(TreeLog& aStream) const override + { + aStream << "[PushClipRect rect=" << mRect << "]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::PUSHCLIPRECT; @@ -748,6 +888,17 @@ public: mMaskTransform, mBounds, mCopyBackground); } + void Log(TreeLog& aStream) const override + { + aStream << "[PushLayer opaque=" << mOpaque; + aStream << " opacity=" << mOpacity; + aStream << " mask=" << mMask; + aStream << " maskTransform=" << mMaskTransform; + aStream << " bounds=" << mBounds; + aStream << " copyBackground=" << mCopyBackground; + aStream << "]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::PUSHLAYER; @@ -778,6 +929,11 @@ public: aDT->PopClip(); } + void Log(TreeLog& aStream) const override + { + aStream << "[PopClip]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::POPCLIP; }; @@ -800,6 +956,11 @@ public: aDT->PopLayer(); } + void Log(TreeLog& aStream) const override + { + aStream << "[PopLayer]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::POPLAYER; }; @@ -828,6 +989,11 @@ public: } } + void Log(TreeLog& aStream) const override + { + aStream << "[SetTransform transform=" << mTransform << "]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::SETTRANSFORM; @@ -855,6 +1021,11 @@ public: aDT->SetPermitSubpixelAA(mPermitSubpixelAA); } + void Log(TreeLog& aStream) const override + { + aStream << "[SetPermitSubpixelAA permitSubpixelAA=" << mPermitSubpixelAA << "]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::SETPERMITSUBPIXELAA; @@ -880,6 +1051,11 @@ public: aDT->Flush(); } + void Log(TreeLog& aStream) const override + { + aStream << "[Flush]"; + } + static const bool AffectsSnapshot = false; static const CommandType Type = CommandType::FLUSH; }; @@ -902,6 +1078,11 @@ public: aDT->Blur(mBlur); } + void Log(TreeLog& aStream) const override + { + aStream << "[Blur]"; + } + static const bool AffectsSnapshot = true; static const CommandType Type = CommandType::BLUR; diff --git a/gfx/2d/DrawTargetCapture.cpp b/gfx/2d/DrawTargetCapture.cpp index cca28958b93b..efdffa0b02ca 100644 --- a/gfx/2d/DrawTargetCapture.cpp +++ b/gfx/2d/DrawTargetCapture.cpp @@ -443,5 +443,15 @@ DrawTargetCaptureImpl::CreateFilter(FilterType aType) } } +void +DrawTargetCaptureImpl::Dump() +{ + TreeLog output; + output << "DrawTargetCapture(" << (void*)(this) << ")\n"; + TreeAutoIndent indent(output); + mCommands.Log(output); + output << "\n"; +} + } // namespace gfx } // namespace mozilla diff --git a/gfx/2d/DrawTargetCapture.h b/gfx/2d/DrawTargetCapture.h index 756779b87721..8661fcd7ac2b 100644 --- a/gfx/2d/DrawTargetCapture.h +++ b/gfx/2d/DrawTargetCapture.h @@ -149,6 +149,8 @@ public: bool ContainsOnlyColoredGlyphs(RefPtr& aScaledFont, Color& aColor, std::vector& aGlyphs) override; + void Dump() override; + protected: virtual ~DrawTargetCaptureImpl(); diff --git a/gfx/2d/Logging.h b/gfx/2d/Logging.h index 012a0c744fd0..ee5b370bbcbe 100644 --- a/gfx/2d/Logging.h +++ b/gfx/2d/Logging.h @@ -20,6 +20,7 @@ #if defined(MOZ_WIDGET_ANDROID) #include "nsDebug.h" #endif +#include "2D.h" #include "Point.h" #include "BaseRect.h" #include "Matrix.h" @@ -357,6 +358,12 @@ public: } return *this; } + Log &operator <<(const Color& aColor) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "Color(" << aColor.r << ", " << aColor.g << ", " << aColor.b << ", " << aColor.a << ")"; + } + return *this; + } template Log &operator <<(const BasePoint& aPoint) { if (MOZ_UNLIKELY(LogIt())) { @@ -394,6 +401,205 @@ public: return *this; } + Log &operator<<(const SourceSurface* aSurface) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "SourceSurface(" << (void*)(aSurface) << ")"; + } + return *this; + } + Log &operator<<(const Path* aPath) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "Path(" << (void*)(aPath) << ")"; + } + return *this; + } + Log &operator<<(const Pattern* aPattern) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "Pattern(" << (void*)(aPattern) << ")"; + } + return *this; + } + Log &operator<<(const ScaledFont* aFont) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "ScaledFont(" << (void*)(aFont) << ")"; + } + return *this; + } + Log &operator<<(const FilterNode* aFilter) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "FilterNode(" << (void*)(aFilter) << ")"; + } + return *this; + } + Log &operator<<(const DrawOptions& aOptions) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "DrawOptions(" << aOptions.mAlpha << ", "; + (*this) << aOptions.mCompositionOp; + mMessage << ", "; + (*this) << aOptions.mAntialiasMode; + mMessage << ")"; + } + return *this; + } + Log &operator<<(const DrawSurfaceOptions& aOptions) { + if (MOZ_UNLIKELY(LogIt())) { + mMessage << "DrawSurfaceOptions("; + (*this) << aOptions.mSamplingFilter; + mMessage << ", "; + (*this) << aOptions.mSamplingBounds; + mMessage << ")"; + } + return *this; + } + + Log& operator<<(SamplingBounds aBounds) { + if (MOZ_UNLIKELY(LogIt())) { + switch(aBounds) { + case SamplingBounds::UNBOUNDED: + mMessage << "SamplingBounds::UNBOUNDED"; + break; + case SamplingBounds::BOUNDED: + mMessage << "SamplingBounds::BOUNDED"; + break; + default: + mMessage << "Invalid SamplingBounds (" << (int)aBounds << ")"; + break; + } + } + return *this; + } + Log& operator<<(SamplingFilter aFilter) { + if (MOZ_UNLIKELY(LogIt())) { + switch(aFilter) { + case SamplingFilter::GOOD: + mMessage << "SamplingFilter::GOOD"; + break; + case SamplingFilter::LINEAR: + mMessage << "SamplingFilter::LINEAR"; + break; + case SamplingFilter::POINT: + mMessage << "SamplingFilter::POINT"; + break; + default: + mMessage << "Invalid SamplingFilter (" << (int)aFilter << ")"; + break; + } + } + return *this; + } + Log& operator<<(AntialiasMode aMode) { + if (MOZ_UNLIKELY(LogIt())) { + switch(aMode) { + case AntialiasMode::NONE: + mMessage << "AntialiasMode::NONE"; + break; + case AntialiasMode::GRAY: + mMessage << "AntialiasMode::GRAY"; + break; + case AntialiasMode::SUBPIXEL: + mMessage << "AntialiasMode::SUBPIXEL"; + break; + case AntialiasMode::DEFAULT: + mMessage << "AntialiasMode::DEFAULT"; + break; + default: + mMessage << "Invalid AntialiasMode (" << (int)aMode << ")"; + break; + } + } + return *this; + } + Log& operator<<(CompositionOp aOp) { + if (MOZ_UNLIKELY(LogIt())) { + switch(aOp) { + case CompositionOp::OP_OVER: + mMessage << "CompositionOp::OP_OVER"; + break; + case CompositionOp::OP_ADD: + mMessage << "CompositionOp::OP_ADD"; + break; + case CompositionOp::OP_ATOP: + mMessage << "CompositionOp::OP_ATOP"; + break; + case CompositionOp::OP_OUT: + mMessage << "CompositionOp::OP_OUT"; + break; + case CompositionOp::OP_IN: + mMessage << "CompositionOp::OP_IN"; + break; + case CompositionOp::OP_SOURCE: + mMessage << "CompositionOp::OP_SOURCE"; + break; + case CompositionOp::OP_DEST_IN: + mMessage << "CompositionOp::OP_DEST_IN"; + break; + case CompositionOp::OP_DEST_OUT: + mMessage << "CompositionOp::OP_DEST_OUT"; + break; + case CompositionOp::OP_DEST_OVER: + mMessage << "CompositionOp::OP_DEST_OVER"; + break; + case CompositionOp::OP_DEST_ATOP: + mMessage << "CompositionOp::OP_DEST_ATOP"; + break; + case CompositionOp::OP_XOR: + mMessage << "CompositionOp::OP_XOR"; + break; + case CompositionOp::OP_MULTIPLY: + mMessage << "CompositionOp::OP_MULTIPLY"; + break; + case CompositionOp::OP_SCREEN: + mMessage << "CompositionOp::OP_SCREEN"; + break; + case CompositionOp::OP_OVERLAY: + mMessage << "CompositionOp::OP_OVERLAY"; + break; + case CompositionOp::OP_DARKEN: + mMessage << "CompositionOp::OP_DARKEN"; + break; + case CompositionOp::OP_LIGHTEN: + mMessage << "CompositionOp::OP_LIGHTEN"; + break; + case CompositionOp::OP_COLOR_DODGE: + mMessage << "CompositionOp::OP_COLOR_DODGE"; + break; + case CompositionOp::OP_COLOR_BURN: + mMessage << "CompositionOp::OP_COLOR_BURN"; + break; + case CompositionOp::OP_HARD_LIGHT: + mMessage << "CompositionOp::OP_HARD_LIGHT"; + break; + case CompositionOp::OP_SOFT_LIGHT: + mMessage << "CompositionOp::OP_SOFT_LIGHT"; + break; + case CompositionOp::OP_DIFFERENCE: + mMessage << "CompositionOp::OP_DIFFERENCE"; + break; + case CompositionOp::OP_EXCLUSION: + mMessage << "CompositionOp::OP_EXCLUSION"; + break; + case CompositionOp::OP_HUE: + mMessage << "CompositionOp::OP_HUE"; + break; + case CompositionOp::OP_SATURATION: + mMessage << "CompositionOp::OP_SATURATION"; + break; + case CompositionOp::OP_COLOR: + mMessage << "CompositionOp::OP_COLOR"; + break; + case CompositionOp::OP_LUMINOSITY: + mMessage << "CompositionOp::OP_LUMINOSITY"; + break; + case CompositionOp::OP_COUNT: + mMessage << "CompositionOp::OP_COUNT"; + break; + default: + mMessage << "Invalid CompositionOp (" << (int)aOp << ")"; + break; + } + } + return *this; + } Log& operator<<(SurfaceFormat aFormat) { if (MOZ_UNLIKELY(LogIt())) { switch(aFormat) { @@ -637,7 +843,10 @@ public: return *this; } if (mStartOfLine) { - mLog << '[' << mPrefix << "] " << std::string(mDepth * INDENT_PER_LEVEL, ' '); + if (!mPrefix.empty()) { + mLog << '[' << mPrefix << "] "; + } + mLog << std::string(mDepth * INDENT_PER_LEVEL, ' '); mStartOfLine = false; } mLog << aObject; diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 2f3f78bab91c..1cb34fbf4d64 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -389,6 +389,7 @@ opaque-types = [ "mozilla::dom::Optional", "mozilla::dom::OwningNodeOrString_Value", "mozilla::dom::Nullable", + "mozilla::external::AtomicRefCounted", "RefPtr_Proxy", "RefPtr_Proxy_member_function", "nsAutoPtr_Proxy",