Title: [258219] trunk/Source/WebCore
Revision
258219
Author
commit-qu...@webkit.org
Date
2020-03-10 10:52:08 -0700 (Tue, 10 Mar 2020)

Log Message

Remove the special DisplayList handling in CanvasRenderingContext2DBase
https://bugs.webkit.org/show_bug.cgi?id=208828

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2020-03-10
Reviewed by Myles C. Maxfield.

Remove DisplayListDrawingContext and use DisplayList::DrawingContext
instead. Remove 'tracksDisplayListReplay' since it is always 'false'.
Remove contextDisplayListMap() since items are added to it only if
'tracksDisplayListReplay' is true which never happens.

* html/CustomPaintCanvas.cpp:
(WebCore::CustomPaintCanvas::getContext):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
(WebCore::CanvasRenderingContext2DBase::paintRenderingResultsToCanvas):
(WebCore::CanvasRenderingContext2DBase::drawingContext const):
(WebCore::DisplayListDrawingContext::DisplayListDrawingContext): Deleted.
(WebCore::contextDisplayListMap): Deleted.
(WebCore::CanvasRenderingContext2DBase::setTracksDisplayListReplay): Deleted.
(WebCore::CanvasRenderingContext2DBase::displayListAsText const): Deleted.
(WebCore::CanvasRenderingContext2DBase::replayDisplayListAsText const): Deleted.
* html/canvas/CanvasRenderingContext2DBase.h:
(WebCore::CanvasRenderingContext2DBase::tracksDisplayListReplay const): Deleted.
* platform/graphics/displaylists/DisplayListDrawingContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258218 => 258219)


--- trunk/Source/WebCore/ChangeLog	2020-03-10 17:47:20 UTC (rev 258218)
+++ trunk/Source/WebCore/ChangeLog	2020-03-10 17:52:08 UTC (rev 258219)
@@ -1,3 +1,30 @@
+2020-03-10  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Remove the special DisplayList handling in CanvasRenderingContext2DBase
+        https://bugs.webkit.org/show_bug.cgi?id=208828
+
+        Reviewed by Myles C. Maxfield.
+
+        Remove DisplayListDrawingContext and use DisplayList::DrawingContext
+        instead. Remove 'tracksDisplayListReplay' since it is always 'false'.
+        Remove contextDisplayListMap() since items are added to it only if
+        'tracksDisplayListReplay' is true which never happens.
+
+        * html/CustomPaintCanvas.cpp:
+        (WebCore::CustomPaintCanvas::getContext):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
+        (WebCore::CanvasRenderingContext2DBase::paintRenderingResultsToCanvas):
+        (WebCore::CanvasRenderingContext2DBase::drawingContext const):
+        (WebCore::DisplayListDrawingContext::DisplayListDrawingContext): Deleted.
+        (WebCore::contextDisplayListMap): Deleted.
+        (WebCore::CanvasRenderingContext2DBase::setTracksDisplayListReplay): Deleted.
+        (WebCore::CanvasRenderingContext2DBase::displayListAsText const): Deleted.
+        (WebCore::CanvasRenderingContext2DBase::replayDisplayListAsText const): Deleted.
+        * html/canvas/CanvasRenderingContext2DBase.h:
+        (WebCore::CanvasRenderingContext2DBase::tracksDisplayListReplay const): Deleted.
+        * platform/graphics/displaylists/DisplayListDrawingContext.h:
+
 2020-03-10  Jer Noble  <jer.no...@apple.com>
 
         [MSE] Use CMSampleBufferGetOutputPresentationTimeStamp / CMSampleBufferGetOutputDuration for all presentation times and durations

Modified: trunk/Source/WebCore/html/CustomPaintCanvas.cpp (258218 => 258219)


--- trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2020-03-10 17:47:20 UTC (rev 258218)
+++ trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2020-03-10 17:52:08 UTC (rev 258219)
@@ -60,7 +60,6 @@
 
     m_context = PaintRenderingContext2D::create(*this);
     downcast<PaintRenderingContext2D>(*m_context).setUsesDisplayListDrawing(true);
-    downcast<PaintRenderingContext2D>(*m_context).setTracksDisplayListReplay(false);
 
     return { RefPtr<PaintRenderingContext2D> { &downcast<PaintRenderingContext2D>(*m_context) } };
 }

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (258218 => 258219)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2020-03-10 17:47:20 UTC (rev 258218)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2020-03-10 17:52:08 UTC (rev 258219)
@@ -42,6 +42,7 @@
 #include "CanvasPattern.h"
 #include "DOMMatrix.h"
 #include "DOMMatrix2DInit.h"
+#include "DisplayListDrawingContext.h"
 #include "DisplayListRecorder.h"
 #include "DisplayListReplayer.h"
 #include "FloatQuad.h"
@@ -87,33 +88,6 @@
 const char* const CanvasRenderingContext2DBase::DefaultFontFamily = "sans-serif";
 const char* const CanvasRenderingContext2DBase::DefaultFont = "10px sans-serif";
 
-struct DisplayListDrawingContext {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    GraphicsContext context;
-    DisplayList::DisplayList displayList;
-    
-    DisplayListDrawingContext(GraphicsContext& context, const FloatRect& clip)
-        : DisplayListDrawingContext(context.state(), clip)
-    {
-    }
-
-    DisplayListDrawingContext(const GraphicsContextState& state, const FloatRect& clip)
-        : context([&](GraphicsContext& displayListContext) {
-            return makeUnique<DisplayList::Recorder>(displayListContext, displayList, state, clip, AffineTransform());
-        })
-    {
-    }
-};
-
-typedef HashMap<const CanvasRenderingContext2DBase*, std::unique_ptr<DisplayList::DisplayList>> ContextDisplayListHashMap;
-
-static ContextDisplayListHashMap& contextDisplayListMap()
-{
-    static NeverDestroyed<ContextDisplayListHashMap> sharedHashMap;
-    return sharedHashMap;
-}
-
 class CanvasStrokeStyleApplier : public StrokeStyleApplier {
 public:
     CanvasStrokeStyleApplier(CanvasRenderingContext2DBase* canvasContext)
@@ -163,9 +137,6 @@
 #if ASSERT_ENABLED
     unwindStateStack();
 #endif
-
-    if (UNLIKELY(tracksDisplayListReplay()))
-        contextDisplayListMap().remove(this);
 }
 
 bool CanvasRenderingContext2DBase::isAccelerated() const
@@ -2065,31 +2036,6 @@
     canvasBase().didDraw(dirtyRect);
 }
 
-void CanvasRenderingContext2DBase::setTracksDisplayListReplay(bool tracksDisplayListReplay)
-{
-    if (tracksDisplayListReplay == m_tracksDisplayListReplay)
-        return;
-
-    m_tracksDisplayListReplay = tracksDisplayListReplay;
-    if (!m_tracksDisplayListReplay)
-        contextDisplayListMap().remove(this);
-}
-
-String CanvasRenderingContext2DBase::displayListAsText(DisplayList::AsTextFlags flags) const
-{
-    if (!m_recordingContext)
-        return { };
-    return m_recordingContext->displayList.asText(flags);
-}
-
-String CanvasRenderingContext2DBase::replayDisplayListAsText(DisplayList::AsTextFlags flags) const
-{
-    auto* displayList = contextDisplayListMap().get(this);
-    if (!displayList)
-        return { };
-    return displayList->asText(flags);
-}
-
 const Vector<CanvasRenderingContext2DBase::State, 1>& CanvasRenderingContext2DBase::stateStack()
 {
     realizeSaves();
@@ -2098,20 +2044,16 @@
 
 void CanvasRenderingContext2DBase::paintRenderingResultsToCanvas()
 {
-    if (UNLIKELY(m_usesDisplayListDrawing)) {
-        if (!m_recordingContext)
-            return;
+    if (!m_recordingContext)
+        return;
 
-        FloatRect clip(FloatPoint::zero(), canvasBase().size());
-        DisplayList::Replayer replayer(*canvasBase().drawingContext(), m_recordingContext->displayList);
+    ASSERT(m_usesDisplayListDrawing);
 
-        if (UNLIKELY(m_tracksDisplayListReplay)) {
-            auto replayList = replayer.replay(clip, m_tracksDisplayListReplay);
-            contextDisplayListMap().add(this, WTFMove(replayList));
-        } else
-            replayer.replay(clip);
-
-        m_recordingContext->displayList.clear();
+    auto& displayList = m_recordingContext->displayList();
+    if (displayList.itemCount()) {
+        DisplayList::Replayer replayer(*canvasBase().drawingContext(), displayList);
+        replayer.replay({ FloatPoint::zero(), canvasBase().size() });
+        displayList.clear();
     }
 }
 
@@ -2119,8 +2061,8 @@
 {
     if (UNLIKELY(m_usesDisplayListDrawing)) {
         if (!m_recordingContext)
-            m_recordingContext = makeUnique<DisplayListDrawingContext>(GraphicsContextState(), FloatRect(FloatPoint::zero(), canvasBase().size()));
-        return &m_recordingContext->context;
+            m_recordingContext = makeUnique<DisplayList::DrawingContext>(canvasBase().size());
+        return &m_recordingContext->context();
     }
 
     return canvasBase().drawingContext();

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h (258218 => 258219)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2020-03-10 17:47:20 UTC (rev 258218)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h	2020-03-10 17:52:08 UTC (rev 258219)
@@ -219,12 +219,6 @@
     bool usesDisplayListDrawing() const { return m_usesDisplayListDrawing; };
     void setUsesDisplayListDrawing(bool flag) { m_usesDisplayListDrawing = flag; };
 
-    bool tracksDisplayListReplay() const { return m_tracksDisplayListReplay; }
-    void setTracksDisplayListReplay(bool);
-
-    String displayListAsText(DisplayList::AsTextFlags) const;
-    String replayDisplayListAsText(DisplayList::AsTextFlags) const;
-
     using Direction = CanvasDirection;
 
     class FontProxy : public FontSelectorClient {
@@ -384,8 +378,7 @@
     unsigned m_unrealizedSaveCount { 0 };
     bool m_usesCSSCompatibilityParseMode;
     bool m_usesDisplayListDrawing { false };
-    bool m_tracksDisplayListReplay { false };
-    mutable std::unique_ptr<struct DisplayListDrawingContext> m_recordingContext;
+    mutable std::unique_ptr<DisplayList::DrawingContext> m_recordingContext;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h (258218 => 258219)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h	2020-03-10 17:47:20 UTC (rev 258218)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h	2020-03-10 17:52:08 UTC (rev 258219)
@@ -33,8 +33,9 @@
 namespace DisplayList {
 
 class DrawingContext {
+    WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, Recorder::Observer*);
+    WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, Recorder::Observer* = nullptr);
 
     GraphicsContext& context() const { return const_cast<DrawingContext&>(*this).m_context; }
     WEBCORE_EXPORT Recorder& recorder();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to