diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /gfx/2d/RecordedEventImpl.h | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/2d/RecordedEventImpl.h')
-rw-r--r-- | gfx/2d/RecordedEventImpl.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/gfx/2d/RecordedEventImpl.h b/gfx/2d/RecordedEventImpl.h index a880536bf8..1d8a275c63 100644 --- a/gfx/2d/RecordedEventImpl.h +++ b/gfx/2d/RecordedEventImpl.h @@ -17,6 +17,8 @@ #include "ScaledFontBase.h" #include "SFNTData.h" +#include "mozilla/layers/LayersSurfaces.h" + namespace mozilla { namespace gfx { @@ -852,6 +854,41 @@ class RecordedDrawSurface : public RecordedEventDerived<RecordedDrawSurface> { DrawOptions mOptions; }; +class RecordedDrawSurfaceDescriptor + : public RecordedEventDerived<RecordedDrawSurfaceDescriptor> { + public: + RecordedDrawSurfaceDescriptor(const layers::SurfaceDescriptor& aDesc, + const Rect& aDest, const Rect& aSource, + const DrawSurfaceOptions& aDSOptions, + const DrawOptions& aOptions) + : RecordedEventDerived(DRAWSURFACEDESCRIPTOR), + mDesc(aDesc), + mDest(aDest), + mSource(aSource), + mDSOptions(aDSOptions), + mOptions(aOptions) {} + + bool PlayEvent(Translator* aTranslator) const override; + + template <class S> + void Record(S& aStream) const; + void OutputSimpleEventInfo(std::stringstream& aStringStream) const override; + + std::string GetName() const override { return "DrawSurfaceDescriptor"; } + + private: + friend class RecordedEvent; + + template <class S> + MOZ_IMPLICIT RecordedDrawSurfaceDescriptor(S& aStream); + + layers::SurfaceDescriptor mDesc; + Rect mDest; + Rect mSource; + DrawSurfaceOptions mDSOptions; + DrawOptions mOptions; +}; + class RecordedDrawDependentSurface : public RecordedEventDerived<RecordedDrawDependentSurface> { public: @@ -3141,6 +3178,52 @@ inline void RecordedDrawSurface::OutputSimpleEventInfo( aStringStream << "DrawSurface (" << mRefSource << ")"; } +inline bool RecordedDrawSurfaceDescriptor::PlayEvent( + Translator* aTranslator) const { + DrawTarget* dt = aTranslator->GetCurrentDrawTarget(); + if (!dt) { + return false; + } + + RefPtr<SourceSurface> surface = + aTranslator->LookupSourceSurfaceFromSurfaceDescriptor(mDesc); + if (!surface) { + return false; + } + + RefPtr<SourceSurface> opt = dt->OptimizeSourceSurface(surface); + if (opt) { + surface = opt; + } + + dt->DrawSurface(surface, mDest, mSource, mDSOptions, mOptions); + return true; +} + +template <class S> +void RecordedDrawSurfaceDescriptor::Record(S& aStream) const { + WriteElement(aStream, mDesc); + WriteElement(aStream, mDest); + WriteElement(aStream, mSource); + WriteElement(aStream, mDSOptions); + WriteElement(aStream, mOptions); +} + +template <class S> +RecordedDrawSurfaceDescriptor::RecordedDrawSurfaceDescriptor(S& aStream) + : RecordedEventDerived(DRAWSURFACEDESCRIPTOR) { + ReadElement(aStream, mDesc); + ReadElement(aStream, mDest); + ReadElement(aStream, mSource); + ReadDrawSurfaceOptions(aStream, mDSOptions); + ReadDrawOptions(aStream, mOptions); +} + +inline void RecordedDrawSurfaceDescriptor::OutputSimpleEventInfo( + std::stringstream& aStringStream) const { + aStringStream << "DrawSurfaceDescriptor (" << mDesc.type() << ")"; +} + inline bool RecordedDrawDependentSurface::PlayEvent( Translator* aTranslator) const { aTranslator->DrawDependentSurface(mId, mDest); @@ -4379,6 +4462,7 @@ inline void RecordedDestination::OutputSimpleEventInfo( f(MASK, RecordedMask); \ f(STROKE, RecordedStroke); \ f(DRAWSURFACE, RecordedDrawSurface); \ + f(DRAWSURFACEDESCRIPTOR, RecordedDrawSurfaceDescriptor); \ f(DRAWDEPENDENTSURFACE, RecordedDrawDependentSurface); \ f(DRAWSURFACEWITHSHADOW, RecordedDrawSurfaceWithShadow); \ f(DRAWSHADOW, RecordedDrawShadow); \ |