Misc display list and other cleanup
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2017 03:08:53 +0000 (03:08 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2017 03:08:53 +0000 (03:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179150

Reviewed by Tim Horton.

Source/WebCore:

A few functions in GraphicsContext would assert when using display lists, because they
had no recording clause. Fix them (ellipse drawing, and focus ring drawing).

Use #pragma once in more places.

Add system trace points for display list recording.

No behavior change for non-display list code.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::fillEllipse):
(WebCore::GraphicsContext::strokeEllipse):
* platform/graphics/PlatformLayer.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
* platform/graphics/ca/cocoa/WebSystemBackdropLayer.h:
* platform/graphics/ca/cocoa/WebTiledBackingLayer.h:
* platform/graphics/cg/GraphicsContextCG.h:
* platform/graphics/cocoa/GraphicsContextCocoa.mm:
(WebCore::GraphicsContext::drawFocusRing):
* platform/graphics/displaylists/DisplayList.h:
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::DrawFocusRingPath::create):
(WebCore::DisplayList::DrawFocusRingPath::width const):
(WebCore::DisplayList::DrawFocusRingPath::offset const):
(WebCore::DisplayList::DrawFocusRingPath::DrawFocusRingPath):
(WebCore::DisplayList::DrawFocusRingRects::create):
(WebCore::DisplayList::DrawFocusRingRects::width const):
(WebCore::DisplayList::DrawFocusRingRects::offset const):
(WebCore::DisplayList::DrawFocusRingRects::DrawFocusRingRects):
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::restore):
(WebCore::DisplayList::Recorder::drawFocusRing):
* platform/graphics/displaylists/DisplayListRecorder.h:
* platform/graphics/displaylists/DisplayListReplayer.h:
* platform/graphics/mac/WebLayer.h:

Source/WTF:

Add system trace points for display list recording.

* wtf/SystemTracing.h:

Tools:

Add system trace points for display list recording.

* Tracing/SystemTracePoints.plist:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224312 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/SystemTracing.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/PlatformLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/cocoa/WebSystemBackdropLayer.h
Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.h
Source/WebCore/platform/graphics/cg/GraphicsContextCG.h
Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
Source/WebCore/platform/graphics/displaylists/DisplayList.h
Source/WebCore/platform/graphics/displaylists/DisplayListItems.h
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h
Source/WebCore/platform/graphics/mac/WebLayer.h
Tools/ChangeLog
Tools/Tracing/SystemTracePoints.plist

index 9cafad3..71013f2 100644 (file)
@@ -1,3 +1,14 @@
+2017-11-01  Simon Fraser  <simon.fraser@apple.com>
+
+        Misc display list and other cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=179150
+
+        Reviewed by Tim Horton.
+
+        Add system trace points for display list recording.
+
+        * wtf/SystemTracing.h:
+
 2017-11-01  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Use LazyNeverDestroyed instead of DEFINE_GLOBAL
index 2856390..58cf552 100644 (file)
@@ -71,6 +71,8 @@ enum TracePointCode {
     MemoryPressureHandlerEnd,
     UpdateTouchRegionsStart,
     UpdateTouchRegionsEnd,
+    DisplayListRecordStart,
+    DisplayListRecordEnd,
 
     WebKitRange = 10000,
     WebHTMLViewPaintStart,
index eefdb86..1df2dce 100644 (file)
@@ -1,3 +1,47 @@
+2017-11-01  Simon Fraser  <simon.fraser@apple.com>
+
+        Misc display list and other cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=179150
+
+        Reviewed by Tim Horton.
+
+        A few functions in GraphicsContext would assert when using display lists, because they
+        had no recording clause. Fix them (ellipse drawing, and focus ring drawing).
+        
+        Use #pragma once in more places.
+
+        Add system trace points for display list recording.
+
+        No behavior change for non-display list code.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::fillEllipse):
+        (WebCore::GraphicsContext::strokeEllipse):
+        * platform/graphics/PlatformLayer.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+        * platform/graphics/ca/cocoa/WebSystemBackdropLayer.h:
+        * platform/graphics/ca/cocoa/WebTiledBackingLayer.h:
+        * platform/graphics/cg/GraphicsContextCG.h:
+        * platform/graphics/cocoa/GraphicsContextCocoa.mm:
+        (WebCore::GraphicsContext::drawFocusRing):
+        * platform/graphics/displaylists/DisplayList.h:
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::DrawFocusRingPath::create):
+        (WebCore::DisplayList::DrawFocusRingPath::width const):
+        (WebCore::DisplayList::DrawFocusRingPath::offset const):
+        (WebCore::DisplayList::DrawFocusRingPath::DrawFocusRingPath):
+        (WebCore::DisplayList::DrawFocusRingRects::create):
+        (WebCore::DisplayList::DrawFocusRingRects::width const):
+        (WebCore::DisplayList::DrawFocusRingRects::offset const):
+        (WebCore::DisplayList::DrawFocusRingRects::DrawFocusRingRects):
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::restore):
+        (WebCore::DisplayList::Recorder::drawFocusRing):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        * platform/graphics/displaylists/DisplayListReplayer.h:
+        * platform/graphics/mac/WebLayer.h:
+
 2017-11-01  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Fix compile errors in MediaPlayerPrivateAVFoundationCF.cpp
