Title: [273291] trunk
Revision
273291
Author
[email protected]
Date
2021-02-22 18:00:56 -0800 (Mon, 22 Feb 2021)

Log Message

[GPU Process] Implement the ClipToDrawingCommands item by using begin and end markers
https://bugs.webkit.org/show_bug.cgi?id=222230

Reviewed by Simon Fraser.

Source/WebCore:

Instead of encoding and decoding the clipping commands as a separate
DisplayList, the recorder will insert a "begin" and "end" markers before
and after the clipping commands.

When replaying the "begin" mark, the replayer will create a mask ImageBuffer
and force using its context for the following items.

When replaying the "end" mark, it will clip the original context to the
mask ImageBuffer.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::ClipToDrawingCommands::apply const): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::BeginClipToDrawingCommands::BeginClipToDrawingCommands):
(WebCore::DisplayList::BeginClipToDrawingCommands::colorSpace const):
(WebCore::DisplayList::EndClipToDrawingCommands::EndClipToDrawingCommands):
(WebCore::DisplayList::EndClipToDrawingCommands::destination const):
(WebCore::DisplayList::ClipToDrawingCommands::ClipToDrawingCommands): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::operator=): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::destination const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::colorSpace const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::drawingCommands const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::encode const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::decode): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::clipToDrawingCommands):
* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::Replayer::context const):
(WebCore::DisplayList::Replayer::applyItem):
* platform/graphics/displaylists/DisplayListReplayer.h:

Source/WebKit:

Replace the DisplayList item ClipToDrawingCommands by the pair items
BeginClipToDrawingCommands and EndClipToDrawingCommands.

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::decodeItem):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:

LayoutTests:

The text with gradient tests will be fixed by this change.

* gpu-process/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (273290 => 273291)


--- trunk/LayoutTests/ChangeLog	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/LayoutTests/ChangeLog	2021-02-23 02:00:56 UTC (rev 273291)
@@ -1,3 +1,14 @@
+2021-02-22  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process] Implement the ClipToDrawingCommands item by using begin and end markers
+        https://bugs.webkit.org/show_bug.cgi?id=222230
+
+        Reviewed by Simon Fraser.
+
+        The text with gradient tests will be fixed by this change.
+
+        * gpu-process/TestExpectations:
+
 2021-02-22  Sam Weinig  <[email protected]>
 
         HTMLModelElement needs a renderer

Modified: trunk/LayoutTests/gpu-process/TestExpectations (273290 => 273291)


--- trunk/LayoutTests/gpu-process/TestExpectations	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/LayoutTests/gpu-process/TestExpectations	2021-02-23 02:00:56 UTC (rev 273291)
@@ -6,7 +6,6 @@
 displaylists/canvas-display-list.html [ Failure ]
 
 # webkit.org/b/220389
-fast/canvas/2d.fillText.gradient.html [ Failure ]
 fast/canvas/canvas-arc-360-winding.html [ Failure ]
 fast/canvas/canvas-arc-connecting-line.html [ Failure ]
 fast/canvas/canvas-arc-zero-lineto.html [ Failure ]
@@ -55,19 +54,6 @@
 fast/repaint/canvas-object-fit.html [ Failure ]
 fast/repaint/canvas-putImageData.html [ Failure ]
 
-# webkit.org/b/220377
-fast/text/canvas-color-fonts/fill-gradient-COLR-2.html [ ImageOnlyFailure ]
-fast/text/canvas-color-fonts/stroke-gradient-COLR-2.html [ ImageOnlyFailure ]
-fast/text/canvas-color-fonts/stroke-gradient-COLR-3.html [ ImageOnlyFailure ]
-fast/text/canvas-color-fonts/stroke-gradient-COLR-4.html [ ImageOnlyFailure ]
-fast/text/canvas-color-fonts/stroke-gradient-COLR-5.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/fill-gradient-sbix-2.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/fill-gradient-sbix-3.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/fill-gradient-sbix-4.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/stroke-gradient-sbix-2.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/stroke-gradient-sbix-3.html [ ImageOnlyFailure ]
-http/tests/canvas/color-fonts/stroke-gradient-sbix-4.html [ ImageOnlyFailure ]
-
 # webkit.org/b/221694
 http/tests/media/clearkey/clear-key-hls-aes128.html [ Failure ]
 http/tests/media/clearkey/collect-webkit-media-session.html [ Crash ]

Modified: trunk/Source/WebCore/ChangeLog (273290 => 273291)


--- trunk/Source/WebCore/ChangeLog	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/ChangeLog	2021-02-23 02:00:56 UTC (rev 273291)
@@ -1,3 +1,53 @@
+2021-02-22  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process] Implement the ClipToDrawingCommands item by using begin and end markers
+        https://bugs.webkit.org/show_bug.cgi?id=222230
+
+        Reviewed by Simon Fraser.
+
+        Instead of encoding and decoding the clipping commands as a separate
+        DisplayList, the recorder will insert a "begin" and "end" markers before
+        and after the clipping commands. 
+
+        When replaying the "begin" mark, the replayer will create a mask ImageBuffer
+        and force using its context for the following items.
+
+        When replaying the "end" mark, it will clip the original context to the
+        mask ImageBuffer.
+
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::DisplayList::append):
+        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
+        (WebCore::DisplayList::ItemHandle::apply):
+        (WebCore::DisplayList::ItemHandle::destroy):
+        (WebCore::DisplayList::ItemHandle::safeCopy const):
+        * platform/graphics/displaylists/DisplayListItemType.cpp:
+        (WebCore::DisplayList::sizeOfItemInBytes):
+        (WebCore::DisplayList::isDrawingItem):
+        (WebCore::DisplayList::isInlineItem):
+        * platform/graphics/displaylists/DisplayListItemType.h:
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::operator<<):
+        (WebCore::DisplayList::ClipToDrawingCommands::apply const): Deleted.
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::BeginClipToDrawingCommands::BeginClipToDrawingCommands):
+        (WebCore::DisplayList::BeginClipToDrawingCommands::colorSpace const):
+        (WebCore::DisplayList::EndClipToDrawingCommands::EndClipToDrawingCommands):
+        (WebCore::DisplayList::EndClipToDrawingCommands::destination const):
+        (WebCore::DisplayList::ClipToDrawingCommands::ClipToDrawingCommands): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::operator=): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::destination const): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::colorSpace const): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::drawingCommands const): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::encode const): Deleted.
+        (WebCore::DisplayList::ClipToDrawingCommands::decode): Deleted.
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::clipToDrawingCommands):
+        * platform/graphics/displaylists/DisplayListReplayer.cpp:
+        (WebCore::DisplayList::Replayer::context const):
+        (WebCore::DisplayList::Replayer::applyItem):
+        * platform/graphics/displaylists/DisplayListReplayer.h:
+
 2021-02-22  Sam Weinig  <[email protected]>
 
         HTMLModelElement needs a renderer

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -233,10 +233,10 @@
         return append<ClipOutToPath>(item.get<ClipOutToPath>());
     case ItemType::ClipPath:
         return append<ClipPath>(item.get<ClipPath>());
-    case ItemType::ClipToDrawingCommands: {
-        ASSERT_NOT_REACHED();
-        return; // FIXME: Support the ability to clone display lists (this is currently only used for display list tracking).
-    }
+    case ItemType::BeginClipToDrawingCommands:
+        return append<BeginClipToDrawingCommands>(item.get<BeginClipToDrawingCommands>());
+    case ItemType::EndClipToDrawingCommands:
+        return append<EndClipToDrawingCommands>(item.get<EndClipToDrawingCommands>());
     case ItemType::DrawGlyphs:
         return append<DrawGlyphs>(item.get<DrawGlyphs>());
     case ItemType::DrawImageBuffer:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -132,10 +132,14 @@
         get<ClipPath>().apply(context);
         return;
     }
-    case ItemType::ClipToDrawingCommands: {
-        get<ClipToDrawingCommands>().apply(context);
+    case ItemType::BeginClipToDrawingCommands: {
+        ASSERT_NOT_REACHED();
         return;
     }
+    case ItemType::EndClipToDrawingCommands: {
+        ASSERT_NOT_REACHED();
+        return;
+    }
     case ItemType::DrawGlyphs:
         ASSERT_NOT_REACHED();
         return;
@@ -298,10 +302,6 @@
         get<ClipPath>().~ClipPath();
         return;
     }
-    case ItemType::ClipToDrawingCommands: {
-        get<ClipToDrawingCommands>().~ClipToDrawingCommands();
-        return;
-    }
     case ItemType::DrawFocusRingPath: {
         get<DrawFocusRingPath>().~DrawFocusRingPath();
         return;
@@ -376,6 +376,10 @@
         return;
     }
 #endif
+    case ItemType::BeginClipToDrawingCommands: {
+        static_assert(std::is_trivially_destructible<BeginClipToDrawingCommands>::value);
+        return;
+    }
     case ItemType::BeginTransparencyLayer: {
         static_assert(std::is_trivially_destructible<BeginTransparencyLayer>::value);
         return;
@@ -432,6 +436,10 @@
         static_assert(std::is_trivially_destructible<DrawRect>::value);
         return;
     }
+    case ItemType::EndClipToDrawingCommands: {
+        static_assert(std::is_trivially_destructible<EndClipToDrawingCommands>::value);
+        return;
+    }
     case ItemType::EndTransparencyLayer: {
         static_assert(std::is_trivially_destructible<EndTransparencyLayer>::value);
         return;
@@ -566,8 +574,6 @@
         return copyInto<ClipOutToPath>(*this, itemOffset);
     case ItemType::ClipPath:
         return copyInto<ClipPath>(*this, itemOffset);
-    case ItemType::ClipToDrawingCommands:
-        return copyInto<ClipToDrawingCommands>(*this, itemOffset);
     case ItemType::DrawFocusRingPath:
         return copyInto<DrawFocusRingPath>(*this, itemOffset);
     case ItemType::DrawFocusRingRects:
@@ -612,6 +618,8 @@
     case ItemType::ApplyStrokePattern:
         return copyInto<ApplyStrokePattern>(*this, itemOffset);
 #endif
+    case ItemType::BeginClipToDrawingCommands:
+        return copyInto<BeginClipToDrawingCommands>(*this, itemOffset);
     case ItemType::BeginTransparencyLayer:
         return copyInto<BeginTransparencyLayer>(*this, itemOffset);
     case ItemType::ClearRect:
@@ -634,6 +642,8 @@
         return copyInto<DrawLine>(*this, itemOffset);
     case ItemType::DrawRect:
         return copyInto<DrawRect>(*this, itemOffset);
+    case ItemType::EndClipToDrawingCommands:
+        return copyInto<EndClipToDrawingCommands>(*this, itemOffset);
     case ItemType::EndTransparencyLayer:
         return copyInto<EndTransparencyLayer>(*this, itemOffset);
     case ItemType::FillEllipse:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -78,8 +78,10 @@
         return sizeof(ClipOutToPath);
     case ItemType::ClipPath:
         return sizeof(ClipPath);
-    case ItemType::ClipToDrawingCommands:
-        return sizeof(ClipToDrawingCommands);
+    case ItemType::BeginClipToDrawingCommands:
+        return sizeof(BeginClipToDrawingCommands);
+    case ItemType::EndClipToDrawingCommands:
+        return sizeof(EndClipToDrawingCommands);
     case ItemType::DrawGlyphs:
         return sizeof(DrawGlyphs);
     case ItemType::DrawImageBuffer:
@@ -179,7 +181,8 @@
     case ItemType::ClipToImageBuffer:
     case ItemType::ClipOutToPath:
     case ItemType::ClipPath:
-    case ItemType::ClipToDrawingCommands:
+    case ItemType::BeginClipToDrawingCommands:
+    case ItemType::EndClipToDrawingCommands:
     case ItemType::ConcatenateCTM:
     case ItemType::FlushContext:
     case ItemType::MetaCommandChangeDestinationImageBuffer:
@@ -251,7 +254,6 @@
     switch (type) {
     case ItemType::ClipOutToPath:
     case ItemType::ClipPath:
-    case ItemType::ClipToDrawingCommands:
     case ItemType::DrawFocusRingPath:
     case ItemType::DrawFocusRingRects:
     case ItemType::DrawGlyphs:
@@ -279,6 +281,8 @@
     case ItemType::Clip:
     case ItemType::ClipOut:
     case ItemType::ClipToImageBuffer:
+    case ItemType::BeginClipToDrawingCommands:
+    case ItemType::EndClipToDrawingCommands:
     case ItemType::ConcatenateCTM:
     case ItemType::DrawDotsForDocumentMarker:
     case ItemType::DrawEllipse:

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h	2021-02-23 02:00:56 UTC (rev 273291)
@@ -51,7 +51,8 @@
     ClipToImageBuffer,
     ClipOutToPath,
     ClipPath,
-    ClipToDrawingCommands,
+    BeginClipToDrawingCommands,
+    EndClipToDrawingCommands,
     DrawGlyphs,
     DrawImageBuffer,
     DrawNativeImage,

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -347,18 +347,16 @@
     return ts;
 }
 
-void ClipToDrawingCommands::apply(GraphicsContext& context) const
+static TextStream& operator<<(TextStream& ts, const BeginClipToDrawingCommands& item)
 {
-    context.clipToDrawingCommands(m_destination, m_colorSpace, [&] (GraphicsContext& clippingContext) {
-        Replayer replayer { clippingContext, m_drawingCommands };
-        replayer.replay();
-    });
+    ts.dumpProperty("destination", item.destination());
+    ts.dumpProperty("color-space", item.colorSpace());
+    return ts;
 }
 
-static TextStream& operator<<(TextStream& ts, const ClipToDrawingCommands& item)
+static TextStream& operator<<(TextStream& ts, const EndClipToDrawingCommands& item)
 {
     ts.dumpProperty("destination", item.destination());
-    ts.dumpProperty("color-space", item.colorSpace());
     return ts;
 }
 
@@ -1035,7 +1033,8 @@
     case ItemType::ClipToImageBuffer: ts << "clip-to-image-buffer"; break;
     case ItemType::ClipOutToPath: ts << "clip-out-to-path"; break;
     case ItemType::ClipPath: ts << "clip-path"; break;
-    case ItemType::ClipToDrawingCommands: ts << "clip-to-image-buffer"; break;
+    case ItemType::BeginClipToDrawingCommands: ts << "begin-clip-to-drawing-commands:"; break;
+    case ItemType::EndClipToDrawingCommands: ts << "end-clip-to-drawing-commands"; break;
     case ItemType::DrawGlyphs: ts << "draw-glyphs"; break;
     case ItemType::DrawImageBuffer: ts << "draw-image-buffer"; break;
     case ItemType::DrawNativeImage: ts << "draw-native-image"; break;
@@ -1146,9 +1145,12 @@
     case ItemType::ClipPath:
         ts << item.get<ClipPath>();
         break;
-    case ItemType::ClipToDrawingCommands:
-        ts << item.get<ClipToDrawingCommands>();
+    case ItemType::BeginClipToDrawingCommands:
+        ts << item.get<BeginClipToDrawingCommands>();
         break;
+    case ItemType::EndClipToDrawingCommands:
+        ts << item.get<EndClipToDrawingCommands>();
+        break;
     case ItemType::DrawGlyphs:
         ts << item.get<DrawGlyphs>();
         break;

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2021-02-23 02:00:56 UTC (rev 273291)
@@ -893,74 +893,42 @@
     return {{ WTFMove(*path), *windRule }};
 }
 
