WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-217566-20201020162216.patch (text/plain), 85.14 KB, created by
Said Abou-Hallawa
on 2020-10-20 16:22:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2020-10-20 16:22:17 PDT
Size:
85.14 KB
patch
obsolete
>Subversion Revision: 268711 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0faeb9117dd81ac95f2e0d0bcedfe798ee3975d1..9626f1de5716461f38dd94f9fddb865a3dda152c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,88 @@ >+2020-10-20 Said Abou-Hallawa <said@apple.com> >+ >+ [GPU Process]: Implement DisplayList::DrawImageBuffer item >+ https://bugs.webkit.org/show_bug.cgi?id=217566 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add the DrawImageBuffer DisplayList item. It will be used only for GPU >+ rendering. The remoteResourceIdentifier of the source ImageBuffer will >+ be recorded. For details on how drawing an ImageBuffer to another >+ ImageBuffer works see the WebKit ChangeLog. >+ >+ * platform/graphics/GraphicsContext.cpp: >+ (WebCore::GraphicsContext::drawImageBuffer): >+ * platform/graphics/GraphicsContextImpl.h: >+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp: >+ (WebCore::GraphicsContextImplCairo::drawImageBuffer): >+ * platform/graphics/cairo/GraphicsContextImplCairo.h: >+ * platform/graphics/displaylists/DisplayList.h: >+ * platform/graphics/displaylists/DisplayListItems.cpp: >+ (WebCore::DisplayList::Item::sizeInBytes): >+ (WebCore::DisplayList::DrawImageBuffer::DrawImageBuffer): >+ (WebCore::DisplayList::DrawImageBuffer::apply const): >+ (WebCore::DisplayList::operator<<): >+ * platform/graphics/displaylists/DisplayListItems.h: >+ (WebCore::DisplayList::DrawImageBuffer::create): >+ (WebCore::DisplayList::DrawImageBuffer::remoteResourceIdentifier const): >+ (WebCore::DisplayList::DrawImageBuffer::source const): >+ (WebCore::DisplayList::DrawImageBuffer::destinationRect const): >+ (WebCore::DisplayList::DrawImageBuffer::options const): >+ (WebCore::DisplayList::DrawImageBuffer::encode const): >+ (WebCore::DisplayList::DrawImageBuffer::decode): >+ (WebCore::DisplayList::Item::encode const): >+ (WebCore::DisplayList::Item::decode): >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::Recorder): >+ (WebCore::DisplayList::Recorder::drawImageBuffer): >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ (WebCore::DisplayList::Recorder::Delegate::lockRemoteImageBuffer): >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp: >+ (Nicosia::CairoOperationRecorder::drawImageBuffer): >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h: >+ >+2020-10-19 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [GPU Process]: Introduce RemoteResourceCacheProxy to manage the remote resources in Web Process >+ https://bugs.webkit.org/show_bug.cgi?id=217558 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Rename Recorder::Observer to Recorder::Delegate because it will be responsible >+ for creating DisplayListItems in future patches. So it will not be just >+ an observer. Also do not make DisplayList::ImageBuffer a superclass of it. >+ RemoteImageBufferProxy, which is a superclass of DisplayList::ImageBuffer, >+ will be the superclass of Recorder::Delegate. >+ >+ Make ImageBufferBackend::isAccelerated a static member instead of a virtual >+ method. RemoteRenderingBackendProxy would want to know whether the backend >+ of an ImageBuffer isAccelerated or not without having to create it. >+ ImageBufferBackend::isAccelerated will be set to false and >+ ImageBufferIOSurfaceBackend::isAccelerated will be set to true. >+ >+ * platform/graphics/ConcreteImageBuffer.h: >+ * platform/graphics/ImageBuffer.h: >+ (WebCore::ImageBuffer::remoteResourceIdentifier const): >+ * platform/graphics/ImageBufferBackend.h: >+ (WebCore::ImageBufferBackend::isAccelerated const): Deleted. >+ * platform/graphics/RemoteResourceIdentifier.h: >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp: >+ (WebCore::ImageBufferIOSurfaceBackend::isAccelerated const): Deleted. >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.h: >+ * platform/graphics/displaylists/DisplayListDrawingContext.cpp: >+ (WebCore::DisplayList::DrawingContext::DrawingContext): >+ * platform/graphics/displaylists/DisplayListDrawingContext.h: >+ (WebCore::DisplayList::DrawingContext::DrawingContext): >+ * platform/graphics/displaylists/DisplayListImageBuffer.h: >+ (WebCore::DisplayList::ImageBuffer::ImageBuffer): >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::Recorder): >+ (WebCore::DisplayList::Recorder::willAppendItem): >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ (WebCore::DisplayList::Recorder::Delegate::~Delegate): >+ (WebCore::DisplayList::Recorder::Observer::~Observer): Deleted. >+ (WebCore::DisplayList::Recorder::Observer::willAppendItem): Deleted. >+ > 2020-10-19 Alexey Shvayka <shvaikalesh@gmail.com> > > [WebIDL] %Interface%.prototype.constructor should be defined on [[Set]] receiver >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index d7d684bcc0d76b173378092a27977ed27e0b7716..7478c0a5f61d04f67665ccaf3f39128fade92550 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,104 @@ >+2020-10-20 Said Abou-Hallawa <said@apple.com> >+ >+ [GPU Process]: Implement DisplayList::DrawImageBuffer item >+ https://bugs.webkit.org/show_bug.cgi?id=217566 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The sequence in the Web Process is the following: >+ >+ -- GraphicsContext::drawImageBuffer() uses DisplayList::Recorder to check >+ whether it is appropriate to create a DrawImageBuffer item or not. >+ >+ -- DisplayList::Recorder::drawImageBuffer() uses the delegate to see if >+ the ImageBuffer is remote or not and whether it can be locked till >+ replaying back the DisplayList in the GPU side. >+ >+ -- RemoteImageBufferProxy inherits DisplayList::Recorder::Delegate. So its >+ lockRemoteImageBuffer() is called. >+ >+ -- If the ImageBuffer can be locked, a DrawImageBufferItem is created with >+ the ImageBuffer::remoteResourceIdentifier(). >+ >+ The sequence in the GPU Process is the following: >+ >+ -- When replaying back the DisplayList, DisplayList::Replayer will call >+ its delegate to check if it wants to apply the DrawImageBuffer. >+ >+ -- Because RemoteImageBuffer inherits DisplayList::Replayer::Delegate, >+ RemoteImageBuffer::apply() will be called. >+ >+ -- RemoteImageBuffer will call RemoteRenderingBackend::applyResourceItem() >+ which will check whether the item's remoteResourceIdentifier is one of >+ the ImageBuffers in its RemoteResourceCache or not. >+ >+ -- If there is a cached ImageBuffer, RemoteRenderingBackend::applyResourceItem() >+ will draw to GraphicsContext. >+ >+ * GPUProcess/graphics/RemoteImageBuffer.h: >+ * GPUProcess/graphics/RemoteRenderingBackend.cpp: >+ (WebKit::RemoteRenderingBackend::applyResourceItem): >+ * GPUProcess/graphics/RemoteRenderingBackend.h: >+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: >+ * WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: >+ (WebKit::RemoteResourceCacheProxy::releaseImageBuffer): >+ (WebKit::RemoteResourceCacheProxy::lockRemoteImageBufferForRemoteClient): >+ (WebKit::RemoteResourceCacheProxy::lockRemoteResourceForRemoteClient): >+ (WebKit::RemoteResourceCacheProxy::releaseRemoteResource): >+ (WebKit::RemoteResourceCacheProxy::unlockRemoteResourcesForRemoteClient): >+ * WebProcess/GPU/graphics/RemoteResourceCacheProxy.h: >+ >+2020-10-19 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [GPU Process]: Introduce RemoteResourceCacheProxy to manage the remote resources in Web Process >+ https://bugs.webkit.org/show_bug.cgi?id=217558 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove RemoteImageBufferMessageHandlerProxy and move sending the messages >+ to RemoteRenderingBackendProxy. >+ >+ To allow casting ImageBuffer to RemoteImageBufferProxy, a new method named >+ remoteResourceIdentifier() is added to IamgeBuffer and it is only overridden >+ by RemoteImageBufferProxy. This method is used in SPECIALIZE_TYPE_TRAITS >+ macros along with IamgeBuffer::isAccelerated(). >+ >+ Introduce RemoteResourceCacheProxy which will manage caching and releasing >+ the RemoteImageBufferProxy. Caching NativeImage will be added to it in >+ future patches. More about controlling the life cycles of remote resources >+ will be added with supporting drawing remote resources to remote client. >+ >+ * Sources.txt: >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h: >+ (isType): >+ * WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp: Removed. >+ * WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.h: Removed. >+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: >+ (WebKit::RemoteImageBufferProxy::create): >+ (WebKit::RemoteImageBufferProxy::~RemoteImageBufferProxy): >+ (WebKit::RemoteImageBufferProxy::createBackend): >+ (WebKit::RemoteImageBufferProxy::commitFlushDisplayList): >+ (WebKit::RemoteImageBufferProxy::RemoteImageBufferProxy): >+ (WebKit::RemoteImageBufferProxy::isPendingFlush const): >+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: >+ (WebKit::RemoteRenderingBackendProxy::createImageBuffer): >+ (WebKit::RemoteRenderingBackendProxy::getImageData): >+ (WebKit::RemoteRenderingBackendProxy::flushDisplayList): >+ (WebKit::RemoteRenderingBackendProxy::flushDisplayListAndCommit): >+ (WebKit::RemoteRenderingBackendProxy::releaseRemoteResource): >+ (WebKit::RemoteRenderingBackendProxy::imageBufferBackendWasCreated): >+ (WebKit::RemoteRenderingBackendProxy::flushDisplayListWasCommitted): >+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: >+ (WebKit::RemoteRenderingBackendProxy::remoteResourceCacheProxy): >+ (WebKit::RemoteRenderingBackendProxy::renderingBackendIdentifier const): Deleted. >+ * WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: Copied from Source/WebCore/platform/graphics/RemoteResourceIdentifier.h. >+ (WebKit::RemoteResourceCacheProxy::RemoteResourceCacheProxy): >+ (WebKit::RemoteResourceCacheProxy::cacheImageBuffer): >+ (WebKit::RemoteResourceCacheProxy::cachedImageBuffer): >+ (WebKit::RemoteResourceCacheProxy::releaseImageBuffer): >+ * WebProcess/GPU/graphics/RemoteResourceCacheProxy.h: Copied from Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h. >+ > 2020-10-19 Peng Liu <peng.liu6@apple.com> > > Two feature flag names are incorrect >diff --git a/Source/WebCore/platform/graphics/ConcreteImageBuffer.h b/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >index c6c19e1289f48b020ea78bce39d106c3db93b07d..8697395fa4c8d0851c7b7790406e61c918fcea50 100644 >--- a/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >+++ b/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >@@ -50,13 +50,8 @@ public: > return nullptr; > return std::unique_ptr<ImageBufferType>(new ImageBufferType(WTFMove(backend), std::forward<Arguments>(arguments)...)); > } >- >- bool isAccelerated() const override >- { >- if (auto* backend = ensureBackendCreated()) >- return backend->isAccelerated(); >- return false; >- } >+ >+ bool isAccelerated() const override { return BackendType::isAccelerated; } > > protected: > ConcreteImageBuffer(std::unique_ptr<BackendType>&& backend) >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp >index 0dc0557b0d4f072edb98bc58c129b421a808f06d..210bbac327152300319280938153d162a739c2d3 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp >+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp >@@ -812,6 +812,9 @@ void GraphicsContext::drawImageBuffer(ImageBuffer& image, const FloatRect& desti > if (paintingDisabled()) > return; > >+ if (m_impl && m_impl->drawImageBuffer(image, destination, source, options)) >+ return; >+ > InterpolationQualityMaintainer interpolationQualityForThisScope(*this, options.interpolationQuality()); > image.draw(*this, destination, source, options); > } >diff --git a/Source/WebCore/platform/graphics/GraphicsContextImpl.h b/Source/WebCore/platform/graphics/GraphicsContextImpl.h >index c2cafe336cc56995dc40ded40167e683b42a57f7..3536d2f3b73cd488e98ec2e9fde248f8238c39ce 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContextImpl.h >+++ b/Source/WebCore/platform/graphics/GraphicsContextImpl.h >@@ -73,6 +73,7 @@ public: > virtual ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) = 0; > virtual ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) = 0; > >+ virtual bool drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) = 0; > virtual void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; > virtual void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0; > >diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h >index 0ae9fcbd0588d4c4e1ef5af3cc7f12b612bf78da..8b94f91d9ba9146244f01b703cb347a8a9d7d198 100644 >--- a/Source/WebCore/platform/graphics/ImageBuffer.h >+++ b/Source/WebCore/platform/graphics/ImageBuffer.h >@@ -28,6 +28,7 @@ > #pragma once > > #include "ImageBufferBackend.h" >+#include "RemoteResourceIdentifier.h" > #include "RenderingMode.h" > > namespace WebCore { >@@ -60,6 +61,9 @@ public: > > WEBCORE_EXPORT virtual ~ImageBuffer() = default; > >+ virtual bool isAccelerated() const = 0; >+ virtual RemoteResourceIdentifier remoteResourceIdentifier() const { return { }; } >+ > virtual GraphicsContext& context() const = 0; > virtual void flushContext() = 0; > >@@ -104,8 +108,6 @@ public: > virtual bool copyToPlatformTexture(GraphicsContextGLOpenGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const = 0; > virtual PlatformLayer* platformLayer() const = 0; > >- virtual bool isAccelerated() const = 0; >- > protected: > ImageBuffer() = default; > >diff --git a/Source/WebCore/platform/graphics/ImageBufferBackend.h b/Source/WebCore/platform/graphics/ImageBufferBackend.h >index 58fc14836d92aa20019f20feedc5571e9ab5e95c..cb5872567f0883b5bd02e0eecb8cefdbe710a8ec 100644 >--- a/Source/WebCore/platform/graphics/ImageBufferBackend.h >+++ b/Source/WebCore/platform/graphics/ImageBufferBackend.h >@@ -101,7 +101,7 @@ public: > virtual bool copyToPlatformTexture(GraphicsContextGLOpenGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const { return false; } > > static constexpr bool isOriginAtUpperLeftCorner = false; >- virtual bool isAccelerated() const { return false; } >+ static constexpr bool isAccelerated = false; > > protected: > WEBCORE_EXPORT ImageBufferBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace); >diff --git a/Source/WebCore/platform/graphics/RemoteResourceIdentifier.h b/Source/WebCore/platform/graphics/RemoteResourceIdentifier.h >index 2af542dfec847abc371aa2f1e8e4b8dd9fb110e5..6690becdc8b4aae8524b3f6810fb9264c85c499c 100644 >--- a/Source/WebCore/platform/graphics/RemoteResourceIdentifier.h >+++ b/Source/WebCore/platform/graphics/RemoteResourceIdentifier.h >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(GPU_PROCESS) >- > #include <wtf/ObjectIdentifier.h> > > namespace WebCore { >@@ -35,5 +33,3 @@ enum RemoteResourceIdentifierType { }; > using RemoteResourceIdentifier = ObjectIdentifier<RemoteResourceIdentifierType>; > > } // namespace WebCore >- >-#endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >index b65b4d64406beb76c409d3e8c654975ca9f7eb63..8ef4f786b7249142456eff1f0ad8216cc9055367 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >@@ -279,6 +279,12 @@ ImageDrawResult GraphicsContextImplCairo::drawTiledImage(Image& image, const Flo > return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions); > } > >+bool GraphicsContextImplCairo::drawImageBuffer(ImageBuffer&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) >+{ >+ // FIXME: Not implemented. >+ return false; >+} >+ > void GraphicsContextImplCairo::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > UNUSED_PARAM(imageSize); >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >index e5e20748c6d7620f10cf2156628ef7e0be601c7b..2858fc22fc1fb99262b46054ac46f92b6ce9f0d2 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >@@ -74,6 +74,8 @@ public: > ImageDrawResult drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; > ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&) override; > ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override; >+ >+ bool drawImageBuffer(ImageBuffer&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; > void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; > void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) override; > >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >index c8065a9ec2514644f7405f9a5413f62235627154..dbc3b7eb8b3d1ad88d0ab3f0eef90a7c8d85e030 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >@@ -190,11 +190,6 @@ IOSurface* ImageBufferIOSurfaceBackend::surface() > return m_surface.get(); > } > >-bool ImageBufferIOSurfaceBackend::isAccelerated() const >-{ >- return true; >-} >- > } // namespace WebCore > > #endif // HAVE(IOSURFACE) >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >index 2418f1d45d53d45933b3904a288c6101f14bcc31..323094ea795c5d2483c884403124a9040cc740fb 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >@@ -62,9 +62,9 @@ public: > RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override; > void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > IOSurface* surface(); >- bool isAccelerated() const override; > > static constexpr bool isOriginAtUpperLeftCorner = true; >+ static constexpr bool isAccelerated = true; > > protected: > static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&); >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayList.h b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >index 506dabab0b8b4b731476bdf9f3095672b912ef19..322ecc1c1c415cef059fccfbaf508f93a59212ac 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayList.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >@@ -64,6 +64,7 @@ enum class ItemType : uint8_t { > DrawImage, > DrawTiledImage, > DrawTiledScaledImage, >+ DrawImageBuffer, > DrawNativeImage, > DrawPattern, > DrawRect, >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp >index 23cc07e8ae442bdcea0d3674a5a8551c65cfdc87..d4617d3516f4f3e51d75d64434a6a39457a0001f 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp >@@ -33,9 +33,9 @@ > namespace WebCore { > namespace DisplayList { > >-DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, Recorder::Observer* observer) >+DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, Recorder::Delegate* delegate) > : m_context([&](GraphicsContext& displayListContext) { >- return makeUnique<Recorder>(displayListContext, m_displayList, GraphicsContextState(), FloatRect({ }, logicalSize), initialCTM, observer); >+ return makeUnique<Recorder>(displayListContext, m_displayList, GraphicsContextState(), FloatRect({ }, logicalSize), initialCTM, delegate); > }) > { > } >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >index 7b673f32ad815a50081b7e7ab108131717fde543..22ed256e80ad293a052069b743088a1351f47cc0 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h >@@ -35,7 +35,7 @@ namespace DisplayList { > class DrawingContext { > WTF_MAKE_FAST_ALLOCATED; > public: >- WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM = { }, Recorder::Observer* = nullptr); >+ WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM = { }, Recorder::Delegate* = nullptr); > > GraphicsContext& context() const { return const_cast<DrawingContext&>(*this).m_context; } > WEBCORE_EXPORT Recorder& recorder(); >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h b/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h >index 6fd912dfb8fe11c098dd6126a8c878ac6ba7ae02..32599e062d7cf59d1dc2ead01e760d66e3f7ec3c 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h >@@ -32,7 +32,7 @@ namespace WebCore { > namespace DisplayList { > > template<typename BackendType> >-class ImageBuffer : public ConcreteImageBuffer<BackendType>, public Recorder::Observer { >+class ImageBuffer : public ConcreteImageBuffer<BackendType> { > using BaseConcreteImageBuffer = ConcreteImageBuffer<BackendType>; > > public: >@@ -48,12 +48,12 @@ public: > > ImageBuffer(std::unique_ptr<BackendType>&& dataBackend, const FloatSize& size) > : BaseConcreteImageBuffer(WTFMove(dataBackend)) >- , m_drawingContext(size, initialDrawingContextCTM(size), this) >+ , m_drawingContext(size, initialDrawingContextCTM(size)) > { > } > >- ImageBuffer(const FloatSize& size) >- : m_drawingContext(size, initialDrawingContextCTM(size), this) >+ ImageBuffer(const FloatSize& size, Recorder::Delegate* delegate = nullptr) >+ : m_drawingContext(size, initialDrawingContextCTM(size), delegate) > { > } > >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >index 8d8b28193875c3166f81ed08e3d929961f7b8716..cf8892125610a8e3fb1226b24aaf2972dbb32405 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >@@ -110,6 +110,8 @@ size_t Item::sizeInBytes(const Item& item) > return sizeof(downcast<DrawTiledImage>(item)); > case ItemType::DrawTiledScaledImage: > return sizeof(downcast<DrawTiledScaledImage>(item)); >+ case ItemType::DrawImageBuffer: >+ return sizeof(downcast<DrawImageBuffer>(item)); > case ItemType::DrawNativeImage: > return sizeof(downcast<DrawNativeImage>(item)); > case ItemType::DrawPattern: >@@ -738,6 +740,32 @@ static TextStream& operator<<(TextStream& ts, const DrawTiledScaledImage& item) > return ts; > } > >+DrawImageBuffer::DrawImageBuffer(RemoteResourceIdentifier remoteResourceIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+ : DrawingItem(ItemType::DrawImageBuffer) >+ , m_remoteResourceIdentifier(remoteResourceIdentifier) >+ , m_destinationRect(destRect) >+ , m_srcRect(srcRect) >+ , m_options(options) >+{ >+} >+ >+DrawImageBuffer::~DrawImageBuffer() = default; >+ >+void DrawImageBuffer::apply(GraphicsContext&) const >+{ >+ // Should be handled by the delegate. >+ ASSERT_NOT_REACHED(); >+} >+ >+static TextStream& operator<<(TextStream& ts, const DrawImageBuffer& item) >+{ >+ ts << static_cast<const DrawingItem&>(item); >+ ts.dumpProperty("remote-resource-identifier", item.remoteResourceIdentifier()); >+ ts.dumpProperty("source-rect", item.source()); >+ ts.dumpProperty("dest-rect", item.destinationRect()); >+ return ts; >+} >+ > DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > : DrawingItem(ItemType::DrawNativeImage) > , m_image(image) >@@ -1496,6 +1524,7 @@ static TextStream& operator<<(TextStream& ts, const ItemType& type) > case ItemType::DrawImage: ts << "draw-image"; break; > case ItemType::DrawTiledImage: ts << "draw-tiled-image"; break; > case ItemType::DrawTiledScaledImage: ts << "draw-tiled-scaled-image"; break; >+ case ItemType::DrawImageBuffer: ts << "draw-image-buffer"; break; > case ItemType::DrawNativeImage: ts << "draw-native-image"; break; > case ItemType::DrawPattern: ts << "draw-pattern"; break; > case ItemType::DrawRect: ts << "draw-rect"; break; >@@ -1602,6 +1631,9 @@ TextStream& operator<<(TextStream& ts, const Item& item) > case ItemType::DrawTiledScaledImage: > ts << downcast<DrawTiledScaledImage>(item); > break; >+ case ItemType::DrawImageBuffer: >+ ts << downcast<DrawImageBuffer>(item); >+ break; > case ItemType::DrawNativeImage: > ts << downcast<DrawNativeImage>(item); > break; >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >index d4ca98e648451b26cbf649835b1da2f3c23b4aff..6c3ec282505e5c306f110017be276d60950fe6d1 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >@@ -35,6 +35,7 @@ > #include "ImageData.h" > #include "MediaPlayerIdentifier.h" > #include "Pattern.h" >+#include "RemoteResourceIdentifier.h" > #include "SharedBuffer.h" > #include <wtf/TypeCasts.h> > >@@ -1533,6 +1534,71 @@ Optional<Ref<DrawTiledScaledImage>> DrawTiledScaledImage::decode(Decoder& decode > return DrawTiledScaledImage::create(*imageHandle->image, *destination, *source, *tileScaleFactor, hRule, vRule, *imagePaintingOptions); > } > >+class DrawImageBuffer : public DrawingItem { >+public: >+ static Ref<DrawImageBuffer> create(RemoteResourceIdentifier remoteResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& options) >+ { >+ return adoptRef(*new DrawImageBuffer(remoteResourceIdentifier, destination, source, options)); >+ } >+ >+ WEBCORE_EXPORT virtual ~DrawImageBuffer(); >+ >+ RemoteResourceIdentifier remoteResourceIdentifier() const { return m_remoteResourceIdentifier; } >+ FloatRect source() const { return m_srcRect; } >+ FloatRect destinationRect() const { return m_destinationRect; } >+ ImagePaintingOptions options() const { return m_options; } >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<Ref<DrawImageBuffer>> decode(Decoder&); >+ >+private: >+ WEBCORE_EXPORT DrawImageBuffer(RemoteResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&); >+ >+ void apply(GraphicsContext&) const override; >+ >+ Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; } >+ >+ RemoteResourceIdentifier m_remoteResourceIdentifier; >+ FloatRect m_destinationRect; >+ FloatRect m_srcRect; >+ ImagePaintingOptions m_options; >+}; >+ >+template<class Encoder> >+void DrawImageBuffer::encode(Encoder& encoder) const >+{ >+ encoder << m_remoteResourceIdentifier; >+ encoder << m_destinationRect; >+ encoder << m_srcRect; >+ encoder << m_options; >+} >+ >+template<class Decoder> >+Optional<Ref<DrawImageBuffer>> DrawImageBuffer::decode(Decoder& decoder) >+{ >+ Optional<RemoteResourceIdentifier> remoteResourceIdentifier; >+ decoder >> remoteResourceIdentifier; >+ if (!remoteResourceIdentifier) >+ return WTF::nullopt; >+ >+ Optional<FloatRect> destination; >+ decoder >> destination; >+ if (!destination) >+ return WTF::nullopt; >+ >+ Optional<FloatRect> source; >+ decoder >> source; >+ if (!source) >+ return WTF::nullopt; >+ >+ Optional<ImagePaintingOptions> options; >+ decoder >> options; >+ if (!options) >+ return WTF::nullopt; >+ >+ return DrawImageBuffer::create(*remoteResourceIdentifier, *destination, *source, *options); >+} >+ > class DrawNativeImage : public DrawingItem { > public: > static Ref<DrawNativeImage> create(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >@@ -3066,6 +3132,9 @@ void Item::encode(Encoder& encoder) const > case ItemType::DrawTiledScaledImage: > encoder << downcast<DrawTiledScaledImage>(*this); > break; >+ case ItemType::DrawImageBuffer: >+ encoder << downcast<DrawImageBuffer>(*this); >+ break; > case ItemType::DrawNativeImage: > encoder << downcast<DrawNativeImage>(*this); > break; >@@ -3263,6 +3332,10 @@ Optional<Ref<Item>> Item::decode(Decoder& decoder) > if (auto item = DrawTiledScaledImage::decode(decoder)) > return static_reference_cast<Item>(WTFMove(*item)); > break; >+ case ItemType::DrawImageBuffer: >+ if (auto item = DrawImageBuffer::decode(decoder)) >+ return static_reference_cast<Item>(WTFMove(*item)); >+ break; > case ItemType::DrawNativeImage: > if (auto item = DrawNativeImage::decode(decoder)) > return static_reference_cast<Item>(WTFMove(*item)); >@@ -3425,6 +3498,7 @@ SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawGlyphs) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledScaledImage) >+SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImageBuffer) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawNativeImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPattern) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawRect) >@@ -3487,6 +3561,7 @@ template<> struct EnumTraits<WebCore::DisplayList::ItemType> { > WebCore::DisplayList::ItemType::DrawImage, > WebCore::DisplayList::ItemType::DrawTiledImage, > WebCore::DisplayList::ItemType::DrawTiledScaledImage, >+ WebCore::DisplayList::ItemType::DrawImageBuffer, > WebCore::DisplayList::ItemType::DrawNativeImage, > WebCore::DisplayList::ItemType::DrawPattern, > WebCore::DisplayList::ItemType::DrawRect, >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >index 68d2f680515eae558a0d4fbef6ab1a27e0a09eb4..8b71a655b2e2337d8ec2d074db5fcaa3ed689294 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >@@ -30,6 +30,7 @@ > #include "DisplayListDrawingContext.h" > #include "DisplayListItems.h" > #include "GraphicsContext.h" >+#include "ImageBuffer.h" > #include "Logging.h" > #include <wtf/MathExtras.h> > #include <wtf/text/TextStream.h> >@@ -37,10 +38,10 @@ > namespace WebCore { > namespace DisplayList { > >-Recorder::Recorder(GraphicsContext& context, DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, Observer* observer) >+Recorder::Recorder(GraphicsContext& context, DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, Delegate* delegate) > : GraphicsContextImpl(context, initialClip, AffineTransform()) > , m_displayList(displayList) >- , m_observer(observer) >+ , m_delegate(delegate) > { > LOG_WITH_STREAM(DisplayLists, stream << "\nRecording with clip " << initialClip); > m_stateStack.append({ state, initialCTM, initialClip }); >@@ -93,8 +94,8 @@ static Ref<Item> createStateChangeItem(const GraphicsContextStateChange& changes > > void Recorder::willAppendItem(const Item& item) > { >- if (m_observer) >- m_observer->willAppendItem(item); >+ if (m_delegate) >+ m_delegate->willAppendItem(item); > > if (item.isDrawingItem() > #if USE(CG) >@@ -166,6 +167,15 @@ ImageDrawResult Recorder::drawTiledImage(Image& image, const FloatRect& destinat > return ImageDrawResult::DidRecord; > } > >+bool Recorder::drawImageBuffer(WebCore::ImageBuffer& imageBuffer, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+{ >+ if (!m_delegate || !m_delegate->lockRemoteImageBuffer(imageBuffer)) >+ return false; >+ >+ appendItemAndUpdateExtent(DrawImageBuffer::create(imageBuffer.remoteResourceIdentifier(), destRect, srcRect, options)); >+ return true; >+} >+ > void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > appendItemAndUpdateExtent(DrawNativeImage::create(image, imageSize, destRect, srcRect, options)); >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >index 1b24c26c67288f817273a2d2aef2b4bc96e35c75..923c54885729fb53776dadad9a68bd513287b312 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >@@ -53,8 +53,8 @@ class Recorder : public GraphicsContextImpl { > WTF_MAKE_FAST_ALLOCATED; > WTF_MAKE_NONCOPYABLE(Recorder); > public: >- class Observer; >- WEBCORE_EXPORT Recorder(GraphicsContext&, DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Observer* = nullptr); >+ class Delegate; >+ WEBCORE_EXPORT Recorder(GraphicsContext&, DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Delegate* = nullptr); > WEBCORE_EXPORT virtual ~Recorder(); > > WEBCORE_EXPORT void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >@@ -63,10 +63,11 @@ public: > > void appendItemAndUpdateExtent(Ref<DrawingItem>&&); > >- class Observer { >+ class Delegate { > public: >- virtual ~Observer() { } >+ virtual ~Delegate() { } > virtual void willAppendItem(const Item&) { }; >+ virtual bool lockRemoteImageBuffer(WebCore::ImageBuffer&) { return false; } > }; > > private: >@@ -105,6 +106,7 @@ private: > ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&) override; > ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) override; > >+ bool drawImageBuffer(WebCore::ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override; > void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; > void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) override; > >@@ -187,7 +189,7 @@ private: > ContextState& currentState(); > > DisplayList& m_displayList; >- Observer* m_observer; >+ Delegate* m_delegate; > > Vector<ContextState, 32> m_stateStack; > }; >diff --git a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >index 304facbab1521791daa86db1531753e38671084d..a2c9e093fc14ba5c1e829c4b24e16540037a4455 100644 >--- a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >@@ -549,6 +549,12 @@ ImageDrawResult CairoOperationRecorder::drawTiledImage(Image& image, const Float > return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions); > } > >+bool CairoOperationRecorder::drawImageBuffer(ImageBuffer&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) >+{ >+ // FIXME: Not implemented. >+ return false; >+} >+ > void CairoOperationRecorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > struct DrawNativeImage final : PaintingOperation, OperationData<RefPtr<cairo_surface_t>, FloatRect, FloatRect, ImagePaintingOptions, float, Cairo::ShadowState> { >diff --git a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >index 572ff2166f6e973a763b67cb6bb96f43f26a8d50..38093d4135b4d7b6511a16087aff13f603ed13ba 100644 >--- a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >+++ b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >@@ -67,6 +67,8 @@ private: > WebCore::ImageDrawResult drawImage(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::ImagePaintingOptions&) override; > WebCore::ImageDrawResult drawTiledImage(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatPoint&, const WebCore::FloatSize&, const WebCore::FloatSize&, const WebCore::ImagePaintingOptions&) override; > WebCore::ImageDrawResult drawTiledImage(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::FloatSize&, WebCore::Image::TileRule, WebCore::Image::TileRule, const WebCore::ImagePaintingOptions&) override; >+ >+ bool drawImageBuffer(WebCore::ImageBuffer&, const WebCore::FloatRect& destination, const WebCore::FloatRect& source, const WebCore::ImagePaintingOptions&) override; > void drawNativeImage(const WebCore::NativeImagePtr&, const WebCore::FloatSize&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::ImagePaintingOptions&) override; > void drawPattern(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::AffineTransform&, const WebCore::FloatPoint&, const WebCore::FloatSize&, const WebCore::ImagePaintingOptions&) override; > >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h b/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >index 78d82f8c44bc37d213a80884abe84fcf02a04f2b..e268362a514bfb0d930df24c27fab989867f9be3 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >@@ -83,7 +83,7 @@ private: > return true; > } > >- return false; >+ return m_remoteRenderingBackend.applyResourceItem(item, context); > } > > void apply(WebCore::DisplayList::PaintFrameForMedia& item, WebCore::GraphicsContext& context) >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >index 1ef28ee2f2521dca554f480502f7274c9cc29b38..653912ae4af82753667f9389e4b5748332d16e22 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >+++ b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp >@@ -72,6 +72,18 @@ uint64_t RemoteRenderingBackend::messageSenderDestinationID() const > return m_renderingBackendIdentifier.toUInt64(); > } > >+bool RemoteRenderingBackend::applyResourceItem(const DisplayList::Item& item, GraphicsContext& context) >+{ >+ if (item.type() == DisplayList::ItemType::DrawImageBuffer) { >+ auto& drawItem = static_cast<const DisplayList::DrawImageBuffer&>(item); >+ if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(drawItem.remoteResourceIdentifier())) { >+ imageBuffer->draw(context, drawItem.destinationRect(), drawItem.source(), drawItem.options()); >+ return true; >+ } >+ } >+ return false; >+} >+ > void RemoteRenderingBackend::imageBufferBackendWasCreated(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, ImageBufferBackendHandle handle, RemoteResourceIdentifier remoteResourceIdentifier) > { > send(Messages::RemoteRenderingBackendProxy::ImageBufferBackendWasCreated(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle), remoteResourceIdentifier), m_renderingBackendIdentifier); >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >index effba449b188ea2b54d362c2ac54c28fc0ccb3ed..81874fae65d26182a801244372efcb06f189fd08 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h >@@ -42,6 +42,7 @@ > namespace WebCore { > namespace DisplayList { > class DisplayList; >+class Item; > } > class FloatSize; > enum class ColorSpace : uint8_t; >@@ -61,6 +62,9 @@ public: > > GPUConnectionToWebProcess* gpuConnectionToWebProcess() const; > >+ // Rendering operations. >+ bool applyResourceItem(const WebCore::DisplayList::Item&, WebCore::GraphicsContext&); >+ > // Messages to be sent. > void imageBufferBackendWasCreated(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle, WebCore::RemoteResourceIdentifier); > void flushDisplayListWasCommitted(DisplayListFlushIdentifier, WebCore::RemoteResourceIdentifier); >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 796db6996eedfe5b7e928001372054cf69c38046..7a3b2300b7c36890ffc253bba0554af20362f5d5 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -557,8 +557,8 @@ WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp > > WebProcess/GPU/GPUProcessConnection.cpp > WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >-WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp > WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >+WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp > WebProcess/GPU/media/AudioTrackPrivateRemote.cpp > WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp > WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 6bd9ac45f31ac43c2fc0964af5fdde4a78e68487..7486903488ca63a154a1e9c016e58fcc8e8bea89 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -4224,8 +4224,6 @@ > 71A676A522C62318007D6295 /* WKTouchActionGestureRecognizer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTouchActionGestureRecognizer.mm; path = ios/WKTouchActionGestureRecognizer.mm; sourceTree = "<group>"; }; > 71FB810A2260627A00323677 /* WebsiteSimulatedMouseEventsDispatchPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteSimulatedMouseEventsDispatchPolicy.h; sourceTree = "<group>"; }; > 7227800B2408BD7D007D376B /* PlatformRemoteImageBufferProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformRemoteImageBufferProxy.h; sourceTree = "<group>"; }; >- 7227800C24097A02007D376B /* RemoteImageBufferMessageHandlerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteImageBufferMessageHandlerProxy.cpp; sourceTree = "<group>"; }; >- 7227800D24097A02007D376B /* RemoteImageBufferMessageHandlerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteImageBufferMessageHandlerProxy.h; sourceTree = "<group>"; }; > 726D56DD253A64810002EF90 /* RemoteResourceCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteResourceCache.cpp; sourceTree = "<group>"; }; > 726D56DE253A64810002EF90 /* RemoteResourceCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteResourceCache.h; sourceTree = "<group>"; }; > 727A7F342407857D004D2931 /* ImageBufferShareableIOSurfaceBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferShareableIOSurfaceBackend.cpp; sourceTree = "<group>"; }; >@@ -4237,6 +4235,8 @@ > 727A7F492408AEE6004D2931 /* RemoteImageBufferProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteImageBufferProxy.h; sourceTree = "<group>"; }; > 728E86EF1795188C0087879E /* WebColorPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPickerMac.h; sourceTree = "<group>"; }; > 728E86F01795188C0087879E /* WebColorPickerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebColorPickerMac.mm; sourceTree = "<group>"; }; >+ 72B53157253C1E4D0049295A /* RemoteResourceCacheProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteResourceCacheProxy.cpp; sourceTree = "<group>"; }; >+ 72B53158253C1E4D0049295A /* RemoteResourceCacheProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteResourceCacheProxy.h; sourceTree = "<group>"; }; > 75A8D2C4187CCF9F00C39C9E /* WKWebsiteDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsiteDataStore.h; sourceTree = "<group>"; }; > 75A8D2C5187CCF9F00C39C9E /* WKWebsiteDataStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebsiteDataStore.mm; sourceTree = "<group>"; }; > 75A8D2D4187D1C0100C39C9E /* WKWebsiteDataStoreInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsiteDataStoreInternal.h; sourceTree = "<group>"; }; >@@ -8138,12 +8138,12 @@ > 727A7F36240788F0004D2931 /* ImageBufferShareableBitmapBackend.h */, > 727A7F38240788F0004D2931 /* PlatformImageBufferShareableBackend.h */, > 7227800B2408BD7D007D376B /* PlatformRemoteImageBufferProxy.h */, >- 7227800C24097A02007D376B /* RemoteImageBufferMessageHandlerProxy.cpp */, >- 7227800D24097A02007D376B /* RemoteImageBufferMessageHandlerProxy.h */, > 727A7F492408AEE6004D2931 /* RemoteImageBufferProxy.h */, > 5506409D2407160900AAE045 /* RemoteRenderingBackendProxy.cpp */, > 5506409E2407160900AAE045 /* RemoteRenderingBackendProxy.h */, > 550640A0240719E100AAE045 /* RemoteRenderingBackendProxy.messages.in */, >+ 72B53157253C1E4D0049295A /* RemoteResourceCacheProxy.cpp */, >+ 72B53158253C1E4D0049295A /* RemoteResourceCacheProxy.h */, > 5506409F2407196A00AAE045 /* RenderingBackendIdentifier.h */, > ); > path = graphics; >diff --git a/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h b/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h >index 9aff088e37ca76a7f864ae7e42bbb7004f1f1523..00060ec101c254e2b58a7646a4a424f3d02449e3 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/PlatformRemoteImageBufferProxy.h >@@ -37,4 +37,14 @@ using AcceleratedRemoteImageBufferProxy = RemoteImageBufferProxy<AcceleratedImag > > } // namespace WebKit > >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::UnacceleratedRemoteImageBufferProxy) >+ static bool isType(const WebCore::ImageBuffer& imageBuffer) { return imageBuffer.remoteResourceIdentifier() && !imageBuffer.isAccelerated(); } >+SPECIALIZE_TYPE_TRAITS_END() >+ >+#if HAVE(IOSURFACE) >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::AcceleratedRemoteImageBufferProxy) >+ static bool isType(const WebCore::ImageBuffer& imageBuffer) { return imageBuffer.remoteResourceIdentifier() && imageBuffer.isAccelerated(); } >+SPECIALIZE_TYPE_TRAITS_END() >+#endif >+ > #endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp >deleted file mode 100644 >index e9562a368e69e4230e7262c2636df286d746eac5..0000000000000000000000000000000000000000 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.cpp >+++ /dev/null >@@ -1,103 +0,0 @@ >-/* >- * Copyright (C) 2020 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "RemoteImageBufferMessageHandlerProxy.h" >- >-#if ENABLE(GPU_PROCESS) >- >-#include "ImageDataReference.h" >-#include "RemoteRenderingBackendMessages.h" >-#include "RemoteRenderingBackendProxy.h" >-#include <WebCore/DisplayListItems.h> >-#include <wtf/SystemTracing.h> >- >-namespace WebKit { >-using namespace WebCore; >- >-RemoteImageBufferMessageHandlerProxy::RemoteImageBufferMessageHandlerProxy(const FloatSize& size, RenderingMode renderingMode, float resolutionScale, ColorSpace colorSpace, RemoteRenderingBackendProxy& remoteRenderingBackendProxy) >- : m_remoteRenderingBackendProxy(makeWeakPtr(remoteRenderingBackendProxy)) >-{ >- // Create the RemoteImageBufferProxy. >- m_remoteRenderingBackendProxy->send(Messages::RemoteRenderingBackend::CreateImageBuffer(size, renderingMode, resolutionScale, colorSpace, m_remoteResourceIdentifier), m_remoteRenderingBackendProxy->renderingBackendIdentifier()); >-} >- >-RemoteImageBufferMessageHandlerProxy::~RemoteImageBufferMessageHandlerProxy() >-{ >- // Release the RemoteImageBufferProxy. >- if (!m_remoteRenderingBackendProxy) >- return; >- m_remoteRenderingBackendProxy->send(Messages::RemoteRenderingBackend::ReleaseRemoteResource(m_remoteResourceIdentifier), m_remoteRenderingBackendProxy->renderingBackendIdentifier()); >-} >- >-RefPtr<ImageData> RemoteImageBufferMessageHandlerProxy::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >-{ >- IPC::ImageDataReference imageDataReference; >- m_remoteRenderingBackendProxy->sendSync(Messages::RemoteRenderingBackend::GetImageData(outputFormat, srcRect, m_remoteResourceIdentifier), Messages::RemoteRenderingBackend::GetImageData::Reply(imageDataReference), m_remoteRenderingBackendProxy->renderingBackendIdentifier(), 1_s); >- return imageDataReference.buffer(); >-} >- >-void RemoteImageBufferMessageHandlerProxy::waitForImageBufferBackendWasCreated() >-{ >- if (m_remoteRenderingBackendProxy && !isBackendCreated()) >- m_remoteRenderingBackendProxy->waitForImageBufferBackendWasCreated(); >-} >- >-void RemoteImageBufferMessageHandlerProxy::waitForFlushDisplayListWasCommitted() >-{ >- if (m_remoteRenderingBackendProxy && isPendingFlush()) >- m_remoteRenderingBackendProxy->waitForFlushDisplayListWasCommitted(); >-} >- >-void RemoteImageBufferMessageHandlerProxy::flushDisplayList(WebCore::DisplayList::DisplayList& displayList) >-{ >- if (!m_remoteRenderingBackendProxy) >- return; >- >- TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd); >- m_remoteRenderingBackendProxy->send(Messages::RemoteRenderingBackend::FlushDisplayList(displayList, m_remoteResourceIdentifier), m_remoteRenderingBackendProxy->renderingBackendIdentifier()); >- displayList.clear(); >-} >- >-void RemoteImageBufferMessageHandlerProxy::flushDisplayListAndWaitCommit(WebCore::DisplayList::DisplayList& displayList) >-{ >- if (!m_remoteRenderingBackendProxy) >- return; >- >- TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd, 1); >- m_sentFlushIdentifier = DisplayListFlushIdentifier::generate(); >- m_remoteRenderingBackendProxy->send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit(displayList, m_sentFlushIdentifier, m_remoteResourceIdentifier), m_remoteRenderingBackendProxy->renderingBackendIdentifier()); >- displayList.clear(); >- waitForFlushDisplayListWasCommitted(); >-} >- >-void RemoteImageBufferMessageHandlerProxy::commitFlushContext(DisplayListFlushIdentifier flushIdentifier) >-{ >- m_receivedFlushIdentifier = flushIdentifier; >-} >- >-} // namespace WebKit >- >-#endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.h >deleted file mode 100644 >index b9a026a81298796e7bd35fa96eee904de4bfb5fd..0000000000000000000000000000000000000000 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferMessageHandlerProxy.h >+++ /dev/null >@@ -1,83 +0,0 @@ >-/* >- * Copyright (C) 2020 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#if ENABLE(GPU_PROCESS) >- >-#include "DisplayListFlushIdentifier.h" >-#include "ImageBufferBackendHandle.h" >-#include <WebCore/ColorSpace.h> >-#include <WebCore/DisplayList.h> >-#include <WebCore/FloatSize.h> >-#include <WebCore/RemoteResourceIdentifier.h> >-#include <WebCore/RenderingMode.h> >- >-namespace WebCore { >-class ImageData; >-enum class AlphaPremultiplication : uint8_t; >-} >- >-namespace WebKit { >- >-class RemoteRenderingBackendProxy; >- >-class RemoteImageBufferMessageHandlerProxy { >-public: >- virtual ~RemoteImageBufferMessageHandlerProxy(); >- >- WebCore::RemoteResourceIdentifier remoteResourceIdentifier() const { return m_remoteResourceIdentifier; } >- >- // Messages to be received. See RemoteRenderingBackend.messages.in. >- virtual void createBackend(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle) = 0; >- >- void commitFlushContext(DisplayListFlushIdentifier); >- >-protected: >- RemoteImageBufferMessageHandlerProxy(const WebCore::FloatSize&, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace, RemoteRenderingBackendProxy&); >- >- virtual bool isBackendCreated() const = 0; >- bool isPendingFlush() const { return m_sentFlushIdentifier != m_receivedFlushIdentifier; } >- >- RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) const; >- >- void waitForImageBufferBackendWasCreated(); >- void waitForFlushDisplayListWasCommitted(); >- >- // Messages to be sent. See RemoteRenderingBackendProxy.messages.in. >- void flushDisplayList(WebCore::DisplayList::DisplayList&); >- void flushDisplayListAndWaitCommit(WebCore::DisplayList::DisplayList&); >- >-private: >- WeakPtr<RemoteRenderingBackendProxy> m_remoteRenderingBackendProxy; >- WebCore::RemoteResourceIdentifier m_remoteResourceIdentifier { WebCore::RemoteResourceIdentifier::generate() }; >- >- DisplayListFlushIdentifier m_sentFlushIdentifier; >- DisplayListFlushIdentifier m_receivedFlushIdentifier; >-}; >- >-} // namespace WebKit >- >-#endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >index 20fbf81c982552ef76bb6cd15dc3a1e9d3880ec3..e0d2ff7d1a66a1ce52a351f16f8455da7893d0c9 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >@@ -27,7 +27,6 @@ > > #if ENABLE(GPU_PROCESS) > >-#include "RemoteImageBufferMessageHandlerProxy.h" > #include <WebCore/DisplayListImageBuffer.h> > #include <WebCore/DisplayListItems.h> > #include <WebCore/DisplayListRecorder.h> >@@ -37,54 +36,71 @@ namespace WebKit { > class RemoteRenderingBackend; > > template<typename BackendType> >-class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public RemoteImageBufferMessageHandlerProxy { >+class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public WebCore::DisplayList::Recorder::Delegate { > using BaseDisplayListImageBuffer = WebCore::DisplayList::ImageBuffer<BackendType>; > using BaseDisplayListImageBuffer::m_backend; > using BaseDisplayListImageBuffer::m_drawingContext; > > public: >- static std::unique_ptr<RemoteImageBufferProxy> create(const WebCore::FloatSize& size, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, RemoteRenderingBackendProxy& remoteRenderingBackendProxy) >+ static std::unique_ptr<RemoteImageBufferProxy> create(const WebCore::FloatSize& size, float resolutionScale, RemoteRenderingBackendProxy& remoteRenderingBackendProxy) > { > if (BackendType::calculateBackendSize(size, resolutionScale).isEmpty()) > return nullptr; > >- return std::unique_ptr<RemoteImageBufferProxy>(new RemoteImageBufferProxy(size, renderingMode, resolutionScale, colorSpace, remoteRenderingBackendProxy)); >+ return std::unique_ptr<RemoteImageBufferProxy>(new RemoteImageBufferProxy(size, remoteRenderingBackendProxy)); > } > > ~RemoteImageBufferProxy() > { >+ if (!m_remoteRenderingBackendProxy) >+ return; > flushDrawingContext(); >+ m_remoteRenderingBackendProxy->remoteResourceCacheProxy().releaseImageBuffer(m_remoteResourceIdentifier); > } > >-protected: >- RemoteImageBufferProxy(const WebCore::FloatSize& size, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, RemoteRenderingBackendProxy& remoteRenderingBackendProxy) >- : BaseDisplayListImageBuffer(size) >- , RemoteImageBufferMessageHandlerProxy(size, renderingMode, resolutionScale, colorSpace, remoteRenderingBackendProxy) >- { >- } >+ WebCore::RemoteResourceIdentifier remoteResourceIdentifier() const override { return m_remoteResourceIdentifier; } > >- void createBackend(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace colorSpace, ImageBufferBackendHandle handle) override >+ void createBackend(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace colorSpace, ImageBufferBackendHandle handle) > { > ASSERT(!m_backend); > m_backend = BackendType::create(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle)); > } >- >- bool isBackendCreated() const override { return m_backend.get(); } >+ >+ void commitFlushDisplayList(DisplayListFlushIdentifier flushIdentifier) >+ { >+ m_receivedFlushIdentifier = flushIdentifier; >+ } >+ >+protected: >+ RemoteImageBufferProxy(const WebCore::FloatSize& size, RemoteRenderingBackendProxy& remoteRenderingBackendProxy) >+ : BaseDisplayListImageBuffer(size, this) >+ , m_remoteRenderingBackendProxy(makeWeakPtr(remoteRenderingBackendProxy)) >+ { >+ ASSERT(m_remoteRenderingBackendProxy); >+ } >+ >+ bool isPendingFlush() const { return m_sentFlushIdentifier != m_receivedFlushIdentifier; } > > BackendType* ensureBackendCreated() const override > { >- if (!m_backend) >- const_cast<RemoteImageBufferProxy&>(*this).RemoteImageBufferMessageHandlerProxy::waitForImageBufferBackendWasCreated(); >+ if (!m_backend && m_remoteRenderingBackendProxy) >+ m_remoteRenderingBackendProxy->waitForImageBufferBackendWasCreated(); > return m_backend.get(); > } > > RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) const override > { >+ if (!m_remoteRenderingBackendProxy) >+ return nullptr; >+ > auto& displayList = const_cast<RemoteImageBufferProxy*>(this)->m_drawingContext.displayList(); >- const_cast<RemoteImageBufferProxy*>(this)->RemoteImageBufferMessageHandlerProxy::flushDisplayList(displayList); >- auto result = const_cast<RemoteImageBufferProxy*>(this)->RemoteImageBufferMessageHandlerProxy::getImageData(outputFormat, srcRect); >+ if (displayList.itemCount()) { >+ const_cast<RemoteImageBufferProxy&>(*this).flushDisplayList(displayList); >+ displayList.clear(); >+ } >+ > // getImageData is synchronous, which means we've already received the CommitImageBufferFlushContext message. >- return result; >+ return m_remoteRenderingBackendProxy->getImageData(outputFormat, srcRect, m_remoteResourceIdentifier); > } > > void putImageData(WebCore::AlphaPremultiplication inputFormat, const WebCore::ImageData& imageData, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint = { }, WebCore::AlphaPremultiplication destFormat = WebCore::AlphaPremultiplication::Premultiplied) override >@@ -104,17 +120,53 @@ protected: > void flushDrawingContext() override > { > auto& displayList = m_drawingContext.displayList(); >- if (displayList.itemCount()) >- RemoteImageBufferMessageHandlerProxy::flushDisplayListAndWaitCommit(displayList); >+ if (!displayList.itemCount() || !m_remoteRenderingBackendProxy) >+ return; >+ >+ TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd, 1); >+ m_sentFlushIdentifier = m_remoteRenderingBackendProxy->flushDisplayListAndCommit(displayList, m_remoteResourceIdentifier); >+ >+ // Wait for our DisplayList to be flushed but do not hang. >+ static constexpr unsigned maxWaitingFlush = 3; >+ for (unsigned numWaitingFlush = 0; numWaitingFlush < maxWaitingFlush && isPendingFlush(); ++numWaitingFlush) >+ m_remoteRenderingBackendProxy->waitForFlushDisplayListWasCommitted(); >+ >+ m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_remoteResourceIdentifier); >+ displayList.clear(); >+ } >+ >+ void flushDisplayList(const WebCore::DisplayList::DisplayList& displayList) override >+ { >+ if (!displayList.itemCount() || !m_remoteRenderingBackendProxy) >+ return; >+ >+ TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd); >+ m_remoteRenderingBackendProxy->flushDisplayList(displayList, m_remoteResourceIdentifier); >+ m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_remoteResourceIdentifier); > } >- >+ > void willAppendItem(const WebCore::DisplayList::Item&) override > { > constexpr size_t DisplayListBatchSize = 512; > auto& displayList = m_drawingContext.displayList(); >- if (displayList.itemCount() >= DisplayListBatchSize) >- RemoteImageBufferMessageHandlerProxy::flushDisplayList(displayList); >+ if (displayList.itemCount() < DisplayListBatchSize || !m_remoteRenderingBackendProxy) >+ return; >+ >+ flushDisplayList(displayList); >+ displayList.clear(); >+ } >+ >+ bool lockRemoteImageBuffer(WebCore::ImageBuffer& imageBuffer) override >+ { >+ if (!m_remoteRenderingBackendProxy) >+ return false; >+ return m_remoteRenderingBackendProxy->remoteResourceCacheProxy().lockRemoteImageBufferForRemoteClient(imageBuffer, m_remoteResourceIdentifier); > } >+ >+ DisplayListFlushIdentifier m_sentFlushIdentifier; >+ DisplayListFlushIdentifier m_receivedFlushIdentifier; >+ WebCore::RemoteResourceIdentifier m_remoteResourceIdentifier { WebCore::RemoteResourceIdentifier::generate() }; >+ WeakPtr<RemoteRenderingBackendProxy> m_remoteRenderingBackendProxy; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >index b1461b482148d2b75b40f098d940cde10ab4ffce..5d4e0820e09a514f9bfe538ea28aff2e89e82c73 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp >@@ -30,6 +30,7 @@ > > #include "GPUConnectionToWebProcess.h" > #include "GPUProcessConnection.h" >+#include "ImageDataReference.h" > #include "PlatformRemoteImageBufferProxy.h" > #include "RemoteRenderingBackendMessages.h" > #include "RemoteRenderingBackendProxyMessages.h" >@@ -88,38 +89,75 @@ bool RemoteRenderingBackendProxy::waitForFlushDisplayListWasCommitted() > > std::unique_ptr<ImageBuffer> RemoteRenderingBackendProxy::createImageBuffer(const FloatSize& size, ShouldAccelerate shouldAccelerate, float resolutionScale, ColorSpace colorSpace) > { >+ RenderingMode renderingMode; >+ std::unique_ptr<WebCore::ImageBuffer> imageBuffer; >+ > if (shouldAccelerate == ShouldAccelerate::Yes) { >- if (auto imageBuffer = AcceleratedRemoteImageBufferProxy::create(size, RenderingMode::RemoteAccelerated, resolutionScale, colorSpace, *this)) { >- m_imageBufferMessageHandlerMap.add(imageBuffer->remoteResourceIdentifier(), imageBuffer.get()); >- return imageBuffer; >- } >+ renderingMode = RenderingMode::RemoteAccelerated; >+ imageBuffer = AcceleratedRemoteImageBufferProxy::create(size, resolutionScale, *this); >+ } >+ >+ if (!imageBuffer) { >+ renderingMode = RenderingMode::RemoteUnaccelerated; >+ imageBuffer = UnacceleratedRemoteImageBufferProxy::create(size, resolutionScale, *this); > } > >- if (auto imageBuffer = UnacceleratedRemoteImageBufferProxy::create(size, RenderingMode::RemoteUnaccelerated, resolutionScale, colorSpace, *this)) { >- m_imageBufferMessageHandlerMap.add(imageBuffer->remoteResourceIdentifier(), imageBuffer.get()); >+ if (imageBuffer) { >+ send(Messages::RemoteRenderingBackend::CreateImageBuffer(size, renderingMode, resolutionScale, colorSpace, imageBuffer->remoteResourceIdentifier()), m_renderingBackendIdentifier); >+ m_remoteResourceCacheProxy.cacheImageBuffer(imageBuffer->remoteResourceIdentifier(), imageBuffer.get()); > return imageBuffer; > } > >+ ASSERT_NOT_REACHED(); > return nullptr; > } > >+RefPtr<ImageData> RemoteRenderingBackendProxy::getImageData(AlphaPremultiplication outputFormat, const IntRect& srcRect, RemoteResourceIdentifier remoteResourceIdentifier) >+{ >+ IPC::ImageDataReference imageDataReference; >+ sendSync(Messages::RemoteRenderingBackend::GetImageData(outputFormat, srcRect, remoteResourceIdentifier), Messages::RemoteRenderingBackend::GetImageData::Reply(imageDataReference), m_renderingBackendIdentifier, 1_s); >+ return imageDataReference.buffer(); >+} >+ >+void RemoteRenderingBackendProxy::flushDisplayList(const DisplayList::DisplayList& displayList, RemoteResourceIdentifier remoteResourceIdentifier) >+{ >+ send(Messages::RemoteRenderingBackend::FlushDisplayList(displayList, remoteResourceIdentifier), m_renderingBackendIdentifier); >+} >+ >+DisplayListFlushIdentifier RemoteRenderingBackendProxy::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, RemoteResourceIdentifier remoteResourceIdentifier) >+{ >+ DisplayListFlushIdentifier sentFlushIdentifier = DisplayListFlushIdentifier::generate(); >+ send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit(displayList, sentFlushIdentifier, remoteResourceIdentifier), m_renderingBackendIdentifier); >+ return sentFlushIdentifier; >+} >+ > void RemoteRenderingBackendProxy::releaseRemoteResource(RemoteResourceIdentifier remoteResourceIdentifier) > { >- // CreateImageBuffer message should have been received before this one. >- bool found = m_imageBufferMessageHandlerMap.remove(remoteResourceIdentifier); >- ASSERT_UNUSED(found, found); >+ send(Messages::RemoteRenderingBackend::ReleaseRemoteResource(remoteResourceIdentifier), m_renderingBackendIdentifier); > } > > void RemoteRenderingBackendProxy::imageBufferBackendWasCreated(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, ImageBufferBackendHandle handle, RemoteResourceIdentifier remoteResourceIdentifier) > { >- if (auto imageBuffer = m_imageBufferMessageHandlerMap.get(remoteResourceIdentifier)) >- imageBuffer->createBackend(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle)); >+ auto imageBuffer = m_remoteResourceCacheProxy.cachedImageBuffer(remoteResourceIdentifier); >+ if (!imageBuffer) >+ return; >+ >+ if (imageBuffer->isAccelerated()) >+ downcast<AcceleratedRemoteImageBufferProxy>(*imageBuffer).createBackend(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle)); >+ else >+ downcast<UnacceleratedRemoteImageBufferProxy>(*imageBuffer).createBackend(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle)); > } > > void RemoteRenderingBackendProxy::flushDisplayListWasCommitted(DisplayListFlushIdentifier flushIdentifier, RemoteResourceIdentifier remoteResourceIdentifier) > { >- if (auto imageBuffer = m_imageBufferMessageHandlerMap.get(remoteResourceIdentifier)) >- imageBuffer->commitFlushContext(flushIdentifier); >+ auto imageBuffer = m_remoteResourceCacheProxy.cachedImageBuffer(remoteResourceIdentifier); >+ if (!imageBuffer) >+ return; >+ >+ if (imageBuffer->isAccelerated()) >+ downcast<AcceleratedRemoteImageBufferProxy>(*imageBuffer).commitFlushDisplayList(flushIdentifier); >+ else >+ downcast<UnacceleratedRemoteImageBufferProxy>(*imageBuffer).commitFlushDisplayList(flushIdentifier); > } > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >index 9d290023d49721ead6cb98799d26f5a8d0ed4dbe..3fe51c5da95e37503d7dbdb45eb8697cd4263f72 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h >@@ -31,16 +31,24 @@ > #include "ImageBufferBackendHandle.h" > #include "MessageReceiver.h" > #include "MessageSender.h" >-#include "RemoteImageBufferMessageHandlerProxy.h" >+#include "RemoteResourceCacheProxy.h" > #include "RenderingBackendIdentifier.h" >-#include <WebCore/ColorSpace.h> >-#include <WebCore/DisplayList.h> >-#include <WebCore/FloatSize.h> > #include <WebCore/RemoteResourceIdentifier.h> >-#include <WebCore/RenderingMode.h> >-#include <wtf/HashMap.h> > #include <wtf/WeakPtr.h> > >+namespace WebCore { >+namespace DisplayList { >+class DisplayList; >+class Item; >+} >+class FloatSize; >+class ImageData; >+enum class AlphaPremultiplication : uint8_t; >+enum class ColorSpace : uint8_t; >+enum class RenderingMode : uint8_t; >+enum class ShouldAccelerate : bool; >+} >+ > namespace WebKit { > > class RemoteRenderingBackendProxy >@@ -52,7 +60,7 @@ public: > > ~RemoteRenderingBackendProxy(); > >- RenderingBackendIdentifier renderingBackendIdentifier() const { return m_renderingBackendIdentifier; } >+ RemoteResourceCacheProxy& remoteResourceCacheProxy() { return m_remoteResourceCacheProxy; } > > // IPC::MessageSender. > IPC::Connection* messageSenderConnection() const override; >@@ -61,7 +69,11 @@ public: > // IPC::MessageReceiver > void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; > >+ // Messages to be sent. > std::unique_ptr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, WebCore::ShouldAccelerate, float resolutionScale, WebCore::ColorSpace); >+ RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect, WebCore::RemoteResourceIdentifier); >+ void flushDisplayList(const WebCore::DisplayList::DisplayList&, WebCore::RemoteResourceIdentifier); >+ DisplayListFlushIdentifier flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, WebCore::RemoteResourceIdentifier); > void releaseRemoteResource(WebCore::RemoteResourceIdentifier); > > bool waitForImageBufferBackendWasCreated(); >@@ -74,8 +86,7 @@ private: > void imageBufferBackendWasCreated(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle, WebCore::RemoteResourceIdentifier); > void flushDisplayListWasCommitted(DisplayListFlushIdentifier, WebCore::RemoteResourceIdentifier); > >- using ImageBufferMessageHandlerMap = HashMap<WebCore::RemoteResourceIdentifier, RemoteImageBufferMessageHandlerProxy*>; >- ImageBufferMessageHandlerMap m_imageBufferMessageHandlerMap; >+ RemoteResourceCacheProxy m_remoteResourceCacheProxy { *this }; > RenderingBackendIdentifier m_renderingBackendIdentifier { RenderingBackendIdentifier::generate() }; > }; > >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..f40f419741110b9c587d05f0b258621ddf82c257 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp >@@ -0,0 +1,129 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "RemoteResourceCacheProxy.h" >+ >+#if ENABLE(GPU_PROCESS) >+ >+#include "RemoteRenderingBackendProxy.h" >+ >+namespace WebKit { >+using namespace WebCore; >+ >+RemoteResourceCacheProxy::RemoteResourceCacheProxy(RemoteRenderingBackendProxy& remoteRenderingBackendProxy) >+ : m_remoteRenderingBackendProxy(remoteRenderingBackendProxy) >+{ >+} >+ >+void RemoteResourceCacheProxy::cacheImageBuffer(RemoteResourceIdentifier identifier, WebCore::ImageBuffer* imageBuffer) >+{ >+ auto addResult = m_imageBuffers.add(identifier, imageBuffer); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+} >+ >+ImageBuffer* RemoteResourceCacheProxy::cachedImageBuffer(RemoteResourceIdentifier identifier) >+{ >+ return m_imageBuffers.get(identifier); >+} >+ >+void RemoteResourceCacheProxy::releaseImageBuffer(RemoteResourceIdentifier remoteResourceIdentifier) >+{ >+ bool found = m_imageBuffers.remove(remoteResourceIdentifier); >+ ASSERT_UNUSED(found, found); >+ >+ // Tell the GPU process to remove this resource unless it's pending replaying back. >+ releaseRemoteResource(remoteResourceIdentifier); >+} >+ >+bool RemoteResourceCacheProxy::lockRemoteImageBufferForRemoteClient(ImageBuffer& imageBuffer, RemoteResourceIdentifier remoteClientIdentifier) >+{ >+ if (!imageBuffer.remoteResourceIdentifier()) >+ return false; >+ >+ if (cachedImageBuffer(imageBuffer.remoteResourceIdentifier()) != &imageBuffer) { >+ ASSERT_NOT_REACHED(); >+ return false; >+ } >+ >+ lockRemoteResourceForRemoteClient(imageBuffer.remoteResourceIdentifier(), remoteClientIdentifier); >+ return true; >+} >+ >+void RemoteResourceCacheProxy::lockRemoteResourceForRemoteClient(RemoteResourceIdentifier remoteResourceIdentifier, RemoteResourceIdentifier remoteClientIdentifier) >+{ >+ // Add the "resource -> client" dependency in m_lockedRemoteResourceForRemoteClients. >+ auto& clients = m_lockedRemoteResourceForRemoteClients.ensure(remoteResourceIdentifier, [&] { >+ return RemoteClientsHashSet(); >+ }).iterator->value; >+ >+ clients.add(remoteClientIdentifier); >+} >+ >+void RemoteResourceCacheProxy::releaseRemoteResource(RemoteResourceIdentifier remoteResourceIdentifier) >+{ >+ ASSERT(!m_pendingUnlockRemoteResourceForRemoteClients.contains(remoteResourceIdentifier)); >+ >+ // If we have recorded resource -> client dependency before in m_lockedRemoteResourceForRemoteClients, move this >+ // dependency to m_pendingUnlockRemoteResourceForRemoteClients. Otherwise remove the resource in the GPU Process. >+ if (m_lockedRemoteResourceForRemoteClients.contains(remoteResourceIdentifier)) >+ m_pendingUnlockRemoteResourceForRemoteClients.add(remoteResourceIdentifier, m_lockedRemoteResourceForRemoteClients.take(remoteResourceIdentifier)); >+ else >+ m_remoteRenderingBackendProxy.releaseRemoteResource(remoteResourceIdentifier); >+} >+ >+void RemoteResourceCacheProxy::unlockRemoteResourcesForRemoteClient(RemoteResourceIdentifier remoteClientIdentifier) >+{ >+ auto removeRemoteClient = [&](RemoteResourceClientsHashMap& remoteResourceForRemoteClients, RemoteResourceIdentifier remoteClientIdentifier) { >+ Vector<RemoteResourceIdentifier> remoteResourceClientsToBeRemoved; >+ >+ // Remove all the resource -> client dependencies from remoteResourceClientsHashMap. >+ for (auto& pair : remoteResourceForRemoteClients) { >+ pair.value.remove(remoteClientIdentifier); >+ if (pair.value.isEmpty()) >+ remoteResourceClientsToBeRemoved.append(pair.key); >+ } >+ >+ // Return a list of the unreferenced resources. >+ return remoteResourceClientsToBeRemoved; >+ }; >+ >+ // Remove all the resource -> client dependencies from m_lockedRemoteResourceForRemoteClients. >+ for (auto remoteResourceIdentifier : removeRemoteClient(m_lockedRemoteResourceForRemoteClients, remoteClientIdentifier)) >+ m_lockedRemoteResourceForRemoteClients.remove(remoteResourceIdentifier); >+ >+ // Remove all the resource -> client dependencies from m_pendingUnlockRemoteResourceForRemoteClients. >+ for (auto remoteResourceIdentifier : removeRemoteClient(m_pendingUnlockRemoteResourceForRemoteClients, remoteClientIdentifier)) { >+ // Remove the unreferenced resources from m_remoteResourceClientsPendingReleaseHashMap. >+ m_pendingUnlockRemoteResourceForRemoteClients.remove(remoteResourceIdentifier); >+ >+ // Tell the GPU process to remove this resource. >+ m_remoteRenderingBackendProxy.releaseRemoteResource(remoteResourceIdentifier); >+ } >+} >+ >+} // namespace WebKit >+ >+#endif // ENABLE(GPU_PROCESS) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h >new file mode 100644 >index 0000000000000000000000000000000000000000..478e4b993d775cd8d602aaf94713988d583ef4a0 >--- /dev/null >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h >@@ -0,0 +1,68 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(GPU_PROCESS) >+ >+#include <WebCore/RemoteResourceIdentifier.h> >+#include <wtf/HashMap.h> >+ >+namespace WebCore { >+class ImageBuffer; >+} >+ >+namespace WebKit { >+ >+class RemoteRenderingBackendProxy; >+ >+class RemoteResourceCacheProxy { >+public: >+ RemoteResourceCacheProxy(RemoteRenderingBackendProxy&); >+ >+ void cacheImageBuffer(WebCore::RemoteResourceIdentifier, WebCore::ImageBuffer*); >+ WebCore::ImageBuffer* cachedImageBuffer(WebCore::RemoteResourceIdentifier); >+ void releaseImageBuffer(WebCore::RemoteResourceIdentifier); >+ >+ bool lockRemoteImageBufferForRemoteClient(WebCore::ImageBuffer&, WebCore::RemoteResourceIdentifier remoteClientIdentifier); >+ void unlockRemoteResourcesForRemoteClient(WebCore::RemoteResourceIdentifier remoteClientIdentifier); >+ >+private: >+ using RemoteClientsHashSet = HashSet<WebCore::RemoteResourceIdentifier>; >+ using RemoteResourceClientsHashMap = HashMap<WebCore::RemoteResourceIdentifier, RemoteClientsHashSet>; >+ using RemoteImageBufferProxyHashMap = HashMap<WebCore::RemoteResourceIdentifier, WebCore::ImageBuffer*>; >+ >+ void lockRemoteResourceForRemoteClient(WebCore::RemoteResourceIdentifier, WebCore::RemoteResourceIdentifier remoteClientIdentifier); >+ void releaseRemoteResource(WebCore::RemoteResourceIdentifier); >+ >+ RemoteImageBufferProxyHashMap m_imageBuffers; >+ RemoteResourceClientsHashMap m_lockedRemoteResourceForRemoteClients; >+ RemoteResourceClientsHashMap m_pendingUnlockRemoteResourceForRemoteClients; >+ RemoteRenderingBackendProxy& m_remoteRenderingBackendProxy; >+}; >+ >+} // namespace WebKit >+ >+#endif // ENABLE(GPU_PROCESS)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 217566
:
411031
|
411032
|
411934
|
411947
|
412398
|
412403