index 9587e67..436df54 100644 (file)
@@ -1045,11 +1045,21 @@ FloatSize GraphicsContext::scaleFactorForDrawing(const FloatRect& destRect, cons
 
 void GraphicsContext::fillEllipse(const FloatRect& ellipse)
 {
+    if (isRecording()) {
+        m_displayListRecorder->fillEllipse(ellipse);
+        return;
+    }
+
     platformFillEllipse(ellipse);
 }
 
 void GraphicsContext::strokeEllipse(const FloatRect& ellipse)
 {
+    if (isRecording()) {
+        m_displayListRecorder->strokeEllipse(ellipse);
+        return;
+    }
+
     platformStrokeEllipse(ellipse);
 }
 
index 29f9dec..10fcf14 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef PlatformLayer_h
-#define PlatformLayer_h
+#pragma once
 
 #if PLATFORM(COCOA)
 OBJC_CLASS CALayer;
@@ -45,4 +44,3 @@ typedef TextureMapperPlatformLayer PlatformLayer;
 typedef void* PlatformLayer;
 #endif
 
-#endif // PlatformLayer_h
index 7fdb8c1..ea93cc5 100644 (file)
@@ -1544,9 +1544,8 @@ void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, con
         client().didCommitChangesForLayer(this);
 
     if (usesDisplayListDrawing() && m_drawsContent && (!m_hasEverPainted || hadDirtyRects)) {
-#ifdef LOG_RECORDING_TIME
-        double startTime = currentTime();
-#endif
+        TraceScope tracingScope(DisplayListRecordStart, DisplayListRecordEnd);
+
         m_displayList = std::make_unique<DisplayList::DisplayList>();
         
         FloatRect initialClip(boundsOrigin(), size());
@@ -1555,11 +1554,6 @@ void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, con
         // The Recorder is large, so heap-allocate.
         std::unique_ptr<DisplayList::Recorder> recorder = std::make_unique<DisplayList::Recorder>(context, *m_displayList, initialClip, AffineTransform());
         paintGraphicsLayerContents(context, FloatRect(FloatPoint(), size()));
-
-#ifdef LOG_RECORDING_TIME
-        double duration = currentTime() - startTime;
-        WTFLogAlways("Recording took %.5fms", duration * 1000.0);
-#endif
     }
 }
 
index cdf6826..b868e0d 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebSystemBackdropLayer_h
-#define WebSystemBackdropLayer_h
+#pragma once
 
 #import <QuartzCore/QuartzCore.h>
 
@@ -37,4 +36,3 @@
 @interface WebDarkSystemBackdropLayer : WebSystemBackdropLayer
 @end
 
-#endif // WebSystemBackdropLayer_h
index 522ec54..9c8e34d 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef WebTiledBackingLayer_h
-#define WebTiledBackingLayer_h
+#pragma once
 
 #import <QuartzCore/QuartzCore.h>
 
@@ -51,4 +50,3 @@ class TiledBacking;
 
 @end
 
-#endif // WebTiledBackingLayer_h
index e6d31af..06b3d6e 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef GraphicsContextCG_h
-#define GraphicsContextCG_h
+#pragma once
 
 #include "GraphicsContext.h"
 
@@ -101,4 +100,3 @@ private:
 
 }
 
-#endif
index 330f656..3cfe4cc 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "GraphicsContext.h"
 
+#import "DisplayListRecorder.h"
 #import "GraphicsContextCG.h"
 #import "GraphicsContextPlatformPrivateCG.h"
 #import "IntRect.h"
@@ -112,12 +113,17 @@ static bool drawFocusRingToContextAtTime(CGContextRef context, CGPathRef focusRi
 }
 #endif // !PLATFORM(IOS)
 
