diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index ee640d80b6a2..7eb2b21ff8d5 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -1649,7 +1649,7 @@ class GFX2D_API Factory { DrawEventRecorder* aRecorder, DrawTarget* aDT); static already_AddRefed CreateRecordingDrawTarget( - DrawEventRecorder* aRecorder, DrawTarget* aDT, IntSize aSize); + DrawEventRecorder* aRecorder, DrawTarget* aDT, IntRect aRect); static already_AddRefed CreateDrawTargetForData( BackendType aBackend, unsigned char* aData, const IntSize& aSize, diff --git a/gfx/2d/DrawTargetRecording.cpp b/gfx/2d/DrawTargetRecording.cpp index 421f91b9d2a5..8223498574ab 100644 --- a/gfx/2d/DrawTargetRecording.cpp +++ b/gfx/2d/DrawTargetRecording.cpp @@ -211,21 +211,21 @@ class FilterNodeRecording : public FilterNode { }; DrawTargetRecording::DrawTargetRecording(DrawEventRecorder* aRecorder, - DrawTarget* aDT, IntSize aSize, + DrawTarget* aDT, IntRect aRect, bool aHasData) : mRecorder(static_cast(aRecorder)), mFinalDT(aDT), - mSize(aSize) { + mRect(aRect) { RefPtr snapshot = aHasData ? mFinalDT->Snapshot() : nullptr; mRecorder->RecordEvent( - RecordedDrawTargetCreation(this, mFinalDT->GetBackendType(), mSize, + RecordedDrawTargetCreation(this, mFinalDT->GetBackendType(), mRect, mFinalDT->GetFormat(), aHasData, snapshot)); mFormat = mFinalDT->GetFormat(); } DrawTargetRecording::DrawTargetRecording(const DrawTargetRecording* aDT, - IntSize aSize, SurfaceFormat aFormat) - : mRecorder(aDT->mRecorder), mFinalDT(aDT->mFinalDT), mSize(aSize) { + IntRect aRect, SurfaceFormat aFormat) + : mRecorder(aDT->mRecorder), mFinalDT(aDT->mFinalDT), mRect(aRect) { mFormat = aFormat; } @@ -361,7 +361,7 @@ void DrawTargetRecording::Stroke(const Path* aPath, const Pattern& aPattern, already_AddRefed DrawTargetRecording::Snapshot() { RefPtr retSurf = - new SourceSurfaceRecording(mSize, mFormat, mRecorder); + new SourceSurfaceRecording(mRect.Size(), mFormat, mRecorder); mRecorder->RecordEvent(RecordedSnapshot(retSurf, this)); @@ -371,7 +371,7 @@ already_AddRefed DrawTargetRecording::Snapshot() { already_AddRefed DrawTargetRecording::IntoLuminanceSource( LuminanceType aLuminanceType, float aOpacity) { RefPtr retSurf = - new SourceSurfaceRecording(mSize, SurfaceFormat::A8, mRecorder); + new SourceSurfaceRecording(mRect.Size(), SurfaceFormat::A8, mRecorder); mRecorder->RecordEvent( RecordedIntoLuminanceSource(retSurf, this, aLuminanceType, aOpacity)); @@ -519,7 +519,8 @@ already_AddRefed DrawTargetRecording::CreateSimilarDrawTarget( const IntSize& aSize, SurfaceFormat aFormat) const { RefPtr similarDT; if (mFinalDT->CanCreateSimilarDrawTarget(aSize, aFormat)) { - similarDT = new DrawTargetRecording(this, aSize, aFormat); + similarDT = + new DrawTargetRecording(this, IntRect(IntPoint(0, 0), aSize), aFormat); mRecorder->RecordEvent( RecordedCreateSimilarDrawTarget(similarDT.get(), aSize, aFormat)); } else if (XRE_IsContentProcess()) { @@ -542,7 +543,7 @@ bool DrawTargetRecording::CanCreateSimilarDrawTarget( RefPtr DrawTargetRecording::CreateClippedDrawTarget( const Rect& aBounds, SurfaceFormat aFormat) { RefPtr similarDT; - similarDT = new DrawTargetRecording(this, mSize, aFormat); + similarDT = new DrawTargetRecording(this, mRect, aFormat); mRecorder->RecordEvent( RecordedCreateClippedDrawTarget(similarDT.get(), aBounds, aFormat)); similarDT->SetTransform(mTransform); @@ -555,7 +556,8 @@ DrawTargetRecording::CreateSimilarDrawTargetForFilter( FilterNode* aSource, const Rect& aSourceRect, const Point& aDestPoint) { RefPtr similarDT; if (mFinalDT->CanCreateSimilarDrawTarget(aMaxSize, aFormat)) { - similarDT = new DrawTargetRecording(this, aMaxSize, aFormat); + similarDT = new DrawTargetRecording(this, IntRect(IntPoint(0, 0), aMaxSize), + aFormat); mRecorder->RecordEvent(RecordedCreateDrawTargetForFilter( this, similarDT.get(), aMaxSize, aFormat, aFilter, aSource, aSourceRect, aDestPoint)); @@ -623,7 +625,7 @@ void DrawTargetRecording::FlushItem(const IntRect& aBounds) { // Tell the new recording about our draw target // This code should match what happens in the DrawTargetRecording constructor. mRecorder->RecordEvent( - RecordedDrawTargetCreation(this, mFinalDT->GetBackendType(), mSize, + RecordedDrawTargetCreation(this, mFinalDT->GetBackendType(), mRect, mFinalDT->GetFormat(), false, nullptr)); // Add the current transform to the new recording mRecorder->RecordEvent( diff --git a/gfx/2d/DrawTargetRecording.h b/gfx/2d/DrawTargetRecording.h index 57b4fbd6130b..ab1dd110f545 100644 --- a/gfx/2d/DrawTargetRecording.h +++ b/gfx/2d/DrawTargetRecording.h @@ -17,7 +17,7 @@ class DrawTargetRecording : public DrawTarget { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetRecording, override) DrawTargetRecording(DrawEventRecorder* aRecorder, DrawTarget* aDT, - IntSize aSize, bool aHasData = false); + IntRect aRect, bool aHasData = false); ~DrawTargetRecording(); @@ -35,7 +35,8 @@ class DrawTargetRecording : public DrawTarget { virtual void DetachAllSnapshots() override; - virtual IntSize GetSize() const override { return mSize; } + virtual IntSize GetSize() const override { return mRect.Size(); } + virtual IntRect GetRect() const override { return mRect; } virtual void Flush() override; @@ -354,7 +355,7 @@ class DrawTargetRecording : public DrawTarget { * @param aSize size of the the similar DrawTarget * @param aFormat format of the similar DrawTarget */ - DrawTargetRecording(const DrawTargetRecording* aDT, IntSize aSize, + DrawTargetRecording(const DrawTargetRecording* aDT, IntRect aRect, SurfaceFormat aFormat); Path* GetPathForPathRecording(const Path* aPath) const; @@ -363,7 +364,7 @@ class DrawTargetRecording : public DrawTarget { RefPtr mRecorder; RefPtr mFinalDT; - IntSize mSize; + IntRect mRect; }; } // namespace gfx diff --git a/gfx/2d/DrawTargetWrapAndRecord.cpp b/gfx/2d/DrawTargetWrapAndRecord.cpp index 9d9941ec03e0..890f509ed9a8 100644 --- a/gfx/2d/DrawTargetWrapAndRecord.cpp +++ b/gfx/2d/DrawTargetWrapAndRecord.cpp @@ -282,7 +282,7 @@ DrawTargetWrapAndRecord::DrawTargetWrapAndRecord(DrawEventRecorder* aRecorder, mFinalDT(aDT) { RefPtr snapshot = aHasData ? mFinalDT->Snapshot() : nullptr; mRecorder->RecordEvent(RecordedDrawTargetCreation( - this, mFinalDT->GetBackendType(), mFinalDT->GetSize(), + this, mFinalDT->GetBackendType(), mFinalDT->GetRect(), mFinalDT->GetFormat(), aHasData, snapshot)); mFormat = mFinalDT->GetFormat(); } diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index c32cbc062672..2a18270ce664 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -411,8 +411,8 @@ already_AddRefed Factory::CreateWrapAndRecordDrawTarget( } already_AddRefed Factory::CreateRecordingDrawTarget( - DrawEventRecorder* aRecorder, DrawTarget* aDT, IntSize aSize) { - return MakeAndAddRef(aRecorder, aDT, aSize); + DrawEventRecorder* aRecorder, DrawTarget* aDT, IntRect aRect) { + return MakeAndAddRef(aRecorder, aDT, aRect); } already_AddRefed Factory::CreateCaptureDrawTargetForTarget( diff --git a/gfx/2d/RecordedEventImpl.h b/gfx/2d/RecordedEventImpl.h index 9a14de1afb78..5435a27b59bf 100644 --- a/gfx/2d/RecordedEventImpl.h +++ b/gfx/2d/RecordedEventImpl.h @@ -41,13 +41,13 @@ class RecordedDrawTargetCreation : public RecordedEventDerived { public: RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, - const IntSize& aSize, SurfaceFormat aFormat, + const IntRect& aRect, SurfaceFormat aFormat, bool aHasExistingData = false, SourceSurface* aExistingData = nullptr) : RecordedEventDerived(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), - mSize(aSize), + mRect(aRect), mFormat(aFormat), mHasExistingData(aHasExistingData), mExistingData(aExistingData) {} @@ -63,7 +63,7 @@ class RecordedDrawTargetCreation ReferencePtr mRefPtr; BackendType mBackendType; - IntSize mSize; + IntRect mRect; SurfaceFormat mFormat; bool mHasExistingData; RefPtr mExistingData; @@ -1731,7 +1731,7 @@ void RecordedDrawingEvent::Record(S& aStream) const { inline bool RecordedDrawTargetCreation::PlayEvent( Translator* aTranslator) const { RefPtr newDT = - aTranslator->CreateDrawTarget(mRefPtr, mSize, mFormat); + aTranslator->CreateDrawTarget(mRefPtr, mRect.Size(), mFormat); // If we couldn't create a DrawTarget this will probably cause us to crash // with nullptr later in the playback, so return false to abort. @@ -1752,19 +1752,19 @@ template void RecordedDrawTargetCreation::Record(S& aStream) const { WriteElement(aStream, mRefPtr); WriteElement(aStream, mBackendType); - WriteElement(aStream, mSize); + WriteElement(aStream, mRect); WriteElement(aStream, mFormat); WriteElement(aStream, mHasExistingData); if (mHasExistingData) { MOZ_ASSERT(mExistingData); - MOZ_ASSERT(mExistingData->GetSize() == mSize); + MOZ_ASSERT(mExistingData->GetSize() == mRect.Size()); RefPtr dataSurf = mExistingData->GetDataSurface(); DataSourceSurface::ScopedMap map(dataSurf, DataSourceSurface::READ); - for (int y = 0; y < mSize.height; y++) { + for (int y = 0; y < mRect.height; y++) { aStream.write((const char*)map.GetData() + y * map.GetStride(), - BytesPerPixel(mFormat) * mSize.width); + BytesPerPixel(mFormat) * mRect.width); } } } @@ -1774,13 +1774,13 @@ RecordedDrawTargetCreation::RecordedDrawTargetCreation(S& aStream) : RecordedEventDerived(DRAWTARGETCREATION), mExistingData(nullptr) { ReadElement(aStream, mRefPtr); ReadElement(aStream, mBackendType); - ReadElement(aStream, mSize); + ReadElement(aStream, mRect); ReadElement(aStream, mFormat); ReadElement(aStream, mHasExistingData); if (mHasExistingData) { RefPtr dataSurf = - Factory::CreateDataSourceSurface(mSize, mFormat); + Factory::CreateDataSourceSurface(mRect.Size(), mFormat); if (!dataSurf) { gfxWarning() << "RecordedDrawTargetCreation had to reset mHasExistingData"; @@ -1789,9 +1789,9 @@ RecordedDrawTargetCreation::RecordedDrawTargetCreation(S& aStream) } DataSourceSurface::ScopedMap map(dataSurf, DataSourceSurface::READ); - for (int y = 0; y < mSize.height; y++) { + for (int y = 0; y < mRect.height; y++) { aStream.read((char*)map.GetData() + y * map.GetStride(), - BytesPerPixel(mFormat) * mSize.width); + BytesPerPixel(mFormat) * mRect.width); } mExistingData = dataSurf; } @@ -1800,8 +1800,8 @@ RecordedDrawTargetCreation::RecordedDrawTargetCreation(S& aStream) inline void RecordedDrawTargetCreation::OutputSimpleEventInfo( std::stringstream& aStringStream) const { aStringStream << "[" << mRefPtr << "] DrawTarget Creation (Type: " - << NameFromBackend(mBackendType) << ", Size: " << mSize.width - << "x" << mSize.height << ")"; + << NameFromBackend(mBackendType) << ", Size: " << mRect.width + << "x" << mRect.height << ")"; } inline bool RecordedDrawTargetDestruction::PlayEvent( diff --git a/gfx/ipc/CrossProcessPaint.cpp b/gfx/ipc/CrossProcessPaint.cpp index 4e63f490efb4..d3141ad5c502 100644 --- a/gfx/ipc/CrossProcessPaint.cpp +++ b/gfx/ipc/CrossProcessPaint.cpp @@ -86,8 +86,8 @@ PaintFragment PaintFragment::Record(nsIDocShell* aDocShell, // TODO: This may OOM crash if the content is complex enough RefPtr recorder = MakeAndAddRef(nullptr); - RefPtr dt = - Factory::CreateRecordingDrawTarget(recorder, referenceDt, surfaceSize); + RefPtr dt = Factory::CreateRecordingDrawTarget( + recorder, referenceDt, IntRect(IntPoint(0, 0), surfaceSize)); // Perform the actual rendering { diff --git a/gfx/layers/ipc/CanvasChild.cpp b/gfx/layers/ipc/CanvasChild.cpp index 955174964661..9e0a9a226b2c 100644 --- a/gfx/layers/ipc/CanvasChild.cpp +++ b/gfx/layers/ipc/CanvasChild.cpp @@ -9,6 +9,8 @@ #include "MainThreadUtils.h" #include "mozilla/gfx/DrawTargetRecording.h" #include "mozilla/gfx/Tools.h" +#include "mozilla/gfx/Rect.h" +#include "mozilla/gfx/Point.h" #include "mozilla/layers/CanvasDrawEventRecorder.h" #include "RecordedCanvasEventImpl.h" @@ -104,7 +106,7 @@ already_AddRefed CanvasChild::CreateDrawTarget( RefPtr dummyDt = gfx::Factory::CreateDrawTarget( gfx::BackendType::SKIA, gfx::IntSize(1, 1), aFormat); RefPtr dt = - MakeAndAddRef(mRecorder, dummyDt, aSize); + MakeAndAddRef(mRecorder, dummyDt, gfx::IntRect(gfx::IntPoint(0, 0), aSize)); return dt.forget(); } diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 4fb4c0ce6d9b..0b8230c0f79d 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -677,7 +677,7 @@ struct DIGroup { gfx::BackendType::SKIA, gfx::IntSize(1, 1), format); RefPtr dt = - gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, dtSize); + gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, IntRect(IntPoint(0, 0), dtSize)); // Setup the gfxContext RefPtr context = gfxContext::CreateOrNull(dt); GP("ctx-offset %f %f\n", bounds.x, bounds.y); @@ -2267,7 +2267,7 @@ WebRenderCommandBuilder::GenerateFallbackData( RefPtr dummyDt = gfx::Factory::CreateDrawTarget( gfx::BackendType::SKIA, gfx::IntSize(1, 1), format); RefPtr dt = gfx::Factory::CreateRecordingDrawTarget( - recorder, dummyDt, dtSize.ToUnknownSize()); + recorder, dummyDt, IntRect(IntPoint(0, 0), dtSize.ToUnknownSize())); if (!fallbackData->mBasicLayerManager) { fallbackData->mBasicLayerManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE); @@ -2487,7 +2487,7 @@ Maybe WebRenderCommandBuilder::BuildWrMaskImage( RefPtr dummyDt = Factory::CreateDrawTarget( BackendType::SKIA, IntSize(1, 1), SurfaceFormat::A8); RefPtr dt = - Factory::CreateRecordingDrawTarget(recorder, dummyDt, size); + Factory::CreateRecordingDrawTarget(recorder, dummyDt, IntRect(IntPoint(0, 0), size)); RefPtr context = gfxContext::CreateOrNull(dt); MOZ_ASSERT(context);