-class ClipToDrawingCommands {
+class BeginClipToDrawingCommands {
 public:
-    static constexpr ItemType itemType = ItemType::ClipToDrawingCommands;
-    static constexpr bool isInlineItem = false;
+    static constexpr ItemType itemType = ItemType::BeginClipToDrawingCommands;
+    static constexpr bool isInlineItem = true;
     static constexpr bool isDrawingItem = false;
 
-    ClipToDrawingCommands(const FloatRect& destination, DestinationColorSpace colorSpace, DisplayList&& drawingCommands)
+    BeginClipToDrawingCommands(const FloatRect& destination, DestinationColorSpace colorSpace)
         : m_destination(destination)
         , m_colorSpace(colorSpace)
-        , m_drawingCommands(WTFMove(drawingCommands))
     {
     }
 
-    ClipToDrawingCommands(const ClipToDrawingCommands& other)
-        : m_destination(other.m_destination)
-        , m_colorSpace(other.m_colorSpace)
-    {
-        // FIXME: Copy m_drawingCommands.
-    }
-
-    ClipToDrawingCommands& operator=(const ClipToDrawingCommands& other)
-    {
-        m_destination = other.m_destination;
-        m_colorSpace = other.m_colorSpace;
-        // FIXME: Copy m_drawingCommands.
-        return *this;
-    }
-
     const FloatRect& destination() const { return m_destination; }
     DestinationColorSpace colorSpace() const { return m_colorSpace; }
-    const DisplayList& drawingCommands() const { return m_drawingCommands; }
 
-    template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static Optional<ClipToDrawingCommands> decode(Decoder&);
-
-    void apply(GraphicsContext&) const;
-
 private:
     FloatRect m_destination;
     DestinationColorSpace m_colorSpace;
-    DisplayList m_drawingCommands;
 };
 
-template<class Encoder>
-void ClipToDrawingCommands::encode(Encoder& encoder) const
-{
-    encoder << m_destination;
-    encoder << m_colorSpace;
-    // FIXME: Implement a way to encode in-memory display lists.
-}
+class EndClipToDrawingCommands {
+public:
+    static constexpr ItemType itemType = ItemType::EndClipToDrawingCommands;
+    static constexpr bool isInlineItem = true;
+    static constexpr bool isDrawingItem = false;
 
-template<class Decoder>
-Optional<ClipToDrawingCommands> ClipToDrawingCommands::decode(Decoder& decoder)
-{
-    Optional<FloatRect> destination;
-    decoder >> destination;
-    if (!destination)
-        return WTF::nullopt;
+    EndClipToDrawingCommands(const FloatRect& destination)
+        : m_destination(destination)
+    {
+    }
 
-    Optional<DestinationColorSpace> colorSpace;
-    decoder >> colorSpace;
-    if (!colorSpace)
-        return WTF::nullopt;
+    const FloatRect& destination() const { return m_destination; }
 
-    // FIXME: Implement a way to decode in-memory display lists.
-    DisplayList drawingCommands;
-    return {{ *destination, *colorSpace, WTFMove(drawingCommands) }};
-}
+private:
+    FloatRect m_destination;
+};
 
 class DrawGlyphs {
 public:
@@ -2345,7 +2313,8 @@
     WebCore::DisplayList::ItemType::ClipToImageBuffer,
     WebCore::DisplayList::ItemType::ClipOutToPath,
     WebCore::DisplayList::ItemType::ClipPath,
-    WebCore::DisplayList::ItemType::ClipToDrawingCommands,
+    WebCore::DisplayList::ItemType::BeginClipToDrawingCommands,
+    WebCore::DisplayList::ItemType::EndClipToDrawingCommands,
     WebCore::DisplayList::ItemType::DrawGlyphs,
     WebCore::DisplayList::ItemType::DrawImageBuffer,
     WebCore::DisplayList::ItemType::DrawNativeImage,

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -439,19 +439,9 @@
 
 void Recorder::clipToDrawingCommands(const FloatRect& destination, DestinationColorSpace colorSpace, Function<void(GraphicsContext&)>&& drawingFunction)
 {
-    // The initial CTM matches ImageBuffer's initial CTM.
-    AffineTransform transform = getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
-    FloatSize scaleFactor(transform.xScale(), transform.yScale());
-    auto scaledSize = expandedIntSize(destination.size() * scaleFactor);
-
-    AffineTransform initialCTM;
-    initialCTM.scale(1, -1);
-    initialCTM.translate(0, -scaledSize.height());
-    initialCTM.scale(scaledSize / destination.size());
-
-    auto recordingContext = makeUnique<DrawingContext>(destination.size(), initialCTM);
-    drawingFunction(recordingContext->context());
-    append<ClipToDrawingCommands>(destination, colorSpace, recordingContext->takeDisplayList());
+    append<BeginClipToDrawingCommands>(destination, colorSpace);
+    drawingFunction(graphicsContext());
+    append<EndClipToDrawingCommands>(destination);
 }
 
 bool Recorder::canPaintFrameForMedia(const MediaPlayer& player) const

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -46,6 +46,11 @@
 
 Replayer::~Replayer() = default;
 
+GraphicsContext& Replayer::context() const
+{
+    return m_maskImageBuffer ? m_maskImageBuffer->context() : m_context;
+}
+
 template<class T>
 inline static Optional<RenderingResourceIdentifier> applyImageBufferItem(GraphicsContext& context, const ImageBufferHashMap& imageBuffers, ItemHandle item)
 {
@@ -107,46 +112,65 @@
 
 std::pair<Optional<StopReplayReason>, Optional<RenderingResourceIdentifier>> Replayer::applyItem(ItemHandle item)
 {
-    if (m_delegate && m_delegate->apply(item, m_context))
+    if (m_delegate && m_delegate->apply(item, context()))
         return { WTF::nullopt, WTF::nullopt };
 
     if (item.is<DrawImageBuffer>()) {
-        if (auto missingCachedResourceIdentifier = applyImageBufferItem<DrawImageBuffer>(m_context, m_imageBuffers, item))
+        if (auto missingCachedResourceIdentifier = applyImageBufferItem<DrawImageBuffer>(context(), m_imageBuffers, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
     if (item.is<ClipToImageBuffer>()) {
-        if (auto missingCachedResourceIdentifier = applyImageBufferItem<ClipToImageBuffer>(m_context, m_imageBuffers, item))
+        if (auto missingCachedResourceIdentifier = applyImageBufferItem<ClipToImageBuffer>(context(), m_imageBuffers, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
     if (item.is<DrawNativeImage>()) {
-        if (auto missingCachedResourceIdentifier = applyNativeImageItem<DrawNativeImage>(m_context, m_nativeImages, item))
+        if (auto missingCachedResourceIdentifier = applyNativeImageItem<DrawNativeImage>(context(), m_nativeImages, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
     if (item.is<DrawGlyphs>()) {
-        if (auto missingCachedResourceIdentifier = applyFontItem<DrawGlyphs>(m_context, m_fonts, item))
+        if (auto missingCachedResourceIdentifier = applyFontItem<DrawGlyphs>(context(), m_fonts, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
     if (item.is<DrawPattern>()) {
-        if (auto missingCachedResourceIdentifier = applyNativeImageItem<DrawPattern>(m_context, m_nativeImages, item))
+        if (auto missingCachedResourceIdentifier = applyNativeImageItem<DrawPattern>(context(), m_nativeImages, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
     if (item.is<SetState>()) {
-        if (auto missingCachedResourceIdentifier = applySetStateItem(m_context, m_nativeImages, item))
+        if (auto missingCachedResourceIdentifier = applySetStateItem(context(), m_nativeImages, item))
             return { StopReplayReason::MissingCachedResource, WTFMove(missingCachedResourceIdentifier) };
         return { WTF::nullopt, WTF::nullopt };
     }
 
-    item.apply(m_context);
+    if (item.is<BeginClipToDrawingCommands>()) {
+        if (m_maskImageBuffer)
+            return { StopReplayReason::InvalidItem, WTF::nullopt };
+        auto& clipItem = item.get<BeginClipToDrawingCommands>();
+        m_maskImageBuffer = ImageBuffer::createCompatibleBuffer(clipItem.destination().size(), clipItem.colorSpace(), m_context);
+        if (!m_maskImageBuffer)
+            return { StopReplayReason::OutOfMemory, WTF::nullopt };
+        return { WTF::nullopt, WTF::nullopt };
+    }
+
+    if (item.is<EndClipToDrawingCommands>()) {
+        if (!m_maskImageBuffer)
+            return { StopReplayReason::InvalidItem, WTF::nullopt };
+        auto& clipItem = item.get<EndClipToDrawingCommands>();
+        m_context.clipToImageBuffer(*m_maskImageBuffer, clipItem.destination());
+        m_maskImageBuffer = nullptr;
+        return { WTF::nullopt, WTF::nullopt };
+    }
+
+    item.apply(context());
     return { WTF::nullopt, WTF::nullopt };
 }
 

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h (273290 => 273291)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h	2021-02-23 02:00:56 UTC (rev 273291)
@@ -42,7 +42,8 @@
     ReplayedAllItems,
     MissingCachedResource,
     ChangeDestinationImageBuffer,
-    InvalidItem
+    InvalidItem,
+    OutOfMemory
 };
 
 struct ReplayResult {
@@ -69,9 +70,11 @@
     };
     
 private:
+    GraphicsContext& context() const;
     std::pair<Optional<StopReplayReason>, Optional<RenderingResourceIdentifier>> applyItem(ItemHandle);
 
     GraphicsContext& m_context;
+    RefPtr<WebCore::ImageBuffer> m_maskImageBuffer;
     const DisplayList& m_displayList;
     const ImageBufferHashMap& m_imageBuffers;
     const NativeImageHashMap& m_nativeImages;

Modified: trunk/Source/WebKit/ChangeLog (273290 => 273291)


--- trunk/Source/WebKit/ChangeLog	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebKit/ChangeLog	2021-02-23 02:00:56 UTC (rev 273291)
@@ -1,3 +1,17 @@
+2021-02-22  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process] Implement the ClipToDrawingCommands item by using begin and end markers
+        https://bugs.webkit.org/show_bug.cgi?id=222230
+
+        Reviewed by Simon Fraser.
+
+        Replace the DisplayList item ClipToDrawingCommands by the pair items
+        BeginClipToDrawingCommands and EndClipToDrawingCommands.
+
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::decodeItem):
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
 2021-02-22  Eric Carlson  <[email protected]>
 
         UserMediaPermissionRequestManagerProxy may be released while computing capture device list

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (273290 => 273291)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-02-23 02:00:56 UTC (rev 273291)
@@ -201,6 +201,7 @@
 
         auto result = submit(*displayList, *destination);
         MESSAGE_CHECK_WITH_RETURN_VALUE(result.reasonForStopping != DisplayList::StopReplayReason::InvalidItem, nullptr, "Detected invalid display list item");
+        MESSAGE_CHECK_WITH_RETURN_VALUE(result.reasonForStopping != DisplayList::StopReplayReason::OutOfMemory, nullptr, "Cound not allocate memory");
 
         auto advanceResult = handle.advance(result.numberOfBytesRead);
         MESSAGE_CHECK_WITH_RETURN_VALUE(advanceResult, nullptr, "Failed to advance display list reader handle");
@@ -406,8 +407,6 @@
         return decodeAndCreate<DisplayList::ClipOutToPath>(data, length, handleLocation);
     case DisplayList::ItemType::ClipPath:
         return decodeAndCreate<DisplayList::ClipPath>(data, length, handleLocation);
-    case DisplayList::ItemType::ClipToDrawingCommands:
-        return decodeAndCreate<DisplayList::ClipToDrawingCommands>(data, length, handleLocation);
     case DisplayList::ItemType::DrawFocusRingPath:
         return decodeAndCreate<DisplayList::DrawFocusRingPath>(data, length, handleLocation);
     case DisplayList::ItemType::DrawFocusRingRects:
@@ -449,6 +448,8 @@
     case DisplayList::ItemType::Clip:
     case DisplayList::ItemType::ClipOut:
     case DisplayList::ItemType::ClipToImageBuffer:
+    case DisplayList::ItemType::BeginClipToDrawingCommands:
+    case DisplayList::ItemType::EndClipToDrawingCommands:
     case DisplayList::ItemType::ConcatenateCTM:
     case DisplayList::ItemType::DrawDotsForDocumentMarker:
     case DisplayList::ItemType::DrawEllipse:

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (273290 => 273291)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-02-23 01:43:27 UTC (rev 273290)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-02-23 02:00:56 UTC (rev 273291)
@@ -280,8 +280,6 @@
             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipOutToPath>(item.get<WebCore::DisplayList::ClipOutToPath>());
         case WebCore::DisplayList::ItemType::ClipPath:
             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipPath>(item.get<WebCore::DisplayList::ClipPath>());
-        case WebCore::DisplayList::ItemType::ClipToDrawingCommands:
-            return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::ClipToDrawingCommands>(item.get<WebCore::DisplayList::ClipToDrawingCommands>());
         case WebCore::DisplayList::ItemType::DrawFocusRingPath:
             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawFocusRingPath>(item.get<WebCore::DisplayList::DrawFocusRingPath>());
         case WebCore::DisplayList::ItemType::DrawFocusRingRects:
@@ -323,6 +321,8 @@
         case WebCore::DisplayList::ItemType::Clip:
         case WebCore::DisplayList::ItemType::ClipOut:
         case WebCore::DisplayList::ItemType::ClipToImageBuffer:
+        case WebCore::DisplayList::ItemType::BeginClipToDrawingCommands:
+        case WebCore::DisplayList::ItemType::EndClipToDrawingCommands:
         case WebCore::DisplayList::ItemType::ConcatenateCTM:
         case WebCore::DisplayList::ItemType::DrawDotsForDocumentMarker:
         case WebCore::DisplayList::ItemType::DrawEllipse:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to