-void GraphicsContext::drawFocusRing(const Path& path, float /* width */, float /* offset */, const Color&)
+void GraphicsContext::drawFocusRing(const Path& path, float width, float offset, const Color& color)
 {
 #if PLATFORM(MAC)
     if (paintingDisabled() || path.isNull())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawFocusRing(path, width, offset, color);
+        return;
+    }
+
     drawFocusRingToContext(platformContext(), path.platformPath());
 #else
     UNUSED_PARAM(path);
@@ -129,7 +135,10 @@ void GraphicsContext::drawFocusRing(const Path& path, double timeOffset, bool& n
 {
     if (paintingDisabled() || path.isNull())
         return;
-    
+
+    if (isRecording()) // FIXME: implement animated focus ring drawing.
+        return;
+
     needsRedraw = drawFocusRingToContextAtTime(platformContext(), path.platformPath(), timeOffset);
 }
 
@@ -138,6 +147,9 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, double timeO
     if (paintingDisabled())
         return;
 
+    if (isRecording()) // FIXME: implement animated focus ring drawing.
+        return;
+
     RetainPtr<CGMutablePathRef> focusRingPath = adoptCF(CGPathCreateMutable());
     for (const auto& rect : rects)
         CGPathAddRect(focusRingPath.get(), 0, CGRect(rect));
@@ -146,12 +158,17 @@ void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, double timeO
 }
 #endif
 
-void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float, float offset, const Color&)
+void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
 {
 #if !PLATFORM(IOS)
     if (paintingDisabled())
         return;
 
+    if (isRecording()) {
+        m_displayListRecorder->drawFocusRing(rects, width, offset, color);
+        return;
+    }
+
     RetainPtr<CGMutablePathRef> focusRingPath = adoptCF(CGPathCreateMutable());
     for (auto& rect : rects)
         CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rect, -offset, -offset));
index c08667b..d4437e3 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DisplayList_h
-#define DisplayList_h
+#pragma once
 
 #include "DisplayListItems.h"
 #include <wtf/FastMalloc.h>
@@ -111,4 +110,3 @@ WTF::TextStream& operator<<(WTF::TextStream&, const DisplayList::DisplayList&);
 
 using WebCore::DisplayList::DisplayList;
 
-#endif /* DisplayList_h */
index 2a03330..9f09910 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DisplayListItems_h
-#define DisplayListItems_h
+#pragma once
 
 #include "FloatPoint.h"
 #include "FloatRect.h"
@@ -904,18 +903,18 @@ private:
 
 class DrawFocusRingPath : public DrawingItem {
 public:
-    static Ref<DrawFocusRingPath> create(const Path& path, int width, int offset, const Color& color)
+    static Ref<DrawFocusRingPath> create(const Path& path, float width, float offset, const Color& color)
     {
         return adoptRef(*new DrawFocusRingPath(path, width, offset, color));
     }
 
     const Path& path() const { return m_path; }
-    int width() const { return m_width; }
-    int offset() const { return m_offset; }
+    float width() const { return m_width; }
+    float offset() const { return m_offset; }
     const Color& color() const { return m_color; }
 
 private:
-    DrawFocusRingPath(const Path& path, int width, int offset, const Color& color)
+    DrawFocusRingPath(const Path& path, float width, float offset, const Color& color)
         : DrawingItem(ItemType::DrawFocusRingPath)
         , m_path(path)
         , m_width(width)
@@ -929,25 +928,25 @@ private:
     std::optional<FloatRect> localBounds(const GraphicsContext&) const override;
 
     const Path m_path;
-    int m_width;
-    int m_offset;
+    float m_width;
+    float m_offset;
     Color m_color;
 };
 
 class DrawFocusRingRects : public DrawingItem {
 public:
-    static Ref<DrawFocusRingRects> create(const Vector<FloatRect>& rects, int width, int offset, const Color& color)
+    static Ref<DrawFocusRingRects> create(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
     {
         return adoptRef(*new DrawFocusRingRects(rects, width, offset, color));
     }
 
     const Vector<FloatRect> rects() const { return m_rects; }
-    int width() const { return m_width; }
-    int offset() const { return m_offset; }
+    float width() const { return m_width; }
+    float offset() const { return m_offset; }
     const Color& color() const { return m_color; }
 
 private:
-    DrawFocusRingRects(const Vector<FloatRect>& rects, int width, int offset, const Color& color)
+    DrawFocusRingRects(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
         : DrawingItem(ItemType::DrawFocusRingRects)
         , m_rects(rects)
         , m_width(width)
@@ -961,8 +960,8 @@ private:
     std::optional<FloatRect> localBounds(const GraphicsContext&) const override;
 
     Vector<FloatRect> m_rects;
-    int m_width;
-    int m_offset;
+    float m_width;
+    float m_offset;
     Color m_color;
 };
 
@@ -1387,4 +1386,3 @@ SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyFillPattern)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ApplyDeviceScaleFactor)
 SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(ClearShadow)
 
