Diff
Modified: trunk/Source/WebCore/ChangeLog (269064 => 269065)
--- trunk/Source/WebCore/ChangeLog 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/ChangeLog 2020-10-27 19:53:22 UTC (rev 269065)
@@ -1,3 +1,46 @@
+2020-10-27 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process]: Implement DisplayList::DrawImageBuffer item
+ https://bugs.webkit.org/show_bug.cgi?id=217566
+
+ Reviewed by Simon Fraser.
+
+ Add the DrawImageBuffer DisplayList item. It will be used only for GPU
+ rendering. The renderingResourceIdentifier 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):
+ (WebCore::GraphicsContext::drawConsumingImageBuffer):
+ * 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::renderingResourceIdentifier 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::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-27 Zalan Bujtas <[email protected]>
showRenderTree should output line vertical geometry.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -812,6 +812,9 @@
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);
}
@@ -836,7 +839,10 @@
{
if (paintingDisabled() || !image)
return;
-
+
+ if (m_impl && m_impl->drawImageBuffer(*image, destination, source, options))
+ return;
+
InterpolationQualityMaintainer interpolationQualityForThisScope(*this, options.interpolationQuality());
ImageBuffer::drawConsuming(WTFMove(image), *this, destination, source, options);
}
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextImpl.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -73,6 +73,7 @@
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;
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -279,6 +279,12 @@
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);
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -74,6 +74,8 @@
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;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -64,6 +64,7 @@
DrawImage,
DrawTiledImage,
DrawTiledScaledImage,
+ DrawImageBuffer,
DrawNativeImage,
DrawPattern,
DrawRect,
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -110,6 +110,8 @@
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 @@
return ts;
}
+DrawImageBuffer::DrawImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+ : DrawingItem(ItemType::DrawImageBuffer)
+ , m_renderingResourceIdentifier(renderingResourceIdentifier)
+ , 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.renderingResourceIdentifier());
+ 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 @@
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 @@
case ItemType::DrawTiledScaledImage:
ts << downcast<DrawTiledScaledImage>(item);
break;
+ case ItemType::DrawImageBuffer:
+ ts << downcast<DrawImageBuffer>(item);
+ break;
case ItemType::DrawNativeImage:
ts << downcast<DrawNativeImage>(item);
break;
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -35,6 +35,7 @@
#include "ImageData.h"
#include "MediaPlayerIdentifier.h"
#include "Pattern.h"
+#include "RenderingResourceIdentifier.h"
#include "SharedBuffer.h"
#include <wtf/TypeCasts.h>
@@ -1533,6 +1534,71 @@
return DrawTiledScaledImage::create(*imageHandle->image, *destination, *source, *tileScaleFactor, hRule, vRule, *imagePaintingOptions);
}
+class DrawImageBuffer : public DrawingItem {
+public:
+ static Ref<DrawImageBuffer> create(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& options)
+ {
+ return adoptRef(*new DrawImageBuffer(renderingResourceIdentifier, destination, source, options));
+ }
+
+ WEBCORE_EXPORT virtual ~DrawImageBuffer();
+
+ RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; }
+ 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(RenderingResourceIdentifier, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&);
+
+ void apply(GraphicsContext&) const override;
+
+ Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; }
+
+ RenderingResourceIdentifier m_renderingResourceIdentifier;
+ FloatRect m_destinationRect;
+ FloatRect m_srcRect;
+ ImagePaintingOptions m_options;
+};
+
+template<class Encoder>
+void DrawImageBuffer::encode(Encoder& encoder) const
+{
+ encoder << m_renderingResourceIdentifier;
+ encoder << m_destinationRect;
+ encoder << m_srcRect;
+ encoder << m_options;
+}
+
+template<class Decoder>
+Optional<Ref<DrawImageBuffer>> DrawImageBuffer::decode(Decoder& decoder)
+{
+ Optional<RenderingResourceIdentifier> renderingResourceIdentifier;
+ decoder >> renderingResourceIdentifier;
+ if (!renderingResourceIdentifier)
+ 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(*renderingResourceIdentifier, *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 @@
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 @@
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(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 @@
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,
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -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>
@@ -166,6 +167,15 @@
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.renderingResourceIdentifier(), 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));
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -66,6 +66,7 @@
class Delegate {
public:
virtual ~Delegate() { }
+ virtual bool lockRemoteImageBuffer(WebCore::ImageBuffer&) { return false; }
virtual void willAppendItem(const Item&) { };
};
@@ -105,6 +106,7 @@
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;
Modified: trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -549,6 +549,12 @@
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> {
Modified: trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h (269064 => 269065)
--- trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -67,6 +67,8 @@
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;
Modified: trunk/Source/WebKit/ChangeLog (269064 => 269065)
--- trunk/Source/WebKit/ChangeLog 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/ChangeLog 2020-10-27 19:53:22 UTC (rev 269065)
@@ -1,3 +1,57 @@
+2020-10-27 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process]: Implement DisplayList::DrawImageBuffer item
+ https://bugs.webkit.org/show_bug.cgi?id=217566
+
+ Reviewed by Simon Fraser.
+
+ 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::renderingResourceIdentifier().
+
+ 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 renderingResourceIdentifier is one
+ of the ImageBuffers in its RemoteResourceCache or not.
+
+ -- If there is a cached ImageBuffer, RemoteRenderingBackend::applyResourceItem()
+ will draw it in the GraphicsContext.
+
+ * GPUProcess/graphics/RemoteImageBuffer.h:
+ (WebKit::RemoteImageBuffer::apply): Deleted.
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::applyResourceItem):
+ (WebKit::RemoteRenderingBackend::applyMediaItem):
+ * GPUProcess/graphics/RemoteRenderingBackend.h:
+ * GPUProcess/graphics/RemoteResourceCache.cpp:
+ (WebKit::RemoteResourceCache::cachedImageBuffer):
+ * 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-27 Alex Christensen <[email protected]>
Use NSURLSessionAuthChallengeRejectProtectionSpace if WKNavigationDelegate didReceiveAuthenticationChallenge is not implemented
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (269064 => 269065)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -78,31 +78,12 @@
return true;
}
- if (item.type() == WebCore::DisplayList::ItemType::PaintFrameForMedia) {
- apply(static_cast<WebCore::DisplayList::PaintFrameForMedia&>(item), context);
+ if (m_remoteRenderingBackend.applyResourceItem(item, context))
return true;
- }
- return false;
+ return m_remoteRenderingBackend.applyMediaItem(item, context);
}
- void apply(WebCore::DisplayList::PaintFrameForMedia& item, WebCore::GraphicsContext& context)
- {
- auto process = m_remoteRenderingBackend.gpuConnectionToWebProcess();
- if (!process)
- return;
-
- auto playerProxy = process->remoteMediaPlayerManagerProxy().getProxy(item.identifier());
- if (!playerProxy)
- return;
-
- auto player = playerProxy->mediaPlayer();
- if (!player)
- return;
-
- context.paintFrameForMedia(*player, item.destination());
- }
-
RemoteRenderingBackend& m_remoteRenderingBackend;
};
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (269064 => 269065)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -72,6 +72,44 @@
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);
+ auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(drawItem.renderingResourceIdentifier());
+ if (!imageBuffer)
+ return false;
+
+ imageBuffer->draw(context, drawItem.destinationRect(), drawItem.source(), drawItem.options());
+ return true;
+ }
+
+ return false;
+}
+
+bool RemoteRenderingBackend::applyMediaItem(const DisplayList::Item& item, GraphicsContext& context)
+{
+ if (item.type() != WebCore::DisplayList::ItemType::PaintFrameForMedia)
+ return false;
+
+ auto& mediaItem = static_cast<const DisplayList::PaintFrameForMedia&>(item);
+
+ auto process = gpuConnectionToWebProcess();
+ if (!process)
+ return false;
+
+ auto playerProxy = process->remoteMediaPlayerManagerProxy().getProxy(mediaItem.identifier());
+ if (!playerProxy)
+ return false;
+
+ auto player = playerProxy->mediaPlayer();
+ if (!player)
+ return false;
+
+ context.paintFrameForMedia(*player, mediaItem.destination());
+ return true;
+}
+
void RemoteRenderingBackend::imageBufferBackendWasCreated(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, ImageBufferBackendHandle handle, RenderingResourceIdentifier renderingResourceIdentifier)
{
send(Messages::RemoteRenderingBackendProxy::ImageBufferBackendWasCreated(logicalSize, backendSize, resolutionScale, colorSpace, WTFMove(handle), renderingResourceIdentifier), m_renderingBackendIdentifier);
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (269064 => 269065)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -42,6 +42,7 @@
namespace WebCore {
namespace DisplayList {
class DisplayList;
+class Item;
}
class FloatSize;
enum class ColorSpace : uint8_t;
@@ -61,6 +62,10 @@
GPUConnectionToWebProcess* gpuConnectionToWebProcess() const;
+ // Rendering operations.
+ bool applyResourceItem(const WebCore::DisplayList::Item&, WebCore::GraphicsContext&);
+ bool applyMediaItem(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::RenderingResourceIdentifier);
void flushDisplayListWasCommitted(DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier);
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp (269064 => 269065)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -37,7 +37,7 @@
ASSERT_UNUSED(addResult, addResult.isNewEntry);
}
-WebCore::ImageBuffer* RemoteResourceCache::cachedImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier)
+ImageBuffer* RemoteResourceCache::cachedImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier)
{
return m_imageBuffers.get(renderingResourceIdentifier);
}
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (269064 => 269065)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -145,6 +145,7 @@
TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd, 1);
m_sentFlushIdentifier = m_remoteRenderingBackendProxy->flushDisplayListAndCommit(displayList, m_renderingResourceIdentifier);
+ m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_renderingResourceIdentifier);
displayList.clear();
}
@@ -155,8 +156,16 @@
TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd);
m_remoteRenderingBackendProxy->flushDisplayList(displayList, m_renderingResourceIdentifier);
+ m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_renderingResourceIdentifier);
}
+ bool lockRemoteImageBuffer(WebCore::ImageBuffer& imageBuffer) override
+ {
+ if (!m_remoteRenderingBackendProxy)
+ return false;
+ return m_remoteRenderingBackendProxy->remoteResourceCacheProxy().lockRemoteImageBufferForRemoteClient(imageBuffer, m_renderingResourceIdentifier);
+ }
+
void willAppendItem(const WebCore::DisplayList::Item&) override
{
constexpr size_t DisplayListBatchSize = 512;
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp (269064 => 269065)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp 2020-10-27 19:53:22 UTC (rev 269065)
@@ -53,9 +53,77 @@
{
bool found = m_imageBuffers.remove(renderingResourceIdentifier);
ASSERT_UNUSED(found, found);
- m_remoteRenderingBackendProxy.releaseRemoteResource(renderingResourceIdentifier);
+
+ // Tell the GPU process to remove this resource unless it's pending replaying back.
+ releaseRemoteResource(renderingResourceIdentifier);
}
+bool RemoteResourceCacheProxy::lockRemoteImageBufferForRemoteClient(ImageBuffer& imageBuffer, RenderingResourceIdentifier remoteClientIdentifier)
+{
+ if (!imageBuffer.renderingResourceIdentifier())
+ return false;
+
+ if (cachedImageBuffer(imageBuffer.renderingResourceIdentifier()) != &imageBuffer) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ lockRemoteResourceForRemoteClient(imageBuffer.renderingResourceIdentifier(), remoteClientIdentifier);
+ return true;
+}
+
+void RemoteResourceCacheProxy::lockRemoteResourceForRemoteClient(RenderingResourceIdentifier renderingResourceIdentifier, RenderingResourceIdentifier remoteClientIdentifier)
+{
+ // Add the "resource -> client" dependency in m_lockedRemoteResourceForRemoteClients.
+ auto& clients = m_lockedRemoteResourceForRemoteClients.ensure(renderingResourceIdentifier, [&] {
+ return RemoteClientsHashSet();
+ }).iterator->value;
+
+ clients.add(remoteClientIdentifier);
+}
+
+void RemoteResourceCacheProxy::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier)
+{
+ ASSERT(!m_pendingUnlockRemoteResourceForRemoteClients.contains(renderingResourceIdentifier));
+
+ // 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(renderingResourceIdentifier))
+ m_pendingUnlockRemoteResourceForRemoteClients.add(renderingResourceIdentifier, m_lockedRemoteResourceForRemoteClients.take(renderingResourceIdentifier));
+ else
+ m_remoteRenderingBackendProxy.releaseRemoteResource(renderingResourceIdentifier);
+}
+
+void RemoteResourceCacheProxy::unlockRemoteResourcesForRemoteClient(RenderingResourceIdentifier remoteClientIdentifier)
+{
+ auto removeRemoteClient = [&](RemoteResourceClientsHashMap& remoteResourceForRemoteClients, RenderingResourceIdentifier remoteClientIdentifier) {
+ Vector<RenderingResourceIdentifier> 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 renderingResourceIdentifier : removeRemoteClient(m_lockedRemoteResourceForRemoteClients, remoteClientIdentifier))
+ m_lockedRemoteResourceForRemoteClients.remove(renderingResourceIdentifier);
+
+ // Remove all the resource -> client dependencies from m_pendingUnlockRemoteResourceForRemoteClients.
+ for (auto renderingResourceIdentifier : removeRemoteClient(m_pendingUnlockRemoteResourceForRemoteClients, remoteClientIdentifier)) {
+ // Remove the unreferenced resources from m_remoteResourceClientsPendingReleaseHashMap.
+ m_pendingUnlockRemoteResourceForRemoteClients.remove(renderingResourceIdentifier);
+
+ // Tell the GPU process to remove this resource.
+ m_remoteRenderingBackendProxy.releaseRemoteResource(renderingResourceIdentifier);
+ }
+}
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h (269064 => 269065)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h 2020-10-27 19:40:15 UTC (rev 269064)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h 2020-10-27 19:53:22 UTC (rev 269065)
@@ -46,10 +46,20 @@
WebCore::ImageBuffer* cachedImageBuffer(WebCore::RenderingResourceIdentifier);
void releaseImageBuffer(WebCore::RenderingResourceIdentifier);
+ bool lockRemoteImageBufferForRemoteClient(WebCore::ImageBuffer&, WebCore::RenderingResourceIdentifier remoteClientIdentifier);
+ void unlockRemoteResourcesForRemoteClient(WebCore::RenderingResourceIdentifier remoteClientIdentifier);
+
private:
+ using RemoteClientsHashSet = HashSet<WebCore::RenderingResourceIdentifier>;
+ using RemoteResourceClientsHashMap = HashMap<WebCore::RenderingResourceIdentifier, RemoteClientsHashSet>;
using RemoteImageBufferProxyHashMap = HashMap<WebCore::RenderingResourceIdentifier, WebCore::ImageBuffer*>;
-
+
+ void lockRemoteResourceForRemoteClient(WebCore::RenderingResourceIdentifier, WebCore::RenderingResourceIdentifier remoteClientIdentifier);
+ void releaseRemoteResource(WebCore::RenderingResourceIdentifier);
+
RemoteImageBufferProxyHashMap m_imageBuffers;
+ RemoteResourceClientsHashMap m_lockedRemoteResourceForRemoteClients;
+ RemoteResourceClientsHashMap m_pendingUnlockRemoteResourceForRemoteClients;
RemoteRenderingBackendProxy& m_remoteRenderingBackendProxy;
};