From b3def22e3d5207e72522987d1d5a40b1a1456b38 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Tue, 31 Aug 2021 02:03:58 +0000 Subject: [PATCH] Bug 1728240 - Remove DrawTargetWrapAndRecord and gfx.2d.recording pref. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D124000 --- browser/installer/package-manifest.in | 2 - gfx/2d/2D.h | 8 - gfx/2d/DrawEventRecorder.cpp | 30 - gfx/2d/DrawEventRecorder.h | 36 - gfx/2d/DrawTargetWrapAndRecord.cpp | 753 -------------------- gfx/2d/DrawTargetWrapAndRecord.h | 341 --------- gfx/2d/Factory.cpp | 29 - gfx/2d/Logging.h | 3 - gfx/2d/RecordedEvent.h | 1 - gfx/2d/Types.h | 1 - gfx/2d/moz.build | 2 - gfx/thebes/gfxPlatform.cpp | 45 -- gfx/thebes/gfxPlatform.h | 5 - layout/moz.build | 1 - layout/tools/recording/RecordingCmdLine.jsm | 69 -- layout/tools/recording/components.conf | 15 - layout/tools/recording/jar.mn | 4 - layout/tools/recording/moz.build | 15 - layout/tools/recording/recording.js | 51 -- layout/tools/recording/recording.xhtml | 13 - 20 files changed, 1424 deletions(-) delete mode 100644 gfx/2d/DrawTargetWrapAndRecord.cpp delete mode 100644 gfx/2d/DrawTargetWrapAndRecord.h delete mode 100644 layout/tools/recording/RecordingCmdLine.jsm delete mode 100644 layout/tools/recording/components.conf delete mode 100644 layout/tools/recording/jar.mn delete mode 100644 layout/tools/recording/moz.build delete mode 100644 layout/tools/recording/recording.js delete mode 100644 layout/tools/recording/recording.xhtml diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 87976293ef33..b74da500f0a2 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -239,8 +239,6 @@ @RESPATH@/chrome/pdfjs/* @RESPATH@/chrome/toolkit@JAREXT@ @RESPATH@/chrome/toolkit.manifest -@RESPATH@/chrome/recording.manifest -@RESPATH@/chrome/recording/* #ifdef MOZ_GTK @RESPATH@/browser/chrome/icons/default/default16.png @RESPATH@/browser/chrome/icons/default/default32.png diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 6868cfff6d21..a6b07ec0c86b 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -1839,11 +1839,6 @@ class GFX2D_API Factory { static void CopyDataSourceSurface(DataSourceSurface* aSource, DataSourceSurface* aDest); - static already_AddRefed CreateEventRecorderForFile( - const char_type* aFilename); - - static void SetGlobalEventRecorder(DrawEventRecorder* aRecorder); - static uint32_t GetMaxSurfaceSize(BackendType aType); static LogForwarder* GetLogForwarder() { @@ -1972,9 +1967,6 @@ class GFX2D_API Factory { friend class DrawTargetD2D1; #endif // WIN32 - - private: - static DrawEventRecorder* mRecorder; }; class MOZ_RAII AutoSerializeWithMoz2D final { diff --git a/gfx/2d/DrawEventRecorder.cpp b/gfx/2d/DrawEventRecorder.cpp index 27e65042e0cc..894eb1045c4f 100644 --- a/gfx/2d/DrawEventRecorder.cpp +++ b/gfx/2d/DrawEventRecorder.cpp @@ -81,12 +81,6 @@ void DrawEventRecorderPrivate::DecrementUnscaledFontRefCount( } } -void DrawEventRecorderFile::RecordEvent(const RecordedEvent& aEvent) { - aEvent.RecordToStream(mOutputStream); - - Flush(); -} - void DrawEventRecorderMemory::RecordEvent(const RecordedEvent& aEvent) { aEvent.RecordToStream(mOutputStream); } @@ -99,30 +93,6 @@ nsTHashSet&& DrawEventRecorderMemory::TakeDependentSurfaces() { return std::move(mDependentSurfaces); } -DrawEventRecorderFile::DrawEventRecorderFile(const char_type* aFilename) - : mOutputStream(aFilename, std::ofstream::binary) { - WriteHeader(mOutputStream); -} - -DrawEventRecorderFile::~DrawEventRecorderFile() { mOutputStream.close(); } - -void DrawEventRecorderFile::Flush() { mOutputStream.flush(); } - -bool DrawEventRecorderFile::IsOpen() { return mOutputStream.is_open(); } - -void DrawEventRecorderFile::OpenNew(const char_type* aFilename) { - MOZ_ASSERT(!mOutputStream.is_open()); - - mOutputStream.open(aFilename, std::ofstream::binary); - WriteHeader(mOutputStream); -} - -void DrawEventRecorderFile::Close() { - MOZ_ASSERT(mOutputStream.is_open()); - - mOutputStream.close(); -} - DrawEventRecorderMemory::DrawEventRecorderMemory() { WriteHeader(mOutputStream); } diff --git a/gfx/2d/DrawEventRecorder.h b/gfx/2d/DrawEventRecorder.h index 2d31fa868031..f50b6479a138 100644 --- a/gfx/2d/DrawEventRecorder.h +++ b/gfx/2d/DrawEventRecorder.h @@ -10,7 +10,6 @@ #include "2D.h" #include "RecordedEvent.h" #include "RecordingTypes.h" -#include "mozilla/FStream.h" #include #include @@ -167,41 +166,6 @@ class DrawEventRecorderPrivate : public DrawEventRecorder { bool mExternalFonts; }; -class DrawEventRecorderFile : public DrawEventRecorderPrivate { - using char_type = filesystem::Path::value_type; - - public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawEventRecorderFile, override) - explicit DrawEventRecorderFile(const char_type* aFilename); - virtual ~DrawEventRecorderFile(); - - void RecordEvent(const RecordedEvent& aEvent) override; - - /** - * Returns whether a recording file is currently open. - */ - bool IsOpen(); - - /** - * Opens new file with the provided name. The recorder does NOT forget which - * objects it has recorded. This can be used with Close, so that a recording - * can be processed in chunks. The file must not already be open. - */ - void OpenNew(const char_type* aFilename); - - /** - * Closes the file so that it can be processed. The recorder does NOT forget - * which objects it has recorded. This can be used with OpenNew, so that a - * recording can be processed in chunks. The file must be open. - */ - void Close(); - - private: - void Flush() override; - - mozilla::OFStream mOutputStream; -}; - typedef std::function>& aScaledFonts)> SerializeResourcesFn; diff --git a/gfx/2d/DrawTargetWrapAndRecord.cpp b/gfx/2d/DrawTargetWrapAndRecord.cpp deleted file mode 100644 index e933271a24ff..000000000000 --- a/gfx/2d/DrawTargetWrapAndRecord.cpp +++ /dev/null @@ -1,753 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "DrawTargetWrapAndRecord.h" -#include "PathRecording.h" -#include - -#include "Logging.h" -#include "Tools.h" -#include "Filters.h" -#include "mozilla/UniquePtr.h" -#include "RecordingTypes.h" -#include "RecordedEventImpl.h" - -namespace mozilla { -namespace gfx { - -struct WrapAndRecordSourceSurfaceUserData { - void* refPtr; - RefPtr recorder; -}; - -static void WrapAndRecordSourceSurfaceUserDataFunc(void* aUserData) { - WrapAndRecordSourceSurfaceUserData* userData = - static_cast(aUserData); - - userData->recorder->RecordSourceSurfaceDestruction( - static_cast(userData->refPtr)); - - delete userData; -} - -static void StoreSourceSurface(DrawEventRecorderPrivate* aRecorder, - SourceSurface* aSurface, - DataSourceSurface* aDataSurf, - const char* reason) { - if (!aDataSurf) { - gfxWarning() << "Recording failed to record SourceSurface for " << reason; - // Insert a bogus source surface. - int32_t stride = - aSurface->GetSize().width * BytesPerPixel(aSurface->GetFormat()); - UniquePtr sourceData( - new uint8_t[stride * aSurface->GetSize().height]()); - aRecorder->RecordEvent(RecordedSourceSurfaceCreation( - aSurface, sourceData.get(), stride, aSurface->GetSize(), - aSurface->GetFormat())); - } else { - DataSourceSurface::ScopedMap map(aDataSurf, DataSourceSurface::READ); - aRecorder->RecordEvent(RecordedSourceSurfaceCreation( - aSurface, map.GetData(), map.GetStride(), aDataSurf->GetSize(), - aDataSurf->GetFormat())); - } -} - -static void EnsureSurfaceStored(DrawEventRecorderPrivate* aRecorder, - SourceSurface* aSurface, const char* reason) { - if (aRecorder->HasStoredObject(aSurface)) { - return; - } - - RefPtr dataSurf = aSurface->GetDataSurface(); - StoreSourceSurface(aRecorder, aSurface, dataSurf, reason); - aRecorder->AddStoredObject(aSurface); - aRecorder->AddSourceSurface(aSurface); - - WrapAndRecordSourceSurfaceUserData* userData = - new WrapAndRecordSourceSurfaceUserData; - userData->refPtr = aSurface; - userData->recorder = aRecorder; - aSurface->AddUserData(reinterpret_cast(aRecorder), userData, - &WrapAndRecordSourceSurfaceUserDataFunc); -} - -class SourceSurfaceWrapAndRecord : public SourceSurface { - public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceWrapAndRecord, override) - - SourceSurfaceWrapAndRecord(SourceSurface* aFinalSurface, - DrawEventRecorderPrivate* aRecorder) - : mFinalSurface(aFinalSurface), mRecorder(aRecorder) { - mRecorder->AddStoredObject(this); - } - - ~SourceSurfaceWrapAndRecord() { - mRecorder->RemoveStoredObject(this); - mRecorder->RecordEvent( - RecordedSourceSurfaceDestruction(ReferencePtr(this))); - } - - SurfaceType GetType() const override { return SurfaceType::WRAP_AND_RECORD; } - IntSize GetSize() const override { return mFinalSurface->GetSize(); } - SurfaceFormat GetFormat() const override { - return mFinalSurface->GetFormat(); - } - already_AddRefed GetDataSurface() override { - return mFinalSurface->GetDataSurface(); - } - - RefPtr mFinalSurface; - RefPtr mRecorder; -}; - -class GradientStopsWrapAndRecord : public GradientStops { - public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GradientStopsWrapAndRecord, override) - - GradientStopsWrapAndRecord(GradientStops* aFinalGradientStops, - DrawEventRecorderPrivate* aRecorder) - : mFinalGradientStops(aFinalGradientStops), mRecorder(aRecorder) { - mRecorder->AddStoredObject(this); - } - - ~GradientStopsWrapAndRecord() { - mRecorder->RemoveStoredObject(this); - mRecorder->RecordEvent( - RecordedGradientStopsDestruction(ReferencePtr(this))); - } - - BackendType GetBackendType() const override { return BackendType::RECORDING; } - - RefPtr mFinalGradientStops; - RefPtr mRecorder; -}; - -static SourceSurface* GetSourceSurface(SourceSurface* aSurface) { - if (aSurface->GetType() != SurfaceType::WRAP_AND_RECORD) { - return aSurface; - } - - return static_cast(aSurface)->mFinalSurface; -} - -static already_AddRefed GetGradientStops(GradientStops* aStops) { - if (aStops->GetBackendType() != BackendType::RECORDING) { - return do_AddRef(aStops); - } - - return do_AddRef( - static_cast(aStops)->mFinalGradientStops); -} - -class FilterNodeWrapAndRecord : public FilterNode { - public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeWrapAndRecord, override) - using FilterNode::SetAttribute; - - FilterNodeWrapAndRecord(FilterNode* aFinalFilterNode, - DrawEventRecorderPrivate* aRecorder) - : mFinalFilterNode(aFinalFilterNode), mRecorder(aRecorder) { - mRecorder->AddStoredObject(this); - } - - ~FilterNodeWrapAndRecord() { - mRecorder->RemoveStoredObject(this); - mRecorder->RecordEvent(RecordedFilterNodeDestruction(ReferencePtr(this))); - } - - static FilterNode* GetFilterNode(FilterNode* aNode) { - if (aNode->GetBackendType() != FILTER_BACKEND_RECORDING) { - gfxWarning() - << "Non recording filter node used with recording DrawTarget!"; - return aNode; - } - - return static_cast(aNode)->mFinalFilterNode; - } - - void SetInput(uint32_t aIndex, SourceSurface* aSurface) override { - EnsureSurfaceStored(mRecorder, aSurface, "SetInput"); - - mRecorder->RecordEvent(RecordedFilterNodeSetInput(this, aIndex, aSurface)); - mFinalFilterNode->SetInput(aIndex, GetSourceSurface(aSurface)); - } - void SetInput(uint32_t aIndex, FilterNode* aFilter) override { - MOZ_ASSERT(mRecorder->HasStoredObject(aFilter)); - - mRecorder->RecordEvent(RecordedFilterNodeSetInput(this, aIndex, aFilter)); - mFinalFilterNode->SetInput(aIndex, GetFilterNode(aFilter)); - } - -#define FORWARD_SET_ATTRIBUTE(type, argtype) \ - void SetAttribute(uint32_t aIndex, type aValue) override { \ - mRecorder->RecordEvent(RecordedFilterNodeSetAttribute( \ - this, aIndex, aValue, \ - RecordedFilterNodeSetAttribute::ARGTYPE_##argtype)); \ - mFinalFilterNode->SetAttribute(aIndex, aValue); \ - } - - FORWARD_SET_ATTRIBUTE(bool, BOOL); - FORWARD_SET_ATTRIBUTE(uint32_t, UINT32); - FORWARD_SET_ATTRIBUTE(Float, FLOAT); - FORWARD_SET_ATTRIBUTE(const Size&, SIZE); - FORWARD_SET_ATTRIBUTE(const IntSize&, INTSIZE); - FORWARD_SET_ATTRIBUTE(const IntPoint&, INTPOINT); - FORWARD_SET_ATTRIBUTE(const Rect&, RECT); - FORWARD_SET_ATTRIBUTE(const IntRect&, INTRECT); - FORWARD_SET_ATTRIBUTE(const Point&, POINT); - FORWARD_SET_ATTRIBUTE(const Matrix&, MATRIX); - FORWARD_SET_ATTRIBUTE(const Matrix5x4&, MATRIX5X4); - FORWARD_SET_ATTRIBUTE(const Point3D&, POINT3D); - FORWARD_SET_ATTRIBUTE(const DeviceColor&, COLOR); - -#undef FORWARD_SET_ATTRIBUTE - - virtual void SetAttribute(uint32_t aIndex, const Float* aFloat, - uint32_t aSize) override { - mRecorder->RecordEvent( - RecordedFilterNodeSetAttribute(this, aIndex, aFloat, aSize)); - mFinalFilterNode->SetAttribute(aIndex, aFloat, aSize); - } - - FilterBackend GetBackendType() override { return FILTER_BACKEND_RECORDING; } - - RefPtr mFinalFilterNode; - RefPtr mRecorder; -}; - -struct AdjustedPattern final { - explicit AdjustedPattern(const Pattern& aPattern) : mPattern(nullptr) { - mOrigPattern = const_cast(&aPattern); - } - - ~AdjustedPattern() { - if (mPattern) { - mPattern->~Pattern(); - } - } - - operator Pattern*() { - switch (mOrigPattern->GetType()) { - case PatternType::COLOR: - return mOrigPattern; - case PatternType::SURFACE: { - SurfacePattern* surfPat = static_cast(mOrigPattern); - mPattern = new (mSurfPat) SurfacePattern( - GetSourceSurface(surfPat->mSurface), surfPat->mExtendMode, - surfPat->mMatrix, surfPat->mSamplingFilter, surfPat->mSamplingRect); - return mPattern; - } - case PatternType::LINEAR_GRADIENT: { - LinearGradientPattern* linGradPat = - static_cast(mOrigPattern); - mPattern = new (mLinGradPat) LinearGradientPattern( - linGradPat->mBegin, linGradPat->mEnd, - GetGradientStops(linGradPat->mStops), linGradPat->mMatrix); - return mPattern; - } - case PatternType::RADIAL_GRADIENT: { - RadialGradientPattern* radGradPat = - static_cast(mOrigPattern); - mPattern = new (mRadGradPat) RadialGradientPattern( - radGradPat->mCenter1, radGradPat->mCenter2, radGradPat->mRadius1, - radGradPat->mRadius2, GetGradientStops(radGradPat->mStops), - radGradPat->mMatrix); - return mPattern; - } - case PatternType::CONIC_GRADIENT: { - ConicGradientPattern* conGradPat = - static_cast(mOrigPattern); - mPattern = new (mConGradPat) ConicGradientPattern( - conGradPat->mCenter, conGradPat->mAngle, conGradPat->mStartOffset, - conGradPat->mEndOffset, GetGradientStops(conGradPat->mStops), - conGradPat->mMatrix); - return mPattern; - } - default: - return new (mColPat) ColorPattern(DeviceColor()); - } - - return mPattern; - } - - union { - char mColPat[sizeof(ColorPattern)]; - char mLinGradPat[sizeof(LinearGradientPattern)]; - char mRadGradPat[sizeof(RadialGradientPattern)]; - char mConGradPat[sizeof(ConicGradientPattern)]; - char mSurfPat[sizeof(SurfacePattern)]; - }; - - Pattern* mOrigPattern; - Pattern* mPattern; -}; - -DrawTargetWrapAndRecord::DrawTargetWrapAndRecord(DrawEventRecorder* aRecorder, - DrawTarget* aDT, bool aHasData) - : mRecorder(static_cast(aRecorder)), - mFinalDT(aDT) { - RefPtr snapshot = aHasData ? mFinalDT->Snapshot() : nullptr; - mRecorder->RecordEvent(RecordedDrawTargetCreation( - this, mFinalDT->GetBackendType(), mFinalDT->GetRect(), - mFinalDT->GetFormat(), aHasData, snapshot)); - mFormat = mFinalDT->GetFormat(); -} - -DrawTargetWrapAndRecord::DrawTargetWrapAndRecord( - const DrawTargetWrapAndRecord* aDT, DrawTarget* aSimilarDT) - : mRecorder(aDT->mRecorder), mFinalDT(aSimilarDT) { - mRecorder->RecordEvent(RecordedCreateSimilarDrawTarget( - this, mFinalDT->GetSize(), mFinalDT->GetFormat())); - mFormat = mFinalDT->GetFormat(); -} - -DrawTargetWrapAndRecord::~DrawTargetWrapAndRecord() { - mRecorder->RecordEvent( - RecordedDrawTargetDestruction(static_cast(this))); -} - -void DrawTargetWrapAndRecord::FillRect(const Rect& aRect, - const Pattern& aPattern, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aPattern); - - mRecorder->RecordEvent(RecordedFillRect(this, aRect, aPattern, aOptions)); - mFinalDT->FillRect(aRect, *AdjustedPattern(aPattern), aOptions); -} - -void DrawTargetWrapAndRecord::StrokeRect(const Rect& aRect, - const Pattern& aPattern, - const StrokeOptions& aStrokeOptions, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aPattern); - - mRecorder->RecordEvent( - RecordedStrokeRect(this, aRect, aPattern, aStrokeOptions, aOptions)); - mFinalDT->StrokeRect(aRect, *AdjustedPattern(aPattern), aStrokeOptions, - aOptions); -} - -void DrawTargetWrapAndRecord::StrokeLine(const Point& aBegin, const Point& aEnd, - const Pattern& aPattern, - const StrokeOptions& aStrokeOptions, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aPattern); - - mRecorder->RecordEvent(RecordedStrokeLine(this, aBegin, aEnd, aPattern, - aStrokeOptions, aOptions)); - mFinalDT->StrokeLine(aBegin, aEnd, *AdjustedPattern(aPattern), aStrokeOptions, - aOptions); -} - -void DrawTargetWrapAndRecord::Fill(const Path* aPath, const Pattern& aPattern, - const DrawOptions& aOptions) { - RefPtr pathWrapAndRecord = EnsurePathStored(aPath); - EnsurePatternDependenciesStored(aPattern); - - mRecorder->RecordEvent( - RecordedFill(this, pathWrapAndRecord, aPattern, aOptions)); - mFinalDT->Fill(pathWrapAndRecord->mPath, *AdjustedPattern(aPattern), - aOptions); -} - -struct WrapAndRecordFontUserData { - void* refPtr; - void* unscaledFont; - RefPtr recorder; -}; - -static void WrapAndRecordFontUserDataDestroyFunc(void* aUserData) { - WrapAndRecordFontUserData* userData = - static_cast(aUserData); - - userData->recorder->RecordEvent( - RecordedScaledFontDestruction(ReferencePtr(userData->refPtr))); - userData->recorder->RemoveScaledFont((ScaledFont*)userData->refPtr); - userData->recorder->DecrementUnscaledFontRefCount(userData->unscaledFont); - delete userData; -} - -void DrawTargetWrapAndRecord::FillGlyphs(ScaledFont* aFont, - const GlyphBuffer& aBuffer, - const Pattern& aPattern, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aPattern); - - UserDataKey* userDataKey = reinterpret_cast(mRecorder.get()); - if (!aFont->GetUserData(userDataKey)) { - UnscaledFont* unscaledFont = aFont->GetUnscaledFont(); - if (mRecorder->IncrementUnscaledFontRefCount(unscaledFont) == 0) { - RecordedFontData fontData(unscaledFont); - RecordedFontDetails fontDetails; - if (fontData.GetFontDetails(fontDetails)) { - // Try to serialise the whole font, just in case this is a web font that - // is not present on the system. - if (!mRecorder->HasStoredFontData(fontDetails.fontDataKey)) { - mRecorder->RecordEvent(fontData); - mRecorder->AddStoredFontData(fontDetails.fontDataKey); - } - mRecorder->RecordEvent( - RecordedUnscaledFontCreation(unscaledFont, fontDetails)); - } else { - // If that fails, record just the font description and try to load it - // from the system on the other side. - RecordedFontDescriptor fontDesc(unscaledFont); - if (fontDesc.IsValid()) { - mRecorder->RecordEvent(fontDesc); - } else { - gfxWarning() << "DrawTargetWrapAndRecord::FillGlyphs failed to " - "serialise UnscaledFont"; - } - } - } - - mRecorder->RecordEvent(RecordedScaledFontCreation(aFont, unscaledFont)); - - WrapAndRecordFontUserData* userData = new WrapAndRecordFontUserData; - userData->refPtr = aFont; - userData->unscaledFont = unscaledFont; - userData->recorder = mRecorder; - aFont->AddUserData(userDataKey, userData, - &WrapAndRecordFontUserDataDestroyFunc); - userData->recorder->AddScaledFont(aFont); - } - - mRecorder->RecordEvent(RecordedFillGlyphs( - this, aFont, aPattern, aOptions, aBuffer.mGlyphs, aBuffer.mNumGlyphs)); - mFinalDT->FillGlyphs(aFont, aBuffer, *AdjustedPattern(aPattern), aOptions); -} - -void DrawTargetWrapAndRecord::Mask(const Pattern& aSource, const Pattern& aMask, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aSource); - EnsurePatternDependenciesStored(aMask); - - mRecorder->RecordEvent(RecordedMask(this, aSource, aMask, aOptions)); - mFinalDT->Mask(*AdjustedPattern(aSource), *AdjustedPattern(aMask), aOptions); -} - -void DrawTargetWrapAndRecord::MaskSurface(const Pattern& aSource, - SourceSurface* aMask, Point aOffset, - const DrawOptions& aOptions) { - EnsurePatternDependenciesStored(aSource); - EnsureSurfaceStored(mRecorder, aMask, "MaskSurface"); - - mRecorder->RecordEvent( - RecordedMaskSurface(this, aSource, aMask, aOffset, aOptions)); - mFinalDT->MaskSurface(*AdjustedPattern(aSource), GetSourceSurface(aMask), - aOffset, aOptions); -} - -void DrawTargetWrapAndRecord::Stroke(const Path* aPath, const Pattern& aPattern, - const StrokeOptions& aStrokeOptions, - const DrawOptions& aOptions) { - RefPtr pathWrapAndRecord = EnsurePathStored(aPath); - EnsurePatternDependenciesStored(aPattern); - - mRecorder->RecordEvent(RecordedStroke(this, pathWrapAndRecord, aPattern, - aStrokeOptions, aOptions)); - mFinalDT->Stroke(pathWrapAndRecord->mPath, *AdjustedPattern(aPattern), - aStrokeOptions, aOptions); -} - -already_AddRefed DrawTargetWrapAndRecord::Snapshot() { - RefPtr surf = mFinalDT->Snapshot(); - - RefPtr retSurf = - new SourceSurfaceWrapAndRecord(surf, mRecorder); - - mRecorder->RecordEvent(RecordedSnapshot(retSurf, this)); - - return retSurf.forget(); -} - -already_AddRefed DrawTargetWrapAndRecord::IntoLuminanceSource( - LuminanceType aLuminanceType, float aOpacity) { - RefPtr surf = - mFinalDT->IntoLuminanceSource(aLuminanceType, aOpacity); - - RefPtr retSurf = - new SourceSurfaceWrapAndRecord(surf, mRecorder); - - mRecorder->RecordEvent( - RecordedIntoLuminanceSource(retSurf, this, aLuminanceType, aOpacity)); - - return retSurf.forget(); -} - -void DrawTargetWrapAndRecord::DetachAllSnapshots() { - mFinalDT->DetachAllSnapshots(); -} - -void DrawTargetWrapAndRecord::DrawSurface( - SourceSurface* aSurface, const Rect& aDest, const Rect& aSource, - const DrawSurfaceOptions& aSurfOptions, const DrawOptions& aOptions) { - EnsureSurfaceStored(mRecorder, aSurface, "DrawSurface"); - - mRecorder->RecordEvent(RecordedDrawSurface(this, aSurface, aDest, aSource, - aSurfOptions, aOptions)); - mFinalDT->DrawSurface(GetSourceSurface(aSurface), aDest, aSource, - aSurfOptions, aOptions); -} - -void DrawTargetWrapAndRecord::DrawDependentSurface(uint64_t aId, - const Rect& aDest) { - mRecorder->AddDependentSurface(aId); - mRecorder->RecordEvent(RecordedDrawDependentSurface(this, aId, aDest)); -} - -void DrawTargetWrapAndRecord::DrawSurfaceWithShadow( - SourceSurface* aSurface, const Point& aDest, const DeviceColor& aColor, - const Point& aOffset, Float aSigma, CompositionOp aOp) { - EnsureSurfaceStored(mRecorder, aSurface, "DrawSurfaceWithShadow"); - - mRecorder->RecordEvent(RecordedDrawSurfaceWithShadow( - this, aSurface, aDest, aColor, aOffset, aSigma, aOp)); - mFinalDT->DrawSurfaceWithShadow(GetSourceSurface(aSurface), aDest, aColor, - aOffset, aSigma, aOp); -} - -void DrawTargetWrapAndRecord::DrawFilter(FilterNode* aNode, - const Rect& aSourceRect, - const Point& aDestPoint, - const DrawOptions& aOptions) { - MOZ_ASSERT(mRecorder->HasStoredObject(aNode)); - - mRecorder->RecordEvent( - RecordedDrawFilter(this, aNode, aSourceRect, aDestPoint, aOptions)); - mFinalDT->DrawFilter(FilterNodeWrapAndRecord::GetFilterNode(aNode), - aSourceRect, aDestPoint, aOptions); -} - -already_AddRefed DrawTargetWrapAndRecord::CreateFilter( - FilterType aType) { - RefPtr node = mFinalDT->CreateFilter(aType); - - RefPtr retNode = new FilterNodeWrapAndRecord(node, mRecorder); - - mRecorder->RecordEvent(RecordedFilterNodeCreation(retNode, aType)); - - return retNode.forget(); -} - -void DrawTargetWrapAndRecord::ClearRect(const Rect& aRect) { - mRecorder->RecordEvent(RecordedClearRect(this, aRect)); - mFinalDT->ClearRect(aRect); -} - -void DrawTargetWrapAndRecord::CopySurface(SourceSurface* aSurface, - const IntRect& aSourceRect, - const IntPoint& aDestination) { - EnsureSurfaceStored(mRecorder, aSurface, "CopySurface"); - - mRecorder->RecordEvent( - RecordedCopySurface(this, aSurface, aSourceRect, aDestination)); - mFinalDT->CopySurface(GetSourceSurface(aSurface), aSourceRect, aDestination); -} - -void DrawTargetWrapAndRecord::PushClip(const Path* aPath) { - RefPtr pathWrapAndRecord = EnsurePathStored(aPath); - - mRecorder->RecordEvent(RecordedPushClip(this, pathWrapAndRecord)); - mFinalDT->PushClip(pathWrapAndRecord->mPath); -} - -void DrawTargetWrapAndRecord::PushClipRect(const Rect& aRect) { - mRecorder->RecordEvent(RecordedPushClipRect(this, aRect)); - mFinalDT->PushClipRect(aRect); -} - -void DrawTargetWrapAndRecord::PopClip() { - mRecorder->RecordEvent(RecordedPopClip(static_cast(this))); - mFinalDT->PopClip(); -} - -void DrawTargetWrapAndRecord::PushLayer(bool aOpaque, Float aOpacity, - SourceSurface* aMask, - const Matrix& aMaskTransform, - const IntRect& aBounds, - bool aCopyBackground) { - if (aMask) { - EnsureSurfaceStored(mRecorder, aMask, "PushLayer"); - } - - mRecorder->RecordEvent(RecordedPushLayer(this, aOpaque, aOpacity, aMask, - aMaskTransform, aBounds, - aCopyBackground)); - mFinalDT->PushLayer(aOpaque, aOpacity, aMask, aMaskTransform, aBounds, - aCopyBackground); -} - -void DrawTargetWrapAndRecord::PopLayer() { - mRecorder->RecordEvent(RecordedPopLayer(static_cast(this))); - mFinalDT->PopLayer(); -} - -already_AddRefed -DrawTargetWrapAndRecord::CreateSourceSurfaceFromData( - unsigned char* aData, const IntSize& aSize, int32_t aStride, - SurfaceFormat aFormat) const { - RefPtr surf = - mFinalDT->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat); - - RefPtr retSurf = - new SourceSurfaceWrapAndRecord(surf, mRecorder); - - mRecorder->RecordEvent( - RecordedSourceSurfaceCreation(retSurf, aData, aStride, aSize, aFormat)); - - return retSurf.forget(); -} - -already_AddRefed DrawTargetWrapAndRecord::OptimizeSourceSurface( - SourceSurface* aSurface) const { - RefPtr surf = mFinalDT->OptimizeSourceSurface(aSurface); - - RefPtr retSurf = - new SourceSurfaceWrapAndRecord(surf, mRecorder); - - RefPtr dataSurf = surf->GetDataSurface(); - - if (!dataSurf) { - // Let's try get it off the original surface. - dataSurf = aSurface->GetDataSurface(); - } - - StoreSourceSurface(mRecorder, retSurf, dataSurf, "OptimizeSourceSurface"); - - return retSurf.forget(); -} - -already_AddRefed -DrawTargetWrapAndRecord::CreateSourceSurfaceFromNativeSurface( - const NativeSurface& aSurface) const { - RefPtr surf = - mFinalDT->CreateSourceSurfaceFromNativeSurface(aSurface); - - RefPtr retSurf = - new SourceSurfaceWrapAndRecord(surf, mRecorder); - - RefPtr dataSurf = surf->GetDataSurface(); - StoreSourceSurface(mRecorder, retSurf, dataSurf, - "CreateSourceSurfaceFromNativeSurface"); - - return retSurf.forget(); -} - -already_AddRefed DrawTargetWrapAndRecord::CreateSimilarDrawTarget( - const IntSize& aSize, SurfaceFormat aFormat) const { - RefPtr similarDT = - mFinalDT->CreateSimilarDrawTarget(aSize, aFormat); - if (!similarDT) { - return nullptr; - } - - similarDT = new DrawTargetWrapAndRecord(this, similarDT); - return similarDT.forget(); -} - -bool DrawTargetWrapAndRecord::CanCreateSimilarDrawTarget( - const IntSize& aSize, SurfaceFormat aFormat) const { - return mFinalDT->CanCreateSimilarDrawTarget(aSize, aFormat); -} - -RefPtr DrawTargetWrapAndRecord::CreateClippedDrawTarget( - const Rect& aBounds, SurfaceFormat aFormat) { - RefPtr similarDT; - RefPtr innerDT = - mFinalDT->CreateClippedDrawTarget(aBounds, aFormat); - similarDT = new DrawTargetWrapAndRecord(this->mRecorder, innerDT); - mRecorder->RecordEvent( - RecordedCreateClippedDrawTarget(this, similarDT.get(), aBounds, aFormat)); - similarDT->SetTransform(mTransform); - return similarDT; -} - -already_AddRefed DrawTargetWrapAndRecord::CreatePathBuilder( - FillRule aFillRule) const { - RefPtr builder = mFinalDT->CreatePathBuilder(aFillRule); - return MakeAndAddRef(builder, aFillRule); -} - -already_AddRefed DrawTargetWrapAndRecord::CreateGradientStops( - GradientStop* aStops, uint32_t aNumStops, ExtendMode aExtendMode) const { - RefPtr stops = - mFinalDT->CreateGradientStops(aStops, aNumStops, aExtendMode); - - RefPtr retStops = - new GradientStopsWrapAndRecord(stops, mRecorder); - - mRecorder->RecordEvent( - RecordedGradientStopsCreation(retStops, aStops, aNumStops, aExtendMode)); - - return retStops.forget(); -} - -void DrawTargetWrapAndRecord::SetTransform(const Matrix& aTransform) { - mRecorder->RecordEvent(RecordedSetTransform(this, aTransform)); - DrawTarget::SetTransform(aTransform); - mFinalDT->SetTransform(aTransform); -} - -already_AddRefed DrawTargetWrapAndRecord::EnsurePathStored( - const Path* aPath) { - RefPtr pathWrapAndRecord; - if (aPath->GetBackendType() == BackendType::RECORDING) { - pathWrapAndRecord = - const_cast(static_cast(aPath)); - if (mRecorder->HasStoredObject(aPath)) { - return pathWrapAndRecord.forget(); - } - } else { - MOZ_ASSERT(!mRecorder->HasStoredObject(aPath)); - FillRule fillRule = aPath->GetFillRule(); - RefPtr builder = mFinalDT->CreatePathBuilder(fillRule); - RefPtr builderWrapAndRecord = - new PathBuilderRecording(builder, fillRule); - aPath->StreamToSink(builderWrapAndRecord); - pathWrapAndRecord = - builderWrapAndRecord->Finish().downcast(); - } - - mRecorder->RecordEvent(RecordedPathCreation(pathWrapAndRecord.get())); - mRecorder->AddStoredObject(pathWrapAndRecord); - pathWrapAndRecord->mStoredRecorders.push_back(mRecorder); - - return pathWrapAndRecord.forget(); -} - -void DrawTargetWrapAndRecord::EnsurePatternDependenciesStored( - const Pattern& aPattern) { - switch (aPattern.GetType()) { - case PatternType::COLOR: - // No dependencies here. - return; - case PatternType::LINEAR_GRADIENT: { - MOZ_ASSERT(mRecorder->HasStoredObject( - static_cast(&aPattern)->mStops)); - return; - } - case PatternType::RADIAL_GRADIENT: { - MOZ_ASSERT(mRecorder->HasStoredObject( - static_cast(&aPattern)->mStops)); - return; - } - case PatternType::CONIC_GRADIENT: { - MOZ_ASSERT(mRecorder->HasStoredObject( - static_cast(&aPattern)->mStops)); - return; - } - case PatternType::SURFACE: { - const SurfacePattern* pat = static_cast(&aPattern); - EnsureSurfaceStored(mRecorder, pat->mSurface, - "EnsurePatternDependenciesStored"); - return; - } - } -} - -} // namespace gfx -} // namespace mozilla diff --git a/gfx/2d/DrawTargetWrapAndRecord.h b/gfx/2d/DrawTargetWrapAndRecord.h deleted file mode 100644 index 58bea829bb2c..000000000000 --- a/gfx/2d/DrawTargetWrapAndRecord.h +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MOZILLA_GFX_DRAWTARGETWRAPANDRECORD_H_ -#define MOZILLA_GFX_DRAWTARGETWRAPANDRECORD_H_ - -#include "2D.h" -#include "DrawEventRecorder.h" - -namespace mozilla { -namespace gfx { - -class DrawTargetWrapAndRecord : public DrawTarget { - public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetWrapAndRecord, override) - DrawTargetWrapAndRecord(DrawEventRecorder* aRecorder, DrawTarget* aDT, - bool aHasData = false); - - ~DrawTargetWrapAndRecord(); - - virtual DrawTargetType GetType() const override { - return mFinalDT->GetType(); - } - virtual BackendType GetBackendType() const override { - return mFinalDT->GetBackendType(); - } - virtual bool IsRecording() const override { return true; } - - virtual already_AddRefed Snapshot() override; - virtual already_AddRefed IntoLuminanceSource( - LuminanceType aLuminanceType, float aOpacity) override; - - virtual void DetachAllSnapshots() override; - - virtual IntSize GetSize() const override { return mFinalDT->GetSize(); } - - /* Ensure that the DrawTarget backend has flushed all drawing operations to - * this draw target. This must be called before using the backing surface of - * this draw target outside of GFX 2D code. - */ - virtual void Flush() override { mFinalDT->Flush(); } - - /* - * Draw a surface to the draw target. Possibly doing partial drawing or - * applying scaling. No sampling happens outside the source. - * - * aSurface Source surface to draw - * aDest Destination rectangle that this drawing operation should draw to - * aSource Source rectangle in aSurface coordinates, this area of aSurface - * will be stretched to the size of aDest. - * aOptions General draw options that are applied to the operation - * aSurfOptions DrawSurface options that are applied - */ - virtual void DrawSurface( - SourceSurface* aSurface, const Rect& aDest, const Rect& aSource, - const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(), - const DrawOptions& aOptions = DrawOptions()) override; - - virtual void DrawDependentSurface(uint64_t aId, const Rect& aDest) override; - - virtual void DrawFilter(FilterNode* aNode, const Rect& aSourceRect, - const Point& aDestPoint, - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Blend a surface to the draw target with a shadow. The shadow is drawn as a - * gaussian blur using a specified sigma. The shadow is clipped to the size - * of the input surface, so the input surface should contain a transparent - * border the size of the approximate coverage of the blur (3 * aSigma). - * NOTE: This function works in device space! - * - * aSurface Source surface to draw. - * aDest Destination point that this drawing operation should draw to. - * aColor Color of the drawn shadow - * aOffset Offset of the shadow - * aSigma Sigma used for the guassian filter kernel - * aOperator Composition operator used - */ - virtual void DrawSurfaceWithShadow(SourceSurface* aSurface, - const Point& aDest, - const DeviceColor& aColor, - const Point& aOffset, Float aSigma, - CompositionOp aOperator) override; - - /* - * Clear a rectangle on the draw target to transparent black. This will - * respect the clipping region and transform. - * - * aRect Rectangle to clear - */ - virtual void ClearRect(const Rect& aRect) override; - - /* - * This is essentially a 'memcpy' between two surfaces. It moves a pixel - * aligned area from the source surface unscaled directly onto the - * drawtarget. This ignores both transform and clip. - * - * aSurface Surface to copy from - * aSourceRect Source rectangle to be copied - * aDest Destination point to copy the surface to - */ - virtual void CopySurface(SourceSurface* aSurface, const IntRect& aSourceRect, - const IntPoint& aDestination) override; - - /* - * Fill a rectangle on the DrawTarget with a certain source pattern. - * - * aRect Rectangle that forms the mask of this filling operation - * aPattern Pattern that forms the source of this filling operation - * aOptions Options that are applied to this operation - */ - virtual void FillRect(const Rect& aRect, const Pattern& aPattern, - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Stroke a rectangle on the DrawTarget with a certain source pattern. - * - * aRect Rectangle that forms the mask of this stroking operation - * aPattern Pattern that forms the source of this stroking operation - * aOptions Options that are applied to this operation - */ - virtual void StrokeRect(const Rect& aRect, const Pattern& aPattern, - const StrokeOptions& aStrokeOptions = StrokeOptions(), - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Stroke a line on the DrawTarget with a certain source pattern. - * - * aStart Starting point of the line - * aEnd End point of the line - * aPattern Pattern that forms the source of this stroking operation - * aOptions Options that are applied to this operation - */ - virtual void StrokeLine(const Point& aStart, const Point& aEnd, - const Pattern& aPattern, - const StrokeOptions& aStrokeOptions = StrokeOptions(), - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Stroke a path on the draw target with a certain source pattern. - * - * aPath Path that is to be stroked - * aPattern Pattern that should be used for the stroke - * aStrokeOptions Stroke options used for this operation - * aOptions Draw options used for this operation - */ - virtual void Stroke(const Path* aPath, const Pattern& aPattern, - const StrokeOptions& aStrokeOptions = StrokeOptions(), - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Fill a path on the draw target with a certain source pattern. - * - * aPath Path that is to be filled - * aPattern Pattern that should be used for the fill - * aOptions Draw options used for this operation - */ - virtual void Fill(const Path* aPath, const Pattern& aPattern, - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Fill a series of clyphs on the draw target with a certain source pattern. - */ - virtual void FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer, - const Pattern& aPattern, - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * This takes a source pattern and a mask, and composites the source pattern - * onto the destination surface using the alpha channel of the mask pattern - * as a mask for the operation. - * - * aSource Source pattern - * aMask Mask pattern - * aOptions Drawing options - */ - virtual void Mask(const Pattern& aSource, const Pattern& aMask, - const DrawOptions& aOptions = DrawOptions()) override; - - virtual void MaskSurface( - const Pattern& aSource, SourceSurface* aMask, Point aOffset, - const DrawOptions& aOptions = DrawOptions()) override; - - /* - * Push a clip to the DrawTarget. - * - * aPath The path to clip to - */ - virtual void PushClip(const Path* aPath) override; - - /* - * Push an axis-aligned rectangular clip to the DrawTarget. This rectangle - * is specified in user space. - * - * aRect The rect to clip to - */ - virtual void PushClipRect(const Rect& aRect) override; - - /* Pop a clip from the DrawTarget. A pop without a corresponding push will - * be ignored. - */ - virtual void PopClip() override; - - /** - * Push a 'layer' to the DrawTarget, a layer is a temporary surface that all - * drawing will be redirected to, this is used for example to support group - * opacity or the masking of groups. Clips must be balanced within a layer, - * i.e. between a matching PushLayer/PopLayer pair there must be as many - * PushClip(Rect) calls as there are PopClip calls. - * - * @param aOpaque Whether the layer will be opaque - * @param aOpacity Opacity of the layer - * @param aMask Mask applied to the layer - * @param aMaskTransform Transform applied to the layer mask - * @param aBounds Optional bounds in device space to which the layer is - * limited in size. - * @param aCopyBackground Whether to copy the background into the layer, this - * is only supported when aOpaque is true. - */ - virtual void PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask, - const Matrix& aMaskTransform, - const IntRect& aBounds = IntRect(), - bool aCopyBackground = false) override; - - /** - * This balances a call to PushLayer and proceeds to blend the layer back - * onto the background. This blend will blend the temporary surface back - * onto the target in device space using POINT sampling and operator over. - */ - virtual void PopLayer() override; - - /* - * Create a SourceSurface optimized for use with this DrawTarget from - * existing bitmap data in memory. - * - * The SourceSurface does not take ownership of aData, and may be freed at any - * time. - */ - virtual already_AddRefed CreateSourceSurfaceFromData( - unsigned char* aData, const IntSize& aSize, int32_t aStride, - SurfaceFormat aFormat) const override; - - /* - * Create a SourceSurface optimized for use with this DrawTarget from - * an arbitrary other SourceSurface. This may return aSourceSurface or some - * other existing surface. - */ - virtual already_AddRefed OptimizeSourceSurface( - SourceSurface* aSurface) const override; - - /* - * Create a SourceSurface for a type of NativeSurface. This may fail if the - * draw target does not know how to deal with the type of NativeSurface passed - * in. - */ - virtual already_AddRefed CreateSourceSurfaceFromNativeSurface( - const NativeSurface& aSurface) const override; - - /* - * Create a DrawTarget whose snapshot is optimized for use with this - * DrawTarget. - */ - virtual already_AddRefed CreateSimilarDrawTarget( - const IntSize& aSize, SurfaceFormat aFormat) const override; - - virtual bool CanCreateSimilarDrawTarget(const IntSize& aSize, - SurfaceFormat aFormat) const override; - - virtual RefPtr CreateClippedDrawTarget( - const Rect& aBounds, SurfaceFormat aFormat) override; - /* - * Create a path builder with the specified fillmode. - * - * We need the fill mode up front because of Direct2D. - * ID2D1SimplifiedGeometrySink requires the fill mode - * to be set before calling BeginFigure(). - */ - virtual already_AddRefed CreatePathBuilder( - FillRule aFillRule = FillRule::FILL_WINDING) const override; - - /* - * Create a GradientStops object that holds information about a set of - * gradient stops, this object is required for linear or radial gradient - * patterns to represent the color stops in the gradient. - * - * aStops An array of gradient stops - * aNumStops Number of stops in the array aStops - * aExtendNone This describes how to extend the stop color outside of the - * gradient area. - */ - virtual already_AddRefed CreateGradientStops( - GradientStop* aStops, uint32_t aNumStops, - ExtendMode aExtendMode = ExtendMode::CLAMP) const override; - - virtual already_AddRefed CreateFilter(FilterType aType) override; - - /* - * Set a transform on the surface, this transform is applied at drawing time - * to both the mask and source of the operation. - */ - virtual void SetTransform(const Matrix& aTransform) override; - - /* Tries to get a native surface for a DrawTarget, this may fail if the - * draw target cannot convert to this surface type. - */ - virtual void* GetNativeSurface(NativeSurfaceType aType) override { - return mFinalDT->GetNativeSurface(aType); - } - - virtual bool IsCurrentGroupOpaque() override { - return mFinalDT->IsCurrentGroupOpaque(); - } - - private: - /** - * Used for creating a DrawTargetWrapAndRecord for a CreateSimilarDrawTarget - * call. We have to call CreateSimilarDrawTarget on mFinalDT up front and pass - * it in as it can fail. - * - * @param aDT DrawTargetWrapAndRecord on which CreateSimilarDrawTarget was - * called - * @param aSimilarDT Similar DrawTarget created from aDT.mFinalDT. - */ - DrawTargetWrapAndRecord(const DrawTargetWrapAndRecord* aDT, - DrawTarget* aSimilarDT); - - Path* GetPathForPathRecording(const Path* aPath) const; - already_AddRefed EnsurePathStored(const Path* aPath); - void EnsurePatternDependenciesStored(const Pattern& aPattern); - - RefPtr mRecorder; - RefPtr mFinalDT; -}; - -} // namespace gfx -} // namespace mozilla - -#endif /* MOZILLA_GFX_DRAWTARGETWRAPANDRECORD_H_ */ diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 75edc26a196b..d1f40f2d0e5f 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -53,7 +53,6 @@ #endif #include "DrawTargetOffset.h" -#include "DrawTargetWrapAndRecord.h" #include "DrawTargetRecording.h" #include "SourceSurfaceRawData.h" @@ -225,8 +224,6 @@ StaticMutex Factory::mDTDependencyLock; bool Factory::mBGRSubpixelOrder = false; -DrawEventRecorder* Factory::mRecorder; - mozilla::gfx::Config* Factory::sConfig = nullptr; void Factory::Init(const Config& aConfig) { @@ -396,10 +393,6 @@ already_AddRefed Factory::CreateDrawTarget(BackendType aBackend, return nullptr; } - if (mRecorder && retVal) { - return MakeAndAddRef(mRecorder, retVal); - } - if (!retVal) { // Failed gfxCriticalError(LoggerOptionsBasedOnSize(aSize)) @@ -456,10 +449,6 @@ already_AddRefed Factory::CreateDrawTargetForData( return nullptr; } - if (mRecorder && retVal) { - return MakeAndAddRef(mRecorder, retVal, true); - } - if (!retVal) { gfxCriticalNote << "Failed to create DrawTarget, Type: " << int(aBackend) << " Size: " << aSize << ", Data: " << hexa((void*)aData) @@ -742,11 +731,6 @@ already_AddRefed Factory::CreateDrawTargetForD3D11Texture( newTarget = new DrawTargetD2D1(); if (newTarget->Init(aTexture, aFormat)) { RefPtr retVal = newTarget; - - if (mRecorder) { - retVal = new DrawTargetWrapAndRecord(mRecorder, retVal, true); - } - return retVal.forget(); } @@ -981,10 +965,6 @@ already_AddRefed Factory::CreateDrawTargetForCairoSurface( if (newTarget->Init(aSurface, aSize, aFormat)) { retVal = newTarget; } - - if (mRecorder && retVal) { - return MakeAndAddRef(mRecorder, retVal, true); - } #endif return retVal.forget(); } @@ -1104,15 +1084,6 @@ void Factory::CopyDataSourceSurface(DataSourceSurface* aSource, aDest->Unmap(); } -already_AddRefed Factory::CreateEventRecorderForFile( - const char_type* aFilename) { - return MakeAndAddRef(aFilename); -} - -void Factory::SetGlobalEventRecorder(DrawEventRecorder* aRecorder) { - mRecorder = aRecorder; -} - #ifdef WIN32 /* static */ diff --git a/gfx/2d/Logging.h b/gfx/2d/Logging.h index a097ee27ae3f..aafd876766aa 100644 --- a/gfx/2d/Logging.h +++ b/gfx/2d/Logging.h @@ -679,9 +679,6 @@ class Log final { case SurfaceType::RECORDING: mMessage << "SurfaceType::RECORDING"; break; - case SurfaceType::WRAP_AND_RECORD: - mMessage << "SurfaceType::WRAP_AND_RECORD"; - break; case SurfaceType::DATA_SHARED: mMessage << "SurfaceType::DATA_SHARED"; break; diff --git a/gfx/2d/RecordedEvent.h b/gfx/2d/RecordedEvent.h index 1f841a0e83b8..efb2a817cea4 100644 --- a/gfx/2d/RecordedEvent.h +++ b/gfx/2d/RecordedEvent.h @@ -466,7 +466,6 @@ class RecordedEvent { protected: friend class DrawEventRecorderPrivate; - friend class DrawEventRecorderFile; friend class DrawEventRecorderMemory; static void RecordUnscaledFont(UnscaledFont* aUnscaledFont, std::ostream* aOutput); diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 1ba51f98f91d..cc9ed5bce73e 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -34,7 +34,6 @@ enum class SurfaceType : int8_t { SKIA, /* Surface wrapping a Skia bitmap */ D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */ RECORDING, /* Surface used for recording */ - WRAP_AND_RECORD, /* Surface used for wrap and record */ DATA_SHARED, /* Data surface using shared memory */ DATA_RECYCLING_SHARED, /* Data surface using shared memory */ OFFSET, /* Offset */ diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index ec40cc64da5f..e9c2e10068b5 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -26,7 +26,6 @@ EXPORTS.mozilla.gfx += [ "DrawEventRecorder.h", "DrawTargetOffset.h", "DrawTargetRecording.h", - "DrawTargetWrapAndRecord.h", "Filters.h", "FontVariation.h", "Helpers.h", @@ -167,7 +166,6 @@ UNIFIED_SOURCES += [ "DrawTargetCairo.cpp", "DrawTargetOffset.cpp", "DrawTargetRecording.cpp", - "DrawTargetWrapAndRecord.cpp", "FilterNodeSoftware.cpp", "FilterProcessing.cpp", "FilterProcessingScalar.cpp", diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 8734fa36b956..377275b3d0ba 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -493,48 +493,6 @@ void gfxPlatform::InitChild(const ContentDeviceData& aData) { gContentDeviceInitData = nullptr; } -void RecordingPrefChanged(const char* aPrefName, void* aClosure) { - if (Preferences::GetBool("gfx.2d.recording", false)) { - nsAutoCString fileName; - nsAutoString prefFileName; - nsresult rv = Preferences::GetString("gfx.2d.recordingfile", prefFileName); - if (NS_SUCCEEDED(rv)) { - CopyUTF16toUTF8(prefFileName, fileName); - } else { - nsCOMPtr tmpFile; - if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, - getter_AddRefs(tmpFile)))) { - return; - } - fileName.AppendPrintf("moz2drec_%i_%i.aer", XRE_GetProcessType(), - getpid()); - - nsresult rv = tmpFile->AppendNative(fileName); - if (NS_FAILED(rv)) return; - -#ifdef XP_WIN - rv = tmpFile->GetPath(prefFileName); - CopyUTF16toUTF8(prefFileName, fileName); -#else - rv = tmpFile->GetNativePath(fileName); -#endif - if (NS_FAILED(rv)) return; - } - -#ifdef XP_WIN - gPlatform->mRecorder = - Factory::CreateEventRecorderForFile(prefFileName.BeginReading()); -#else - gPlatform->mRecorder = - Factory::CreateEventRecorderForFile(fileName.BeginReading()); -#endif - printf_stderr("Recording to %s\n", fileName.get()); - Factory::SetGlobalEventRecorder(gPlatform->mRecorder); - } else { - Factory::SetGlobalEventRecorder(nullptr); - } -} - #define WR_DEBUG_PREF "gfx.webrender.debug" static void WebRendeProfilerUIPrefChangeCallback(const char* aPrefName, void*) { @@ -999,9 +957,6 @@ void gfxPlatform::Init() { GLContext::PlatformStartup(); - Preferences::RegisterCallbackAndCall(RecordingPrefChanged, - "gfx.2d.recording"); - // Listen to memory pressure event so we can purge DrawTarget caches gPlatform->mMemoryPressureObserver = layers::MemoryPressureObserver::Create(gPlatform); diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 1a86397a2cac..5f739f2fd135 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -53,7 +53,6 @@ class DrawTarget; class SourceSurface; class DataSourceSurface; class ScaledFont; -class DrawEventRecorder; class VsyncSource; class ContentDeviceData; class GPUDeviceData; @@ -985,8 +984,6 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { static void InitializeCMS(); static void ShutdownCMS(); - friend void RecordingPrefChanged(const char* aPrefName, void* aClosure); - /** * Calling this function will compute and set the ideal tile size for the * platform. This will only have an effect in the parent process; child @@ -1036,8 +1033,6 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { nsTArray mFrameStats; - RefPtr mRecorder; - // Backend that we are compositing with. NONE, if no compositor has been // created yet. mozilla::layers::LayersBackend mCompositorBackend; diff --git a/layout/moz.build b/layout/moz.build index f44531283427..65baed1ba302 100644 --- a/layout/moz.build +++ b/layout/moz.build @@ -18,7 +18,6 @@ DIRS += [ "ipc", "mathml", "inspector", - "tools/recording", "reftests", "painting", ] diff --git a/layout/tools/recording/RecordingCmdLine.jsm b/layout/tools/recording/RecordingCmdLine.jsm deleted file mode 100644 index c22e6504e9f9..000000000000 --- a/layout/tools/recording/RecordingCmdLine.jsm +++ /dev/null @@ -1,69 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -function RecordingCmdLineHandler() {} -RecordingCmdLineHandler.prototype = { - /* nsISupports */ - QueryInterface: ChromeUtils.generateQI(["nsICommandLineHandler"]), - - /* nsICommandLineHandler */ - handle: function handler_handle(cmdLine) { - var args = {}; - args.wrappedJSObject = args; - try { - var uristr = cmdLine.handleFlagWithParam("recording", false); - if (uristr == null) { - return; - } - try { - args.uri = cmdLine.resolveURI(uristr).spec; - } catch (e) { - return; - } - } catch (e) { - cmdLine.handleFlag("recording", true); - } - - /** - * Manipulate preferences by adding to the *default* branch. Adding - * to the default branch means the changes we make won't get written - * back to user preferences. - * - * We want to do this here rather than in reftest.js because it's - * important to set the recording pref before the platform Init gets - * called. - */ - var prefs = Cc["@mozilla.org/preferences-service;1"].getService( - Ci.nsIPrefService - ); - var branch = prefs.getDefaultBranch(""); - - try { - var outputstr = cmdLine.handleFlagWithParam("recording-output", false); - if (outputstr != null) { - branch.setCharPref("gfx.2d.recordingfile", outputstr); - } - } catch (e) {} - - branch.setBoolPref("gfx.2d.recording", true); - - var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService( - Ci.nsIWindowWatcher - ); - wwatch.openWindow( - null, - "chrome://recording/content/recording.xhtml", - "_blank", - "chrome,dialog=no,all", - args - ); - cmdLine.preventDefault = true; - }, - - helpInfo: - " --recording Record drawing for a given URL.\n" + - " --recording-output Specify destination file for a drawing recording.\n", -}; - -var EXPORTED_SYMBOLS = ["RecordingCmdLineHandler"]; diff --git a/layout/tools/recording/components.conf b/layout/tools/recording/components.conf deleted file mode 100644 index 31f191623a05..000000000000 --- a/layout/tools/recording/components.conf +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -Classes = [ - { - 'cid': '{86FB70EC-90FF-45AD-A1C1-F77D3C1184E9}', - 'contract_ids': ['@mozilla.org/commandlinehandler/general-startup;1?type=recording'], - 'jsm': 'resource://gre/modules/RecordingCmdLine.jsm', - 'constructor': 'RecordingCmdLineHandler', - 'categories': {'command-line-handler': 'm-recording'}, - }, -] diff --git a/layout/tools/recording/jar.mn b/layout/tools/recording/jar.mn deleted file mode 100644 index bc66f5ceb623..000000000000 --- a/layout/tools/recording/jar.mn +++ /dev/null @@ -1,4 +0,0 @@ -recording.jar: -% content recording %content/ - content/recording.xhtml (recording.xhtml) - content/recording.js (recording.js) diff --git a/layout/tools/recording/moz.build b/layout/tools/recording/moz.build deleted file mode 100644 index 5a278090f05d..000000000000 --- a/layout/tools/recording/moz.build +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -EXTRA_JS_MODULES += [ - "RecordingCmdLine.jsm", -] - -XPCOM_MANIFESTS += [ - "components.conf", -] - -JAR_MANIFESTS += ["jar.mn"] diff --git a/layout/tools/recording/recording.js b/layout/tools/recording/recording.js deleted file mode 100644 index 6234ee03ece5..000000000000 --- a/layout/tools/recording/recording.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- / -/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const NS_GFXINFO_CONTRACTID = "@mozilla.org/gfx/info;1"; - -var gContainingWindow = null; - -var gBrowser; - -function OnDocumentLoad(evt) { - if ( - evt.target != gBrowser.contentDocument || - evt.target.location == "about:blank" - ) { - return; - } - gBrowser.removeEventListener("load", OnDocumentLoad, true); - gContainingWindow.close(); -} - -this.OnRecordingLoad = function OnRecordingLoad(win) { - if (win === undefined || win == null) { - win = window; - } - if (gContainingWindow == null && win != null) { - gContainingWindow = win; - } - - gBrowser = gContainingWindow.document.getElementById("browser"); - - var gfxInfo = - NS_GFXINFO_CONTRACTID in Cc && - Cc[NS_GFXINFO_CONTRACTID].getService(Ci.nsIGfxInfo); - dump(gfxInfo.AzureContentBackend + "\n"); - if (gfxInfo.AzureContentBackend == "none") { - alert("Page recordings may only be made with Azure content enabled."); - gContainingWindow.close(); - return; - } - - gBrowser.addEventListener("load", OnDocumentLoad, true); - - var args = window.arguments[0].wrappedJSObject; - - gBrowser.loadURI(args.uri, { - triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}), - }); -}; diff --git a/layout/tools/recording/recording.xhtml b/layout/tools/recording/recording.xhtml deleted file mode 100644 index 040f5a212dd3..000000000000 --- a/layout/tools/recording/recording.xhtml +++ /dev/null @@ -1,13 +0,0 @@ - - - -