-#endif // DisplayListItems_h
index d51dba3..37bd41e 100644 (file)
@@ -148,10 +148,10 @@ void Recorder::restore()
 {
     if (!m_stateStack.size())
         return;
-    
+
     bool stateUsedForDrawing = currentState().wasUsedForDrawing;
     size_t saveIndex = currentState().saveItemIndex;
-    
+
     m_stateStack.removeLast();
     // Have to avoid eliding nested Save/Restore when a descendant state contains drawing items.
     currentState().wasUsedForDrawing |= stateUsedForDrawing;
@@ -163,7 +163,7 @@ void Recorder::restore()
     }
 
     appendItem(Restore::create());
-    
+
     if (saveIndex) {
         Save& saveItem = downcast<Save>(m_displayList.itemAt(saveIndex));
         saveItem.setRestoreIndex(m_displayList.itemCount() - 1);
@@ -241,13 +241,13 @@ void Recorder::drawPath(const Path& path)
     updateItemExtent(newItem);
 }
 
-void Recorder::drawFocusRing(const Path& path, int width, int offset, const Color& color)
+void Recorder::drawFocusRing(const Path& path, float width, float offset, const Color& color)
 {
     DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawFocusRingPath::create(path, width, offset, color)));
     updateItemExtent(newItem);
 }
 
-void Recorder::drawFocusRing(const Vector<FloatRect>& rects, int width, int offset, const Color& color)
+void Recorder::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
 {
     DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawFocusRingRects::create(rects, width, offset, color)));
     updateItemExtent(newItem);
index 95c626f..6a29023 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DisplayListRecorder_h
-#define DisplayListRecorder_h
+#pragma once
 
 #include "DisplayList.h"
 #include "GraphicsContext.h" // For InterpolationQuality.
@@ -97,8 +96,8 @@ public:
     void drawEllipse(const FloatRect&);
     void drawPath(const Path&);
 
-    void drawFocusRing(const Path&, int width, int offset, const Color&);
-    void drawFocusRing(const Vector<FloatRect>&, int width, int offset, const Color&);
+    void drawFocusRing(const Path&, float width, float offset, const Color&);
+    void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&);
 
     void save();
     void restore();
@@ -171,4 +170,3 @@ private:
 }
 }
 
-#endif // DisplayListRecorder_h
index 136c15b..fb383e2 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef DisplayListReplayer_h
-#define DisplayListReplayer_h
+#pragma once
 
 #include "DisplayList.h"
 #include <wtf/Noncopyable.h>
@@ -53,4 +52,3 @@ private:
 }
 }
 
-#endif // DisplayListReplayer_h
index 88688a5..d80cc8d 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef WebLayer_h
-#define WebLayer_h
+#pragma once
 
 #include <QuartzCore/QuartzCore.h>
 
@@ -39,4 +38,3 @@
 @end
 #endif
 
-#endif // WebLayer_h
index 4c19315..dd9f33e 100644 (file)
@@ -1,3 +1,14 @@
+2017-11-01  Simon Fraser  <simon.fraser@apple.com>
+
+        Misc display list and other cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=179150
+
+        Reviewed by Tim Horton.
+
+        Add system trace points for display list recording.
+
+        * Tracing/SystemTracePoints.plist:
+
 2017-11-01  Stephan Szabo  <stephan.szabo@sony.com>
 
         [Win] Detect Visual Studio 2017 location
index 22c666d..fdda840 100644 (file)
              </dict>
              <dict>
                  <key>Name</key>
+                 <string>Record display list</string>
+                 <key>Type</key>
+                 <string>Interval</string>
+                 <key>Component</key>
+                 <string>47</string>
+                 <key>CodeBegin</key>
+                 <string>5023</string>
+                 <key>CodeEnd</key>
+                 <string>5024</string>
+             </dict>
+             <dict>
+                 <key>Name</key>
                  <string>Paint WebHTMLView</string>
                  <key>Type</key>
                  <string>Interval</string>