Title: [268240] trunk/Source/WebCore
- Revision
- 268240
- Author
- wenson_hs...@apple.com
- Date
- 2020-10-08 18:17:46 -0700 (Thu, 08 Oct 2020)
Log Message
[MotionMark] Add a fast path for GraphicsContext::strokePath in the case where the path is a line
https://bugs.webkit.org/show_bug.cgi?id=217496
Reviewed by Tim Horton.
When running the Canvas Lines subtest with GPU process enabled, we currently suffer from increased memory usage
in the GPU process. Much of this increased memory usage is due to the allocation of approximately 35 million
`CGPathRef`s over the course of the subtest, which ends up dirtying a large number of pages; this also adds a
nontrivial amount of overhead due to creating and destroying these platform `CGPathRef`s.
We can mitigate most of this overhead in the GPU process by avoiding platform `CGPathRef` allocation entirely
when stroking simple line segments in `GraphicsContext::strokePath`. Rather than reifying `Path::m_path` and
then using `CGContextDrawPathDirect`, we can simply use `CGContextStrokeLineSegments` with a fixed array of
2 `CGPoint`s.
No change in behavior.
* platform/graphics/Path.h:
(WebCore::Path::inlineData const):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::strokePath):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (268239 => 268240)
--- trunk/Source/WebCore/ChangeLog 2020-10-09 00:48:35 UTC (rev 268239)
+++ trunk/Source/WebCore/ChangeLog 2020-10-09 01:17:46 UTC (rev 268240)
@@ -1,3 +1,27 @@
+2020-10-08 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [MotionMark] Add a fast path for GraphicsContext::strokePath in the case where the path is a line
+ https://bugs.webkit.org/show_bug.cgi?id=217496
+
+ Reviewed by Tim Horton.
+
+ When running the Canvas Lines subtest with GPU process enabled, we currently suffer from increased memory usage
+ in the GPU process. Much of this increased memory usage is due to the allocation of approximately 35 million
+ `CGPathRef`s over the course of the subtest, which ends up dirtying a large number of pages; this also adds a
+ nontrivial amount of overhead due to creating and destroying these platform `CGPathRef`s.
+
+ We can mitigate most of this overhead in the GPU process by avoiding platform `CGPathRef` allocation entirely
+ when stroking simple line segments in `GraphicsContext::strokePath`. Rather than reifying `Path::m_path` and
+ then using `CGContextDrawPathDirect`, we can simply use `CGContextStrokeLineSegments` with a fixed array of
+ 2 `CGPoint`s.
+
+ No change in behavior.
+
+ * platform/graphics/Path.h:
+ (WebCore::Path::inlineData const):
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::strokePath):
+
2020-10-08 James Darpinian <jdarpin...@chromium.org>
Support EXT_texture_compression_rgtc WebGL extension
Modified: trunk/Source/WebCore/platform/graphics/Path.h (268239 => 268240)
--- trunk/Source/WebCore/platform/graphics/Path.h 2020-10-09 00:48:35 UTC (rev 268239)
+++ trunk/Source/WebCore/platform/graphics/Path.h 2020-10-09 01:17:46 UTC (rev 268240)
@@ -233,9 +233,13 @@
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<Path> decode(Decoder&);
+#if ENABLE(INLINE_PATH_DATA)
+ template<typename DataType> const DataType& inlineData() const;
+ template<typename DataType> bool hasInlineData() const;
+#endif
+
private:
#if ENABLE(INLINE_PATH_DATA)
- template<typename DataType> bool hasInlineData() const;
bool hasAnyInlineData() const;
Optional<FloatRect> boundingRectFromInlineData() const;
#endif
@@ -413,6 +417,11 @@
return WTF::holds_alternative<DataType>(m_inlineData);
}
+template<typename DataType> inline const DataType& Path::inlineData() const
+{
+ return WTF::get<DataType>(m_inlineData);
+}
+
inline bool Path::hasAnyInlineData() const
{
return !hasInlineData<Monostate>();
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (268239 => 268240)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2020-10-09 00:48:35 UTC (rev 268239)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2020-10-09 01:17:46 UTC (rev 268240)
@@ -888,6 +888,14 @@
if (m_state.strokePattern)
applyStrokePattern();
+
+ if (path.hasInlineData<LineData>()) {
+ auto& lineData = path.inlineData<LineData>();
+ CGPoint points[2] { lineData.start, lineData.end };
+ CGContextStrokeLineSegments(context, points, 2);
+ return;
+ }
+
#if USE_DRAW_PATH_DIRECT
CGContextDrawPathDirect(context, kCGPathStroke, path.platformPath(), nullptr);
#else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes