Diff
Modified: trunk/Source/WebCore/ChangeLog (283847 => 283848)
--- trunk/Source/WebCore/ChangeLog 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/ChangeLog 2021-10-08 23:09:40 UTC (rev 283848)
@@ -1,3 +1,214 @@
+2021-10-08 Wenson Hsieh <[email protected]>
+
+ Split DisplayList::Recorder into an abstract base class and a concrete implementation
+ https://bugs.webkit.org/show_bug.cgi?id=231404
+
+ Reviewed by Myles Maxfield.
+
+ This patch splits the current code in the DisplayList::Recorder class into two classes: an abstract base class
+ with the existing name (DisplayList::Recorder), and a new concrete implementation of this virtual class,
+ DisplayList::RecorderImpl. See below for more details.
+
+ This refactoring will allow us to introduce a WebKit2-specific subclass of DisplayList::Recorder in a subsequent
+ patch, which is similar to the existing DisplayList::Recorder object, but will record its display list items by
+ sending them to the GPU Process through the IPC stream connection, rather than append them to an instance of
+ DisplayList.
+
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::displayListForTextRun const):
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+
+ Change various uses of DisplayList::Recorder to DisplayList::RecorderImpl.
+
+ (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+ * platform/graphics/displaylists/DisplayList.h:
+ * platform/graphics/displaylists/DisplayListDrawingContext.cpp:
+ (WebCore::DisplayList::DrawingContext::DrawingContext):
+ * platform/graphics/displaylists/DisplayListDrawingContext.h:
+ (WebCore::DisplayList::DrawingContext::DrawingContext):
+ (WebCore::DisplayList::DrawingContext::recorder):
+ * platform/graphics/displaylists/DisplayListImageBuffer.h:
+ (WebCore::DisplayList::ImageBuffer::ImageBuffer):
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+
+ The abstract Recorder now contains logic for mapping GraphicsContext method calls into calls to record
+ individual display list items. Note that while many GraphicsContext methods correspond directly to display list
+ items, some methods map to one or more display list items, such as setting state consisting only of inline POD
+ data or drawing simple paths. The base class also manages updating and maintaining the state stack (a list of
+ Recorder::ContextState) when modifying graphics context state.
+
+ Importantly, this means that the abstract Recorder class does not contain either a Recorder Delegate, nor does
+ it contain a DisplayList. Instead, the concrete subclass (DisplayList::RecorderImpl) now holds on to the local
+ DisplayList.
+
+ This also ensures that subclasses of DisplayList::Recorder only need to worry about "recording" display list
+ items given their constituent arguments, instead of directly implementing the individual GraphicsContext drawing
+ methods.
+
+ (WebCore::DisplayList::Recorder::Recorder):
+ (WebCore::DisplayList::Recorder::~Recorder):
+ (WebCore::DisplayList::Recorder::appendStateChangeItem):
+ (WebCore::DisplayList::Recorder::appendStateChangeItemIfNecessary):
+ (WebCore::DisplayList::Recorder::setLineCap):
+ (WebCore::DisplayList::Recorder::setLineDash):
+ (WebCore::DisplayList::Recorder::setLineJoin):
+ (WebCore::DisplayList::Recorder::setMiterLimit):
+ (WebCore::DisplayList::Recorder::drawGlyphsAndCacheFont):
+ (WebCore::DisplayList::Recorder::drawImageBuffer):
+ (WebCore::DisplayList::Recorder::drawNativeImage):
+ (WebCore::DisplayList::Recorder::drawPattern):
+ (WebCore::DisplayList::Recorder::save):
+ (WebCore::DisplayList::Recorder::restore):
+ (WebCore::DisplayList::Recorder::translate):
+ (WebCore::DisplayList::Recorder::rotate):
+ (WebCore::DisplayList::Recorder::scale):
+ (WebCore::DisplayList::Recorder::concatCTM):
+ (WebCore::DisplayList::Recorder::setCTM):
+ (WebCore::DisplayList::Recorder::beginTransparencyLayer):
+ (WebCore::DisplayList::Recorder::endTransparencyLayer):
+ (WebCore::DisplayList::Recorder::drawRect):
+ (WebCore::DisplayList::Recorder::drawLine):
+ (WebCore::DisplayList::Recorder::drawLinesForText):
+ (WebCore::DisplayList::Recorder::drawDotsForDocumentMarker):
+ (WebCore::DisplayList::Recorder::drawEllipse):
+ (WebCore::DisplayList::Recorder::drawPath):
+ (WebCore::DisplayList::Recorder::drawFocusRing):
+ (WebCore::DisplayList::Recorder::fillRect):
+ (WebCore::DisplayList::Recorder::fillRoundedRect):
+ (WebCore::DisplayList::Recorder::fillRectWithRoundedHole):
+ (WebCore::DisplayList::Recorder::fillPath):
+ (WebCore::DisplayList::Recorder::fillEllipse):
+ (WebCore::DisplayList::Recorder::strokeRect):
+ (WebCore::DisplayList::Recorder::strokePath):
+ (WebCore::DisplayList::Recorder::strokeEllipse):
+ (WebCore::DisplayList::Recorder::clearRect):
+ (WebCore::DisplayList::Recorder::applyStrokePattern):
+ (WebCore::DisplayList::Recorder::applyFillPattern):
+ (WebCore::DisplayList::Recorder::clip):
+ (WebCore::DisplayList::Recorder::clipOut):
+ (WebCore::DisplayList::Recorder::clipPath):
+ (WebCore::DisplayList::Recorder::clipToImageBuffer):
+ (WebCore::DisplayList::Recorder::clipToDrawingCommands):
+ (WebCore::DisplayList::Recorder::paintFrameForMedia):
+ (WebCore::DisplayList::Recorder::applyDeviceScaleFactor):
+ (WebCore::DisplayList::Recorder::getPixelBuffer): Deleted.
+ (WebCore::DisplayList::Recorder::putPixelBuffer): Deleted.
+ (WebCore::DisplayList::Recorder::recordNativeImageUse): Deleted.
+ (WebCore::DisplayList::Recorder::canAppendItemOfType const): Deleted.
+ (WebCore::DisplayList::Recorder::canDrawImageBuffer const): Deleted.
+ (WebCore::DisplayList::Recorder::renderingMode const): Deleted.
+ (WebCore::DisplayList::Recorder::extentFromLocalBounds const): Deleted.
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+ (WebCore::DisplayList::Recorder::recordDrawPattern):
+ (WebCore::DisplayList::Recorder::ContextState::ContextState):
+ (WebCore::DisplayList::Recorder::ContextState::cloneForSave const):
+ (WebCore::DisplayList::Recorder::ContextState::cloneForTransparencyLayer const):
+ (WebCore::DisplayList::Recorder::stateStack const):
+ (WebCore::DisplayList::Recorder::isEmpty const): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::~Delegate): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::canAppendItemOfType): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::recordNativeImageUse): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::isCachedImageBuffer const): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::recordFontUse): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::recordImageBufferUse): Deleted.
+ (WebCore::DisplayList::Recorder::Delegate::renderingMode const): Deleted.
+ (WebCore::DisplayList::Recorder::flushContext): Deleted.
+ (WebCore::DisplayList::Recorder::append): Deleted.
+ (WebCore::DisplayList::Recorder::itemNeedsState): Deleted.
+ * platform/graphics/displaylists/DisplayListRecorderImpl.cpp: Added.
+ (WebCore::DisplayList::RecorderImpl::RecorderImpl):
+ (WebCore::DisplayList::RecorderImpl::~RecorderImpl):
+ (WebCore::DisplayList::RecorderImpl::getPixelBuffer):
+ (WebCore::DisplayList::RecorderImpl::putPixelBuffer):
+ (WebCore::DisplayList::RecorderImpl::canAppendItemOfType const):
+ (WebCore::DisplayList::RecorderImpl::canDrawImageBuffer const):
+ (WebCore::DisplayList::RecorderImpl::renderingMode const):
+ (WebCore::DisplayList::RecorderImpl::createNestedContext):
+
+ Refactor the nested Recorder logic used for `Recorder::clipToDrawingCommands`, such that it's now a separate
+ override point. This allows subclasses to instantiate nested contexts of the same type, while keeping the main
+ logic in `clipToDrawingCommands` in the shared base class.
+
+ (WebCore::DisplayList::RecorderImpl::recordSave):
+ (WebCore::DisplayList::RecorderImpl::recordRestore):
+ (WebCore::DisplayList::RecorderImpl::recordTranslate):
+ (WebCore::DisplayList::RecorderImpl::recordRotate):
+ (WebCore::DisplayList::RecorderImpl::recordScale):
+ (WebCore::DisplayList::RecorderImpl::recordSetCTM):
+ (WebCore::DisplayList::RecorderImpl::recordConcatenateCTM):
+ (WebCore::DisplayList::RecorderImpl::recordSetInlineFillColor):
+ (WebCore::DisplayList::RecorderImpl::recordSetInlineStrokeColor):
+ (WebCore::DisplayList::RecorderImpl::recordSetStrokeThickness):
+ (WebCore::DisplayList::RecorderImpl::recordSetState):
+ (WebCore::DisplayList::RecorderImpl::recordSetLineCap):
+ (WebCore::DisplayList::RecorderImpl::recordSetLineDash):
+ (WebCore::DisplayList::RecorderImpl::recordSetLineJoin):
+ (WebCore::DisplayList::RecorderImpl::recordSetMiterLimit):
+ (WebCore::DisplayList::RecorderImpl::recordClearShadow):
+ (WebCore::DisplayList::RecorderImpl::recordClip):
+ (WebCore::DisplayList::RecorderImpl::recordClipOut):
+ (WebCore::DisplayList::RecorderImpl::recordClipToImageBuffer):
+ (WebCore::DisplayList::RecorderImpl::recordClipOutToPath):
+ (WebCore::DisplayList::RecorderImpl::recordClipPath):
+ (WebCore::DisplayList::RecorderImpl::recordBeginClipToDrawingCommands):
+ (WebCore::DisplayList::RecorderImpl::recordEndClipToDrawingCommands):
+ (WebCore::DisplayList::RecorderImpl::recordDrawGlyphs):
+ (WebCore::DisplayList::RecorderImpl::recordDrawImageBuffer):
+ (WebCore::DisplayList::RecorderImpl::recordDrawNativeImage):
+ (WebCore::DisplayList::RecorderImpl::recordDrawPattern):
+ (WebCore::DisplayList::RecorderImpl::recordBeginTransparencyLayer):
+ (WebCore::DisplayList::RecorderImpl::recordEndTransparencyLayer):
+ (WebCore::DisplayList::RecorderImpl::recordDrawRect):
+ (WebCore::DisplayList::RecorderImpl::recordDrawLine):
+ (WebCore::DisplayList::RecorderImpl::recordDrawLinesForText):
+ (WebCore::DisplayList::RecorderImpl::recordDrawDotsForDocumentMarker):
+ (WebCore::DisplayList::RecorderImpl::recordDrawEllipse):
+ (WebCore::DisplayList::RecorderImpl::recordDrawPath):
+ (WebCore::DisplayList::RecorderImpl::recordDrawFocusRingPath):
+ (WebCore::DisplayList::RecorderImpl::recordDrawFocusRingRects):
+ (WebCore::DisplayList::RecorderImpl::recordFillRect):
+ (WebCore::DisplayList::RecorderImpl::recordFillRectWithColor):
+ (WebCore::DisplayList::RecorderImpl::recordFillRectWithGradient):
+ (WebCore::DisplayList::RecorderImpl::recordFillCompositedRect):
+ (WebCore::DisplayList::RecorderImpl::recordFillRoundedRect):
+ (WebCore::DisplayList::RecorderImpl::recordFillRectWithRoundedHole):
+ (WebCore::DisplayList::RecorderImpl::recordFillLine):
+ (WebCore::DisplayList::RecorderImpl::recordFillArc):
+ (WebCore::DisplayList::RecorderImpl::recordFillQuadCurve):
+ (WebCore::DisplayList::RecorderImpl::recordFillBezierCurve):
+ (WebCore::DisplayList::RecorderImpl::recordFillPath):
+ (WebCore::DisplayList::RecorderImpl::recordFillEllipse):
+ (WebCore::DisplayList::RecorderImpl::recordGetPixelBuffer):
+ (WebCore::DisplayList::RecorderImpl::recordPutPixelBuffer):
+ (WebCore::DisplayList::RecorderImpl::recordPaintFrameForMedia):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeRect):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeLine):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeArc):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeQuadCurve):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeBezierCurve):
+ (WebCore::DisplayList::RecorderImpl::recordStrokePath):
+ (WebCore::DisplayList::RecorderImpl::recordStrokeEllipse):
+ (WebCore::DisplayList::RecorderImpl::recordClearRect):
+ (WebCore::DisplayList::RecorderImpl::recordApplyStrokePattern):
+ (WebCore::DisplayList::RecorderImpl::recordApplyFillPattern):
+ (WebCore::DisplayList::RecorderImpl::recordApplyDeviceScaleFactor):
+ (WebCore::DisplayList::RecorderImpl::recordResourceUse):
+ (WebCore::DisplayList::RecorderImpl::extentFromLocalBounds const):
+ * platform/graphics/displaylists/DisplayListRecorderImpl.h: Added.
+ (WebCore::DisplayList::RecorderImpl::isEmpty const):
+ (WebCore::DisplayList::RecorderImpl::Delegate::~Delegate):
+ (WebCore::DisplayList::RecorderImpl::Delegate::canAppendItemOfType):
+ (WebCore::DisplayList::RecorderImpl::Delegate::recordNativeImageUse):
+ (WebCore::DisplayList::RecorderImpl::Delegate::isCachedImageBuffer const):
+ (WebCore::DisplayList::RecorderImpl::Delegate::recordFontUse):
+ (WebCore::DisplayList::RecorderImpl::Delegate::recordImageBufferUse):
+ (WebCore::DisplayList::RecorderImpl::Delegate::renderingMode const):
+ (WebCore::DisplayList::RecorderImpl::recordDrawPattern):
+ (WebCore::DisplayList::RecorderImpl::append):
+
2021-10-08 Alan Bujtas <[email protected]>
ASSERTION FAILED: m_collapsibleLogicalWidth <= m_logicalWidth in WebCore::Layout::InlineContentBreaker::ContinuousContent::append
Modified: trunk/Source/WebCore/Headers.cmake (283847 => 283848)
--- trunk/Source/WebCore/Headers.cmake 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/Headers.cmake 2021-10-08 23:09:40 UTC (rev 283848)
@@ -1399,6 +1399,7 @@
platform/graphics/displaylists/DisplayListItems.h
platform/graphics/displaylists/DisplayListIterator.h
platform/graphics/displaylists/DisplayListRecorder.h
+ platform/graphics/displaylists/DisplayListRecorderImpl.h
platform/graphics/displaylists/DisplayListReplayer.h
platform/graphics/displaylists/InMemoryDisplayList.h
Modified: trunk/Source/WebCore/Sources.txt (283847 => 283848)
--- trunk/Source/WebCore/Sources.txt 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/Sources.txt 2021-10-08 23:09:40 UTC (rev 283848)
@@ -2031,6 +2031,7 @@
platform/graphics/displaylists/DisplayListItemType.cpp
platform/graphics/displaylists/DisplayListIterator.cpp
platform/graphics/displaylists/DisplayListRecorder.cpp
+platform/graphics/displaylists/DisplayListRecorderImpl.cpp
platform/graphics/displaylists/DisplayListReplayer.cpp
platform/graphics/displaylists/InMemoryDisplayList.cpp
platform/graphics/filters/DistantLightSource.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (283847 => 283848)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-08 23:09:40 UTC (rev 283848)
@@ -374,7 +374,7 @@
0FE5806419327A6200DE32EB /* ScrollingTreeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5806219327A6200DE32EB /* ScrollingTreeMac.h */; };
0FE5FBD31C3DD51E0007A2CA /* DisplayList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5FBCB1C3DD51E0007A2CA /* DisplayList.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FE5FBD51C3DD51E0007A2CA /* DisplayListItems.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5FBCD1C3DD51E0007A2CA /* DisplayListItems.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0FE5FBD71C3DD51E0007A2CA /* DisplayListRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorder.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0FE5FBD71C3DD51E0007A2CA /* DisplayListRecorderImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorderImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FE5FBD91C3DD51E0007A2CA /* DisplayListReplayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FE71406142170B800DB33BA /* ScrollbarThemeMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE71404142170B800DB33BA /* ScrollbarThemeMock.h */; };
0FEA3E7B191B2FC5000F1B55 /* ScrollingStateFrameScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEA3E79191B2FC5000F1B55 /* ScrollingStateFrameScrollingNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5393,6 +5393,7 @@
F420F00A25E47791009251EF /* PointerEventTypeNames.h in Headers */ = {isa = PBXBuildFile; fileRef = F420F00825E47791009251EF /* PointerEventTypeNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
F429261825264D4400007898 /* MediaPlayerIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = F429261725264D4400007898 /* MediaPlayerIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
F42994FA270CFE480032298B /* GraphicsContextFlushIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = F42994F9270CFE480032298B /* GraphicsContextFlushIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F429950F270E75000032298B /* DisplayListRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = F429950D270E75000032298B /* DisplayListRecorder.h */; settings = {ATTRIBUTES = (Private, ); }; };
F433E9031DBBDBA200EF0D14 /* StaticPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
F4377D572551C9C60080ABFE /* DisplayListItemType.h in Headers */ = {isa = PBXBuildFile; fileRef = F4377D552551C9C60080ABFE /* DisplayListItemType.h */; settings = {ATTRIBUTES = (Private, ); }; };
F440E77A233D94D70063F9AB /* NavigatorClipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F440E76F233D94D30063F9AB /* NavigatorClipboard.h */; };
@@ -6402,8 +6403,8 @@
0FE5FBCB1C3DD51E0007A2CA /* DisplayList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayList.h; sourceTree = "<group>"; };
0FE5FBCC1C3DD51E0007A2CA /* DisplayListItems.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListItems.cpp; sourceTree = "<group>"; };
0FE5FBCD1C3DD51E0007A2CA /* DisplayListItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListItems.h; sourceTree = "<group>"; };
- 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListRecorder.cpp; sourceTree = "<group>"; };
- 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListRecorder.h; sourceTree = "<group>"; };
+ 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorderImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListRecorderImpl.cpp; sourceTree = "<group>"; };
+ 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorderImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListRecorderImpl.h; sourceTree = "<group>"; };
0FE5FBD01C3DD51E0007A2CA /* DisplayListReplayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListReplayer.cpp; sourceTree = "<group>"; };
0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayListReplayer.h; sourceTree = "<group>"; };
0FE6C76B1FBFB7A60025C053 /* ColorUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColorUtilities.cpp; sourceTree = "<group>"; };
@@ -16800,6 +16801,8 @@
F422B8B6253F7065004E77E8 /* DisplayListItemBuffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListItemBuffer.cpp; sourceTree = "<group>"; };
F429261725264D4400007898 /* MediaPlayerIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaPlayerIdentifier.h; sourceTree = "<group>"; };
F42994F9270CFE480032298B /* GraphicsContextFlushIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextFlushIdentifier.h; sourceTree = "<group>"; };
+ F429950D270E75000032298B /* DisplayListRecorder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListRecorder.h; sourceTree = "<group>"; };
+ F429950E270E75000032298B /* DisplayListRecorder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListRecorder.cpp; sourceTree = "<group>"; };
F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributeChangesCocoa.mm; sourceTree = "<group>"; };
F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticPasteboard.h; sourceTree = "<group>"; };
F433E9041DBBDBC200EF0D14 /* StaticPasteboard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StaticPasteboard.cpp; sourceTree = "<group>"; };
@@ -18203,8 +18206,10 @@
F4377D552551C9C60080ABFE /* DisplayListItemType.h */,
1CE8D12B2618616400FC3AEF /* DisplayListIterator.cpp */,
1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */,
- 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorder.cpp */,
- 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorder.h */,
+ F429950E270E75000032298B /* DisplayListRecorder.cpp */,
+ F429950D270E75000032298B /* DisplayListRecorder.h */,
+ 0FE5FBCE1C3DD51E0007A2CA /* DisplayListRecorderImpl.cpp */,
+ 0FE5FBCF1C3DD51E0007A2CA /* DisplayListRecorderImpl.h */,
0FE5FBD01C3DD51E0007A2CA /* DisplayListReplayer.cpp */,
0FE5FBD11C3DD51E0007A2CA /* DisplayListReplayer.h */,
1CE8863E26105A5F000C816C /* InMemoryDisplayList.cpp */,
@@ -32358,7 +32363,8 @@
0FE5FBD51C3DD51E0007A2CA /* DisplayListItems.h in Headers */,
F4377D572551C9C60080ABFE /* DisplayListItemType.h in Headers */,
1CE8D12E261861C400FC3AEF /* DisplayListIterator.h in Headers */,
- 0FE5FBD71C3DD51E0007A2CA /* DisplayListRecorder.h in Headers */,
+ F429950F270E75000032298B /* DisplayListRecorder.h in Headers */,
+ 0FE5FBD71C3DD51E0007A2CA /* DisplayListRecorderImpl.h in Headers */,
0FE5FBD91C3DD51E0007A2CA /* DisplayListReplayer.h in Headers */,
49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */,
2D29ECC6192ECC8300984B78 /* DisplayRefreshMonitorClient.h in Headers */,
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -26,7 +26,7 @@
#include "CharacterProperties.h"
#include "ComplexTextController.h"
-#include "DisplayListRecorder.h"
+#include "DisplayListRecorderImpl.h"
#include "FloatRect.h"
#include "FontCache.h"
#include "GlyphBuffer.h"
@@ -213,7 +213,7 @@
return nullptr;
std::unique_ptr<DisplayList::InMemoryDisplayList> displayList = makeUnique<DisplayList::InMemoryDisplayList>();
- DisplayList::Recorder recordingContext(*displayList, context.state(), FloatRect(), AffineTransform(), nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction::DontDeconstruct);
+ DisplayList::RecorderImpl recordingContext(*displayList, context.state(), FloatRect(), AffineTransform(), nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction::DontDeconstruct);
FloatPoint startPoint = toFloatPoint(WebCore::size(glyphBuffer.initialAdvance()));
drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction);
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -29,7 +29,7 @@
#if USE(CA)
#include "Animation.h"
-#include "DisplayListRecorder.h"
+#include "DisplayListRecorderImpl.h"
#include "DisplayListReplayer.h"
#include "FloatConversion.h"
#include "FloatRect.h"
@@ -1804,7 +1804,7 @@
FloatRect initialClip(boundsOrigin(), size());
- DisplayList::Recorder context(*m_displayList, GraphicsContextState(), initialClip, AffineTransform());
+ DisplayList::RecorderImpl context(*m_displayList, GraphicsContextState(), initialClip, AffineTransform());
paintGraphicsLayerContents(context, FloatRect(FloatPoint(), size()));
}
}
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -54,7 +54,7 @@
class DisplayList {
WTF_MAKE_NONCOPYABLE(DisplayList); WTF_MAKE_FAST_ALLOCATED;
- friend class Recorder;
+ friend class RecorderImpl;
friend class Replayer;
public:
WEBCORE_EXPORT DisplayList();
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -27,13 +27,13 @@
#include "DisplayListDrawingContext.h"
#include "AffineTransform.h"
-#include "DisplayListRecorder.h"
+#include "DisplayListRecorderImpl.h"
#include "DisplayListReplayer.h"
namespace WebCore {
namespace DisplayList {
-DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, Recorder::Delegate* delegate)
+DrawingContext::DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM, RecorderImpl::Delegate* delegate)
: m_context(m_displayList, GraphicsContextState(), FloatRect({ }, logicalSize), initialCTM, delegate)
{
}
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListDrawingContext.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -26,7 +26,7 @@
#pragma once
#include "DisplayList.h"
-#include "DisplayListRecorder.h"
+#include "DisplayListRecorderImpl.h"
#include "GraphicsContext.h"
namespace WebCore {
@@ -37,10 +37,10 @@
class DrawingContext {
WTF_MAKE_FAST_ALLOCATED;
public:
- WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM = { }, Recorder::Delegate* = nullptr);
+ WEBCORE_EXPORT DrawingContext(const FloatSize& logicalSize, const AffineTransform& initialCTM = { }, RecorderImpl::Delegate* = nullptr);
GraphicsContext& context() const { return const_cast<DrawingContext&>(*this).m_context; }
- Recorder& recorder() { return m_context; };
+ RecorderImpl& recorder() { return m_context; };
DisplayList takeDisplayList() { return std::exchange(m_displayList, { }); }
DisplayList& displayList() { return m_displayList; }
const DisplayList& displayList() const { return m_displayList; }
@@ -50,7 +50,7 @@
WEBCORE_EXPORT void replayDisplayList(GraphicsContext&);
protected:
- Recorder m_context;
+ RecorderImpl m_context;
DisplayList m_displayList;
std::unique_ptr<InMemoryDisplayList> m_replayedDisplayList;
bool m_tracksDisplayListReplay { false };
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListImageBuffer.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -59,7 +59,7 @@
m_drawingContext.displayList().setItemBufferReadingClient(m_readingClient.get());
}
- ImageBuffer(const ImageBufferBackend::Parameters& parameters, Recorder::Delegate* delegate = nullptr)
+ ImageBuffer(const ImageBufferBackend::Parameters& parameters, RecorderImpl::Delegate* delegate = nullptr)
: BaseConcreteImageBuffer(parameters)
, m_drawingContext(logicalSize(), baseTransform(), delegate)
, m_writingClient(WTF::makeUnique<InMemoryDisplayList::WritingClient>())
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -40,21 +40,14 @@
namespace WebCore {
namespace DisplayList {
-Recorder::Recorder(DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, Delegate* delegate, DrawGlyphsRecorder::DrawGlyphsDeconstruction drawGlyphsDeconstruction)
- : m_displayList(displayList)
- , m_delegate(delegate)
- , m_isNested(false)
- , m_drawGlyphsRecorder(*this, drawGlyphsDeconstruction)
+Recorder::Recorder(const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, DrawGlyphsRecorder::DrawGlyphsDeconstruction drawGlyphsDeconstruction)
+ : m_drawGlyphsRecorder(*this, drawGlyphsDeconstruction)
{
- LOG_WITH_STREAM(DisplayLists, stream << "\nRecording with clip " << initialClip);
m_stateStack.append({ state, initialCTM, initialClip });
}
Recorder::Recorder(Recorder& parent, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM)
- : m_displayList(parent.m_displayList)
- , m_delegate(parent.m_delegate)
- , m_isNested(true)
- , m_drawGlyphsRecorder(*this, parent.m_drawGlyphsRecorder.drawGlyphsDeconstruction())
+ : m_drawGlyphsRecorder(*this, parent.m_drawGlyphsRecorder.drawGlyphsDeconstruction())
{
m_stateStack.append({ state, initialCTM, initialClip });
}
@@ -62,20 +55,8 @@
Recorder::~Recorder()
{
ASSERT(m_stateStack.size() == 1); // If this fires, it indicates mismatched save/restore.
- if (!m_isNested)
- LOG(DisplayLists, "Recorded display list:\n%s", m_displayList.description().data());
}
-void Recorder::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect)
-{
- append<GetPixelBuffer>(outputFormat, sourceRect);
-}
-
-void Recorder::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat)
-{
- append<PutPixelBuffer>(pixelBuffer, srcRect, destPoint, destFormat);
-}
-
static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& changes, GraphicsContextState::StateChangeFlags changeFlags)
{
static constexpr GraphicsContextState::StateChangeFlags inlineStateChangeFlags {
@@ -96,41 +77,32 @@
return true;
}
-void Recorder::recordNativeImageUse(NativeImage& image)
-{
- if (m_delegate)
- m_delegate->recordNativeImageUse(image);
- m_displayList.cacheNativeImage(image);
-}
-
void Recorder::appendStateChangeItem(const GraphicsContextStateChange& changes, GraphicsContextState::StateChangeFlags changeFlags)
{
if (!containsOnlyInlineStateChanges(changes, changeFlags)) {
if (auto pattern = changes.m_state.strokePattern)
- recordNativeImageUse(pattern->tileImage());
+ recordResourceUse(pattern->tileImage());
if (auto pattern = changes.m_state.fillPattern)
- recordNativeImageUse(pattern->tileImage());
- append<SetState>(changes.m_state, changeFlags);
+ recordResourceUse(pattern->tileImage());
+ recordSetState(changes.m_state, changeFlags);
return;
}
if (changeFlags.contains(GraphicsContextState::StrokeColorChange))
- append<SetInlineStrokeColor>(*changes.m_state.strokeColor.tryGetAsSRGBABytes());
+ recordSetInlineStrokeColor(*changes.m_state.strokeColor.tryGetAsSRGBABytes());
if (changeFlags.contains(GraphicsContextState::StrokeThicknessChange))
- append<SetStrokeThickness>(changes.m_state.strokeThickness);
+ recordSetStrokeThickness(changes.m_state.strokeThickness);
if (changeFlags.contains(GraphicsContextState::FillColorChange))
- append<SetInlineFillColor>(*changes.m_state.fillColor.tryGetAsSRGBABytes());
+ recordSetInlineFillColor(*changes.m_state.fillColor.tryGetAsSRGBABytes());
}
-bool Recorder::canAppendItemOfType(ItemType type) const
-{
- return !m_delegate || m_delegate->canAppendItemOfType(type);
-}
-
void Recorder::appendStateChangeItemIfNecessary()
{
+ // FIXME: This is currently invoked in an ad-hoc manner when recording drawing items. We should consider either
+ // splitting GraphicsContext state changes into individual display list items, or refactoring the code such that
+ // this method is automatically invoked when recording a drawing item.
auto& stateChanges = currentState().stateChange;
auto changesFromLastState = stateChanges.changesFromState(currentState().lastDrawingState);
if (!changesFromLastState)
@@ -152,34 +124,24 @@
currentState().stateChange.accumulate(state, flags);
}
-bool Recorder::canDrawImageBuffer(const ImageBuffer& imageBuffer) const
-{
- return !m_delegate || m_delegate->isCachedImageBuffer(imageBuffer);
-}
-
-RenderingMode Recorder::renderingMode() const
-{
- return m_delegate ? m_delegate->renderingMode() : RenderingMode::Unaccelerated;
-}
-
void Recorder::setLineCap(LineCap lineCap)
{
- append<SetLineCap>(lineCap);
+ recordSetLineCap(lineCap);
}
void Recorder::setLineDash(const DashArray& dashArray, float dashOffset)
{
- append<SetLineDash>(dashArray, dashOffset);
+ recordSetLineDash(dashArray, dashOffset);
}
void Recorder::setLineJoin(LineJoin lineJoin)
{
- append<SetLineJoin>(lineJoin);
+ recordSetLineJoin(lineJoin);
}
void Recorder::setMiterLimit(float miterLimit)
{
- append<SetMiterLimit>(miterLimit);
+ recordSetMiterLimit(miterLimit);
}
void Recorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)
@@ -189,39 +151,40 @@
void Recorder::drawGlyphsAndCacheFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode)
{
- if (m_delegate)
- m_delegate->recordFontUse(const_cast<Font&>(font));
- m_displayList.cacheFont(const_cast<Font&>(font));
- append<DrawGlyphs>(font, glyphs, advances, count, localAnchor, smoothingMode);
+ appendStateChangeItemIfNecessary();
+ recordResourceUse(const_cast<Font&>(font));
+ recordDrawGlyphs(font, glyphs, advances, count, localAnchor, smoothingMode);
}
void Recorder::drawImageBuffer(ImageBuffer& imageBuffer, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
+ appendStateChangeItemIfNecessary();
if (!canDrawImageBuffer(imageBuffer)) {
GraphicsContext::drawImageBuffer(imageBuffer, destRect, srcRect, options);
return;
}
- if (m_delegate)
- m_delegate->recordImageBufferUse(imageBuffer);
- m_displayList.cacheImageBuffer(imageBuffer);
- append<DrawImageBuffer>(imageBuffer.renderingResourceIdentifier(), destRect, srcRect, options);
+
+ recordResourceUse(imageBuffer);
+ recordDrawImageBuffer(imageBuffer.renderingResourceIdentifier(), destRect, srcRect, options);
}
void Recorder::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
- recordNativeImageUse(image);
- append<DrawNativeImage>(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options);
+ appendStateChangeItemIfNecessary();
+ recordResourceUse(image);
+ recordDrawNativeImage(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options);
}
void Recorder::drawPattern(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
{
- recordNativeImageUse(image);
- append<DrawPattern>(image.renderingResourceIdentifier(), imageSize, destRect, tileRect, patternTransform, phase, spacing, options);
+ appendStateChangeItemIfNecessary();
+ recordResourceUse(image);
+ recordDrawPattern(image.renderingResourceIdentifier(), imageSize, destRect, tileRect, patternTransform, phase, spacing, options);
}
void Recorder::save()
{
- append<Save>();
+ recordSave();
m_stateStack.append(m_stateStack.last().cloneForSave());
}
@@ -231,25 +194,25 @@
return;
m_stateStack.removeLast();
- append<Restore>();
+ recordRestore();
}
void Recorder::translate(float x, float y)
{
currentState().translate(x, y);
- append<Translate>(x, y);
+ recordTranslate(x, y);
}
void Recorder::rotate(float angleInRadians)
{
currentState().rotate(angleInRadians);
- append<Rotate>(angleInRadians);
+ recordRotate(angleInRadians);
}
void Recorder::scale(const FloatSize& size)
{
currentState().scale(size);
- append<Scale>(size);
+ recordScale(size);
}
void Recorder::concatCTM(const AffineTransform& transform)
@@ -258,13 +221,13 @@
return;
currentState().concatCTM(transform);
- append<ConcatenateCTM>(transform);
+ recordConcatenateCTM(transform);
}
void Recorder::setCTM(const AffineTransform& transform)
{
currentState().setCTM(transform);
- append<SetCTM>(transform);
+ recordSetCTM(transform);
}
AffineTransform Recorder::getCTM(GraphicsContext::IncludeDeviceScale) const
@@ -275,54 +238,64 @@
void Recorder::beginTransparencyLayer(float opacity)
{
- append<BeginTransparencyLayer>(opacity);
+ appendStateChangeItemIfNecessary();
+ recordBeginTransparencyLayer(opacity);
m_stateStack.append(m_stateStack.last().cloneForTransparencyLayer());
}
void Recorder::endTransparencyLayer()
{
- append<EndTransparencyLayer>();
+ appendStateChangeItemIfNecessary();
+ recordEndTransparencyLayer();
m_stateStack.removeLast();
}
void Recorder::drawRect(const FloatRect& rect, float borderThickness)
{
- append<DrawRect>(rect, borderThickness);
+ appendStateChangeItemIfNecessary();
+ recordDrawRect(rect, borderThickness);
}
void Recorder::drawLine(const FloatPoint& point1, const FloatPoint& point2)
{
- append<DrawLine>(point1, point2);
+ appendStateChangeItemIfNecessary();
+ recordDrawLine(point1, point2);
}
void Recorder::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle)
{
- append<DrawLinesForText>(FloatPoint(), toFloatSize(point), thickness, widths, printing, doubleLines);
+ appendStateChangeItemIfNecessary();
+ recordDrawLinesForText(FloatPoint(), toFloatSize(point), thickness, widths, printing, doubleLines);
}
void Recorder::drawDotsForDocumentMarker(const FloatRect& rect, DocumentMarkerLineStyle style)
{
- append<DrawDotsForDocumentMarker>(rect, style);
+ appendStateChangeItemIfNecessary();
+ recordDrawDotsForDocumentMarker(rect, style);
}
void Recorder::drawEllipse(const FloatRect& rect)
{
- append<DrawEllipse>(rect);
+ appendStateChangeItemIfNecessary();
+ recordDrawEllipse(rect);
}
void Recorder::drawPath(const Path& path)
{
- append<DrawPath>(path);
+ appendStateChangeItemIfNecessary();
+ recordDrawPath(path);
}
void Recorder::drawFocusRing(const Path& path, float width, float offset, const Color& color)
{
- append<DrawFocusRingPath>(path, width, offset, color);
+ appendStateChangeItemIfNecessary();
+ recordDrawFocusRingPath(path, width, offset, color);
}
void Recorder::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
{
- append<DrawFocusRingRects>(rects, width, offset, color);
+ appendStateChangeItemIfNecessary();
+ recordDrawFocusRingRects(rects, width, offset, color);
}
#if PLATFORM(MAC)
@@ -339,99 +312,113 @@
void Recorder::fillRect(const FloatRect& rect)
{
- append<FillRect>(rect);
+ appendStateChangeItemIfNecessary();
+ recordFillRect(rect);
}
void Recorder::fillRect(const FloatRect& rect, const Color& color)
{
- append<FillRectWithColor>(rect, color);
+ appendStateChangeItemIfNecessary();
+ recordFillRectWithColor(rect, color);
}
void Recorder::fillRect(const FloatRect& rect, Gradient& gradient)
{
- append<FillRectWithGradient>(rect, gradient);
+ appendStateChangeItemIfNecessary();
+ recordFillRectWithGradient(rect, gradient);
}
void Recorder::fillRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode blendMode)
{
- append<FillCompositedRect>(rect, color, op, blendMode);
+ appendStateChangeItemIfNecessary();
+ recordFillCompositedRect(rect, color, op, blendMode);
}
void Recorder::fillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode blendMode)
{
- append<FillRoundedRect>(rect, color, blendMode);
+ appendStateChangeItemIfNecessary();
+ recordFillRoundedRect(rect, color, blendMode);
}
void Recorder::fillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color)
{
- append<FillRectWithRoundedHole>(rect, roundedHoleRect, color);
+ appendStateChangeItemIfNecessary();
+ recordFillRectWithRoundedHole(rect, roundedHoleRect, color);
}
void Recorder::fillPath(const Path& path)
{
+ appendStateChangeItemIfNecessary();
#if ENABLE(INLINE_PATH_DATA)
if (path.hasInlineData()) {
if (path.hasInlineData<LineData>())
- append<FillLine>(path.inlineData<LineData>());
+ recordFillLine(path.inlineData<LineData>());
else if (path.hasInlineData<ArcData>())
- append<FillArc>(path.inlineData<ArcData>());
+ recordFillArc(path.inlineData<ArcData>());
else if (path.hasInlineData<QuadCurveData>())
- append<FillQuadCurve>(path.inlineData<QuadCurveData>());
+ recordFillQuadCurve(path.inlineData<QuadCurveData>());
else if (path.hasInlineData<BezierCurveData>())
- append<FillBezierCurve>(path.inlineData<BezierCurveData>());
+ recordFillBezierCurve(path.inlineData<BezierCurveData>());
return;
}
#endif
- append<FillPath>(path);
+ recordFillPath(path);
}
void Recorder::fillEllipse(const FloatRect& rect)
{
- append<FillEllipse>(rect);
+ appendStateChangeItemIfNecessary();
+ recordFillEllipse(rect);
}
void Recorder::strokeRect(const FloatRect& rect, float lineWidth)
{
- append<StrokeRect>(rect, lineWidth);
+ appendStateChangeItemIfNecessary();
+ recordStrokeRect(rect, lineWidth);
}
void Recorder::strokePath(const Path& path)
{
+ appendStateChangeItemIfNecessary();
#if ENABLE(INLINE_PATH_DATA)
if (path.hasInlineData()) {
if (path.hasInlineData<LineData>())
- append<StrokeLine>(path.inlineData<LineData>());
+ recordStrokeLine(path.inlineData<LineData>());
else if (path.hasInlineData<ArcData>())
- append<StrokeArc>(path.inlineData<ArcData>());
+ recordStrokeArc(path.inlineData<ArcData>());
else if (path.hasInlineData<QuadCurveData>())
- append<StrokeQuadCurve>(path.inlineData<QuadCurveData>());
+ recordStrokeQuadCurve(path.inlineData<QuadCurveData>());
else if (path.hasInlineData<BezierCurveData>())
- append<StrokeBezierCurve>(path.inlineData<BezierCurveData>());
+ recordStrokeBezierCurve(path.inlineData<BezierCurveData>());
return;
}
#endif
- append<StrokePath>(path);
+ recordStrokePath(path);
}
void Recorder::strokeEllipse(const FloatRect& rect)
{
- append<StrokeEllipse>(rect);
+ appendStateChangeItemIfNecessary();
+ recordStrokeEllipse(rect);
}
void Recorder::clearRect(const FloatRect& rect)
{
- append<ClearRect>(rect);
+ appendStateChangeItemIfNecessary();
+ recordClearRect(rect);
}
#if USE(CG)
void Recorder::applyStrokePattern()
{
- append<ApplyStrokePattern>();
+ appendStateChangeItemIfNecessary();
+ recordApplyStrokePattern();
}
void Recorder::applyFillPattern()
{
- append<ApplyFillPattern>();
+ appendStateChangeItemIfNecessary();
+ recordApplyFillPattern();
}
#endif
@@ -438,23 +425,23 @@
void Recorder::clip(const FloatRect& rect)
{
currentState().clipBounds.intersect(rect);
- append<Clip>(rect);
+ recordClip(rect);
}
void Recorder::clipOut(const FloatRect& rect)
{
- append<ClipOut>(rect);
+ recordClipOut(rect);
}
void Recorder::clipOut(const Path& path)
{
- append<ClipOutToPath>(path);
+ recordClipOutToPath(path);
}
void Recorder::clipPath(const Path& path, WindRule windRule)
{
currentState().clipBounds.intersect(path.fastBoundingRect());
- append<ClipPath>(path, windRule);
+ recordClipPath(path, windRule);
}
IntRect Recorder::clipBounds() const
@@ -464,10 +451,8 @@
void Recorder::clipToImageBuffer(ImageBuffer& imageBuffer, const FloatRect& destRect)
{
- if (m_delegate)
- m_delegate->recordImageBufferUse(imageBuffer);
- m_displayList.cacheImageBuffer(imageBuffer);
- append<ClipToImageBuffer>(imageBuffer.renderingResourceIdentifier(), destRect);
+ recordResourceUse(imageBuffer);
+ recordClipToImageBuffer(imageBuffer.renderingResourceIdentifier(), destRect);
}
GraphicsContext::ClipToDrawingCommandsResult Recorder::clipToDrawingCommands(const FloatRect& destination, const DestinationColorSpace& colorSpace, Function<void(GraphicsContext&)>&& drawingFunction)
@@ -483,10 +468,10 @@
initialCTM.translate(0, -scaledSize.height());
initialCTM.scale(scaledSize / destination.size());
- Recorder nestedContext(*this, GraphicsContextState(), initialClip, initialCTM);
- append<BeginClipToDrawingCommands>(destination, colorSpace);
- drawingFunction(nestedContext);
- append<EndClipToDrawingCommands>(destination);
+ auto nestedContext = createNestedContext(initialClip, initialCTM);
+ recordBeginClipToDrawingCommands(destination, colorSpace);
+ drawingFunction(*nestedContext);
+ recordEndClipToDrawingCommands(destination);
return ClipToDrawingCommandsResult::Success;
}
@@ -499,7 +484,7 @@
return;
}
ASSERT(player.identifier());
- append<PaintFrameForMedia>(player, destination);
+ recordPaintFrameForMedia(player, destination);
}
#endif
@@ -507,7 +492,7 @@
{
// FIXME: this changes the baseCTM, which will invalidate all of our cached extents.
// Assert that it's only called early on?
- append<ApplyDeviceScaleFactor>(deviceScaleFactor);
+ recordApplyDeviceScaleFactor(deviceScaleFactor);
}
FloatRect Recorder::roundToDevicePixels(const FloatRect& rect, GraphicsContext::RoundingMode)
@@ -526,25 +511,6 @@
return ceilf(blurRadius * radiusExtentMultiplier);
}
-FloatRect Recorder::extentFromLocalBounds(const FloatRect& rect) const
-{
- FloatRect bounds = rect;
- const ContextState& state = currentState();
-
- FloatSize shadowOffset;
- float shadowRadius;
- Color shadowColor;
- if (getShadow(shadowOffset, shadowRadius, shadowColor)) {
- FloatRect shadowExtent = bounds;
- shadowExtent.move(shadowOffset);
- shadowExtent.inflate(shadowPaintingExtent(shadowRadius));
- bounds.unite(shadowExtent);
- }
-
- FloatRect clippedExtent = intersection(state.clipBounds, bounds);
- return state.ctm.mapRect(clippedExtent);
-}
-
const Recorder::ContextState& Recorder::currentState() const
{
ASSERT(m_stateStack.size());
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (283847 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -30,6 +30,7 @@
#include "DrawGlyphsRecorder.h"
#include "GraphicsContext.h"
#include "Image.h" // For Image::TileRule.
+#include "InlinePathData.h"
#include "TextFlags.h"
#include <wtf/Noncopyable.h>
@@ -54,36 +55,138 @@
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(Recorder);
public:
- class Delegate;
- WEBCORE_EXPORT Recorder(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Delegate* = nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction = DrawGlyphsRecorder::DrawGlyphsDeconstruction::Deconstruct);
+ WEBCORE_EXPORT Recorder(const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, DrawGlyphsRecorder::DrawGlyphsDeconstruction = DrawGlyphsRecorder::DrawGlyphsDeconstruction::Deconstruct);
WEBCORE_EXPORT virtual ~Recorder();
- WEBCORE_EXPORT void getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect);
- WEBCORE_EXPORT void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat);
+ virtual void getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect) = 0;
+ virtual void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) = 0;
+ virtual void flushContext(GraphicsContextFlushIdentifier) = 0;
- bool isEmpty() const { return m_displayList.isEmpty(); }
+protected:
+ WEBCORE_EXPORT Recorder(Recorder& parent, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform& initialCTM);
- class Delegate {
- public:
- virtual ~Delegate() { }
- virtual bool canAppendItemOfType(ItemType) { return false; }
- virtual void recordNativeImageUse(NativeImage&) { }
- virtual bool isCachedImageBuffer(const ImageBuffer&) const { return false; }
- virtual void recordFontUse(Font&) { }
- virtual void recordImageBufferUse(ImageBuffer&) { }
- virtual RenderingMode renderingMode() const { return RenderingMode::Unaccelerated; }
+ virtual void recordSave() = 0;
+ virtual void recordRestore() = 0;
+ virtual void recordTranslate(float x, float y) = 0;
+ virtual void recordRotate(float angle) = 0;
+ virtual void recordScale(const FloatSize&) = 0;
+ virtual void recordSetCTM(const AffineTransform&) = 0;
+ virtual void recordConcatenateCTM(const AffineTransform&) = 0;
+ virtual void recordSetInlineFillColor(SRGBA<uint8_t>) = 0;
+ virtual void recordSetInlineStrokeColor(SRGBA<uint8_t>) = 0;
+ virtual void recordSetStrokeThickness(float) = 0;
+ virtual void recordSetState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) = 0;
+ virtual void recordSetLineCap(LineCap) = 0;
+ virtual void recordSetLineDash(const DashArray&, float dashOffset) = 0;
+ virtual void recordSetLineJoin(LineJoin) = 0;
+ virtual void recordSetMiterLimit(float) = 0;
+ virtual void recordClearShadow() = 0;
+ virtual void recordClip(const FloatRect&) = 0;
+ virtual void recordClipOut(const FloatRect&) = 0;
+ virtual void recordClipToImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destinationRect) = 0;
+ virtual void recordClipOutToPath(const Path&) = 0;
+ virtual void recordClipPath(const Path&, WindRule) = 0;
+ virtual void recordBeginClipToDrawingCommands(const FloatRect& destination, DestinationColorSpace) = 0;
+ virtual void recordEndClipToDrawingCommands(const FloatRect& destination) = 0;
+ virtual void recordDrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode) = 0;
+ virtual void recordDrawImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
+ virtual void recordDrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
+ virtual void recordDrawPattern(RenderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) = 0;
+ virtual void recordBeginTransparencyLayer(float) = 0;
+ virtual void recordEndTransparencyLayer() = 0;
+ virtual void recordDrawRect(const FloatRect&, float) = 0;
+ virtual void recordDrawLine(const FloatPoint& point1, const FloatPoint& point2) = 0;
+ virtual void recordDrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines) = 0;
+ virtual void recordDrawDotsForDocumentMarker(const FloatRect&, const DocumentMarkerLineStyle&) = 0;
+ virtual void recordDrawEllipse(const FloatRect&) = 0;
+ virtual void recordDrawPath(const Path&) = 0;
+ virtual void recordDrawFocusRingPath(const Path&, float width, float offset, const Color&) = 0;
+ virtual void recordDrawFocusRingRects(const Vector<FloatRect>&, float width, float offset, const Color&) = 0;
+ virtual void recordFillRect(const FloatRect&) = 0;
+ virtual void recordFillRectWithColor(const FloatRect&, const Color&) = 0;
+ virtual void recordFillRectWithGradient(const FloatRect&, Gradient&) = 0;
+ virtual void recordFillCompositedRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) = 0;
+ virtual void recordFillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) = 0;
+ virtual void recordFillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect&, const Color&) = 0;
+#if ENABLE(INLINE_PATH_DATA)
+ virtual void recordFillLine(const LineData&) = 0;
+ virtual void recordFillArc(const ArcData&) = 0;
+ virtual void recordFillQuadCurve(const QuadCurveData&) = 0;
+ virtual void recordFillBezierCurve(const BezierCurveData&) = 0;
+#endif
+ virtual void recordFillPath(const Path&) = 0;
+ virtual void recordFillEllipse(const FloatRect&) = 0;
+ virtual void recordGetPixelBuffer(PixelBufferFormat outputFormat, const IntRect&) = 0;
+ virtual void recordPutPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication) = 0;
+ virtual void recordPaintFrameForMedia(MediaPlayer&, const FloatRect& destination) = 0;
+ virtual void recordStrokeRect(const FloatRect&, float) = 0;
+#if ENABLE(INLINE_PATH_DATA)
+ virtual void recordStrokeLine(const LineData&) = 0;
+ virtual void recordStrokeArc(const ArcData&) = 0;
+ virtual void recordStrokeQuadCurve(const QuadCurveData&) = 0;
+ virtual void recordStrokeBezierCurve(const BezierCurveData&) = 0;
+#endif
+ virtual void recordStrokePath(const Path&) = 0;
+ virtual void recordStrokeEllipse(const FloatRect&) = 0;
+ virtual void recordClearRect(const FloatRect&) = 0;
+#if USE(CG)
+ virtual void recordApplyStrokePattern() = 0;
+ virtual void recordApplyFillPattern() = 0;
+#endif
+ virtual void recordApplyDeviceScaleFactor(float) = 0;
+
+ virtual void recordResourceUse(NativeImage&) = 0;
+ virtual void recordResourceUse(Font&) = 0;
+ virtual void recordResourceUse(ImageBuffer&) = 0;
+
+ // FIXME: Maybe remove this?
+ virtual bool canDrawImageBuffer(const ImageBuffer&) const = 0;
+ virtual RenderingMode renderingMode() const = 0;
+
+ virtual std::unique_ptr<GraphicsContext> createNestedContext(const FloatRect& initialClip, const AffineTransform& initialCTM) = 0;
+
+ struct ContextState {
+ AffineTransform ctm;
+ FloatRect clipBounds;
+ GraphicsContextStateChange stateChange;
+ GraphicsContextState lastDrawingState;
+
+ ContextState(const GraphicsContextState& state, const AffineTransform& transform, const FloatRect& clip)
+ : ctm(transform)
+ , clipBounds(clip)
+ , lastDrawingState(state)
+ {
+ }
+
+ ContextState cloneForSave() const
+ {
+ ContextState state(lastDrawingState, ctm, clipBounds);
+ state.stateChange = stateChange;
+ return state;
+ }
+
+ ContextState cloneForTransparencyLayer() const
+ {
+ auto state = cloneForSave();
+ state.lastDrawingState.alpha = 1;
+ return state;
+ }
+
+ void translate(float x, float y);
+ void rotate(float angleInRadians);
+ void scale(const FloatSize&);
+ void concatCTM(const AffineTransform&);
+ void setCTM(const AffineTransform&);
};
- void flushContext(GraphicsContextFlushIdentifier identifier) { append<FlushContext>(identifier); }
+ const Vector<ContextState, 4>& stateStack() const { return m_stateStack; }
+ const ContextState& currentState() const;
+ ContextState& currentState();
+
private:
- Recorder(Recorder& parent, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform& initialCTM);
-
bool hasPlatformContext() const final { return false; }
- // FIXME: Maybe remove this?
- bool canDrawImageBuffer(const ImageBuffer&) const;
PlatformGraphicsContext* platformContext() const final { return nullptr; }
- RenderingMode renderingMode() const final;
#if USE(CG) || USE(DIRECT2D)
void setIsCALayerContext(bool) final { }
@@ -94,184 +197,94 @@
void fillRoundedRectImpl(const FloatRoundedRect&, const Color&) final { ASSERT_NOT_REACHED(); }
void drawLineForText(const FloatRect&, bool, bool, StrokeStyle) final { ASSERT_NOT_REACHED(); }
- const GraphicsContextState& state() const final;
+ WEBCORE_EXPORT const GraphicsContextState& state() const final;
- void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final;
+ WEBCORE_EXPORT void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final;
- void setLineCap(LineCap) final;
- void setLineDash(const DashArray&, float dashOffset) final;
- void setLineJoin(LineJoin) final;
- void setMiterLimit(float) final;
+ WEBCORE_EXPORT void setLineCap(LineCap) final;
+ WEBCORE_EXPORT void setLineDash(const DashArray&, float dashOffset) final;
+ WEBCORE_EXPORT void setLineJoin(LineJoin) final;
+ WEBCORE_EXPORT void setMiterLimit(float) final;
- void fillRect(const FloatRect&) final;
- void fillRect(const FloatRect&, const Color&) final;
- void fillRect(const FloatRect&, Gradient&) final;
- void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) final;
- void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) final;
- void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&) final;
- void fillPath(const Path&) final;
- void fillEllipse(const FloatRect&) final;
- void strokeRect(const FloatRect&, float lineWidth) final;
- void strokePath(const Path&) final;
- void strokeEllipse(const FloatRect&) final;
- void clearRect(const FloatRect&) final;
+ WEBCORE_EXPORT void fillRect(const FloatRect&) final;
+ WEBCORE_EXPORT void fillRect(const FloatRect&, const Color&) final;
+ WEBCORE_EXPORT void fillRect(const FloatRect&, Gradient&) final;
+ WEBCORE_EXPORT void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) final;
+ WEBCORE_EXPORT void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) final;
+ WEBCORE_EXPORT void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&) final;
+ WEBCORE_EXPORT void fillPath(const Path&) final;
+ WEBCORE_EXPORT void fillEllipse(const FloatRect&) final;
+ WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth) final;
+ WEBCORE_EXPORT void strokePath(const Path&) final;
+ WEBCORE_EXPORT void strokeEllipse(const FloatRect&) final;
+ WEBCORE_EXPORT void clearRect(const FloatRect&) final;
#if USE(CG) || USE(DIRECT2D)
- void applyStrokePattern() final;
- void applyFillPattern() final;
+ WEBCORE_EXPORT void applyStrokePattern() final;
+ WEBCORE_EXPORT void applyFillPattern() final;
#endif
- void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode) final;
- void drawGlyphsAndCacheFont(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode);
+ WEBCORE_EXPORT void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode) final;
+ WEBCORE_EXPORT void drawGlyphsAndCacheFont(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode) final;
- void drawImageBuffer(WebCore::ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) final;
- void drawNativeImage(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
- void drawPattern(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) final;
+ WEBCORE_EXPORT void drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) final;
+ WEBCORE_EXPORT void drawNativeImage(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
+ WEBCORE_EXPORT void drawPattern(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) final;
- void drawRect(const FloatRect&, float borderThickness) final;
- void drawLine(const FloatPoint&, const FloatPoint&) final;
- void drawLinesForText(const FloatPoint&, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) final;
- void drawDotsForDocumentMarker(const FloatRect&, DocumentMarkerLineStyle) final;
- void drawEllipse(const FloatRect&) final;
+ WEBCORE_EXPORT void drawRect(const FloatRect&, float borderThickness) final;
+ WEBCORE_EXPORT void drawLine(const FloatPoint&, const FloatPoint&) final;
+ WEBCORE_EXPORT void drawLinesForText(const FloatPoint&, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) final;
+ WEBCORE_EXPORT void drawDotsForDocumentMarker(const FloatRect&, DocumentMarkerLineStyle) final;
+ WEBCORE_EXPORT void drawEllipse(const FloatRect&) final;
- void drawPath(const Path&) final;
+ WEBCORE_EXPORT void drawPath(const Path&) final;
- void drawFocusRing(const Path&, float width, float offset, const Color&) final;
- void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) final;
+ WEBCORE_EXPORT void drawFocusRing(const Path&, float width, float offset, const Color&) final;
+ WEBCORE_EXPORT void drawFocusRing(const Vector<FloatRect>&, float width, float offset, const Color&) final;
#if PLATFORM(MAC)
- void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw, const Color&) final;
- void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw, const Color&) final;
+ WEBCORE_EXPORT void drawFocusRing(const Path&, double timeOffset, bool& needsRedraw, const Color&) final;
+ WEBCORE_EXPORT void drawFocusRing(const Vector<FloatRect>&, double timeOffset, bool& needsRedraw, const Color&) final;
#endif
- void save() final;
- void restore() final;
+ WEBCORE_EXPORT void save() final;
+ WEBCORE_EXPORT void restore() final;
- void translate(float x, float y) final;
- void rotate(float angleInRadians) final;
- void scale(const FloatSize&) final;
- void concatCTM(const AffineTransform&) final;
- void setCTM(const AffineTransform&) final;
- AffineTransform getCTM(GraphicsContext::IncludeDeviceScale) const final;
+ WEBCORE_EXPORT void translate(float x, float y) final;
+ WEBCORE_EXPORT void rotate(float angleInRadians) final;
+ WEBCORE_EXPORT void scale(const FloatSize&) final;
+ WEBCORE_EXPORT void concatCTM(const AffineTransform&) final;
+ WEBCORE_EXPORT void setCTM(const AffineTransform&) final;
+ WEBCORE_EXPORT AffineTransform getCTM(GraphicsContext::IncludeDeviceScale) const final;
- void beginTransparencyLayer(float opacity) final;
- void endTransparencyLayer() final;
+ WEBCORE_EXPORT void beginTransparencyLayer(float opacity) final;
+ WEBCORE_EXPORT void endTransparencyLayer() final;
- void clip(const FloatRect&) final;
- void clipOut(const FloatRect&) final;
- void clipOut(const Path&) final;
- void clipPath(const Path&, WindRule) final;
- IntRect clipBounds() const final;
- void clipToImageBuffer(WebCore::ImageBuffer&, const FloatRect&) final;
- WebCore::GraphicsContext::ClipToDrawingCommandsResult clipToDrawingCommands(const FloatRect& destination, const DestinationColorSpace&, Function<void(GraphicsContext&)>&&) final;
+ WEBCORE_EXPORT void clip(const FloatRect&) final;
+ WEBCORE_EXPORT void clipOut(const FloatRect&) final;
+ WEBCORE_EXPORT void clipOut(const Path&) final;
+ WEBCORE_EXPORT void clipPath(const Path&, WindRule) final;
+ WEBCORE_EXPORT IntRect clipBounds() const final;
+ WEBCORE_EXPORT void clipToImageBuffer(ImageBuffer&, const FloatRect&) final;
+ WEBCORE_EXPORT GraphicsContext::ClipToDrawingCommandsResult clipToDrawingCommands(const FloatRect& destination, const DestinationColorSpace&, Function<void(GraphicsContext&)>&&) final;
#if ENABLE(VIDEO)
- void paintFrameForMedia(MediaPlayer&, const FloatRect& destination) final;
+ WEBCORE_EXPORT void paintFrameForMedia(MediaPlayer&, const FloatRect& destination) final;
#endif
- void applyDeviceScaleFactor(float) final;
+ WEBCORE_EXPORT void applyDeviceScaleFactor(float) final;
- FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) final;
+ WEBCORE_EXPORT FloatRect roundToDevicePixels(const FloatRect&, GraphicsContext::RoundingMode) final;
- template<typename T, class... Args>
- void append(Args&&... args)
- {
- if (UNLIKELY(!canAppendItemOfType(T::itemType)))
- return;
-
- if constexpr (itemNeedsState<T>())
- appendStateChangeItemIfNecessary();
-
- m_displayList.append<T>(std::forward<Args>(args)...);
-
- if constexpr (T::isDrawingItem) {
- if (LIKELY(!m_displayList.tracksDrawingItemExtents()))
- return;
-
- auto item = T(std::forward<Args>(args)...);
- if (auto rect = item.localBounds(*this))
- m_displayList.addDrawingItemExtent(extentFromLocalBounds(*rect));
- else if (auto rect = item.globalBounds())
- m_displayList.addDrawingItemExtent(*rect);
- else
- m_displayList.addDrawingItemExtent(std::nullopt);
- }
- }
-
- WEBCORE_EXPORT bool canAppendItemOfType(ItemType) const;
-
- template<typename T>
- static constexpr bool itemNeedsState();
-
- void recordNativeImageUse(NativeImage&);
-
void appendStateChangeItemIfNecessary();
void appendStateChangeItem(const GraphicsContextStateChange&, GraphicsContextState::StateChangeFlags);
- FloatRect extentFromLocalBounds(const FloatRect&) const;
-
const AffineTransform& ctm() const;
- struct ContextState {
- AffineTransform ctm;
- FloatRect clipBounds;
- GraphicsContextStateChange stateChange;
- GraphicsContextState lastDrawingState;
-
- ContextState(const GraphicsContextState& state, const AffineTransform& transform, const FloatRect& clip)
- : ctm(transform)
- , clipBounds(clip)
- , lastDrawingState(state)
- {
- }
-
- ContextState cloneForSave() const
- {
- ContextState state(lastDrawingState, ctm, clipBounds);
- state.stateChange = stateChange;
- return state;
- }
-
- ContextState cloneForTransparencyLayer() const
- {
- auto state = cloneForSave();
- state.lastDrawingState.alpha = 1;
- return state;
- }
-
- void translate(float x, float y);
- void rotate(float angleInRadians);
- void scale(const FloatSize&);
- void concatCTM(const AffineTransform&);
- void setCTM(const AffineTransform&);
- };
-
- const ContextState& currentState() const;
- ContextState& currentState();
-
- DisplayList& m_displayList;
- Delegate* m_delegate;
- bool m_isNested;
-
Vector<ContextState, 4> m_stateStack;
-
DrawGlyphsRecorder m_drawGlyphsRecorder;
};
-template<typename T>
-constexpr bool Recorder::itemNeedsState()
-{
- if (T::isDrawingItem)
- return true;
+} // namespace DisplayList
+} // namespace WebCore
-#if USE(CG)
- if (T::itemType == ItemType::ApplyFillPattern || T::itemType == ItemType::ApplyStrokePattern)
- return true;
-#endif
-
- return false;
-}
-
-}
-}
-
Added: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp (0 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -0,0 +1,464 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayListRecorder.h"
+
+#include "DisplayList.h"
+#include "DisplayListDrawingContext.h"
+#include "DisplayListItems.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "Logging.h"
+#include "MediaPlayer.h"
+#include "NotImplemented.h"
+#include <wtf/MathExtras.h>
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+namespace DisplayList {
+
+RecorderImpl::RecorderImpl(DisplayList& displayList, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM, Delegate* delegate, DrawGlyphsRecorder::DrawGlyphsDeconstruction drawGlyphsDeconstruction)
+ : Recorder(state, initialClip, initialCTM, drawGlyphsDeconstruction)
+ , m_displayList(displayList)
+ , m_delegate(delegate)
+{
+ LOG_WITH_STREAM(DisplayLists, stream << "\nRecording with clip " << initialClip);
+}
+
+RecorderImpl::RecorderImpl(RecorderImpl& parent, const GraphicsContextState& state, const FloatRect& initialClip, const AffineTransform& initialCTM)
+ : Recorder(parent, state, initialClip, initialCTM)
+ , m_displayList(parent.m_displayList)
+ , m_delegate(parent.m_delegate)
+ , m_isNested(true)
+{
+}
+
+RecorderImpl::~RecorderImpl()
+{
+ ASSERT(stateStack().size() == 1); // If this fires, it indicates mismatched save/restore.
+ if (!m_isNested)
+ LOG(DisplayLists, "Recorded display list:\n%s", m_displayList.description().data());
+}
+
+void RecorderImpl::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect)
+{
+ append<GetPixelBuffer>(outputFormat, sourceRect);
+}
+
+void RecorderImpl::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat)
+{
+ append<PutPixelBuffer>(pixelBuffer, srcRect, destPoint, destFormat);
+}
+
+bool RecorderImpl::canAppendItemOfType(ItemType type) const
+{
+ return !m_delegate || m_delegate->canAppendItemOfType(type);
+}
+
+bool RecorderImpl::canDrawImageBuffer(const ImageBuffer& imageBuffer) const
+{
+ return !m_delegate || m_delegate->isCachedImageBuffer(imageBuffer);
+}
+
+RenderingMode RecorderImpl::renderingMode() const
+{
+ return m_delegate ? m_delegate->renderingMode() : RenderingMode::Unaccelerated;
+}
+
+std::unique_ptr<GraphicsContext> RecorderImpl::createNestedContext(const FloatRect& initialClip, const AffineTransform& initialCTM)
+{
+ return makeUnique<RecorderImpl>(*this, GraphicsContextState { }, initialClip, initialCTM);
+}
+
+void RecorderImpl::recordSave()
+{
+ append<Save>();
+}
+
+void RecorderImpl::recordRestore()
+{
+ append<Restore>();
+}
+
+void RecorderImpl::recordTranslate(float x, float y)
+{
+ append<Translate>(x, y);
+}
+
+void RecorderImpl::recordRotate(float angle)
+{
+ append<Rotate>(angle);
+}
+
+void RecorderImpl::recordScale(const FloatSize& scale)
+{
+ append<Scale>(scale);
+}
+
+void RecorderImpl::recordSetCTM(const AffineTransform& transform)
+{
+ append<SetCTM>(transform);
+}
+
+void RecorderImpl::recordConcatenateCTM(const AffineTransform& transform)
+{
+ append<ConcatenateCTM>(transform);
+}
+
+void RecorderImpl::recordSetInlineFillColor(SRGBA<uint8_t> inlineColor)
+{
+ append<SetInlineFillColor>(inlineColor);
+}
+
+void RecorderImpl::recordSetInlineStrokeColor(SRGBA<uint8_t> inlineColor)
+{
+ append<SetInlineStrokeColor>(inlineColor);
+}
+
+void RecorderImpl::recordSetStrokeThickness(float thickness)
+{
+ append<SetStrokeThickness>(thickness);
+}
+
+void RecorderImpl::recordSetState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags changeFlags)
+{
+ append<SetState>(state, changeFlags);
+}
+
+void RecorderImpl::recordSetLineCap(LineCap lineCap)
+{
+ append<SetLineCap>(lineCap);
+}
+
+void RecorderImpl::recordSetLineDash(const DashArray& array, float dashOffset)
+{
+ append<SetLineDash>(array, dashOffset);
+}
+
+void RecorderImpl::recordSetLineJoin(LineJoin join)
+{
+ append<SetLineJoin>(join);
+}
+
+void RecorderImpl::recordSetMiterLimit(float limit)
+{
+ append<SetMiterLimit>(limit);
+}
+
+void RecorderImpl::recordClearShadow()
+{
+ append<ClearShadow>();
+}
+
+void RecorderImpl::recordClip(const FloatRect& clipRect)
+{
+ append<Clip>(clipRect);
+}
+
+void RecorderImpl::recordClipOut(const FloatRect& clipRect)
+{
+ append<ClipOut>(clipRect);
+}
+
+void RecorderImpl::recordClipToImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destinationRect)
+{
+ append<ClipToImageBuffer>(imageBufferIdentifier, destinationRect);
+}
+
+void RecorderImpl::recordClipOutToPath(const Path& path)
+{
+ append<ClipOutToPath>(path);
+}
+
+void RecorderImpl::recordClipPath(const Path& path, WindRule rule)
+{
+ append<ClipPath>(path, rule);
+}
+
+void RecorderImpl::recordBeginClipToDrawingCommands(const FloatRect& destination, DestinationColorSpace colorSpace)
+{
+ append<BeginClipToDrawingCommands>(destination, colorSpace);
+}
+
+void RecorderImpl::recordEndClipToDrawingCommands(const FloatRect& destination)
+{
+ append<EndClipToDrawingCommands>(destination);
+}
+
+void RecorderImpl::recordDrawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode mode)
+{
+ append<DrawGlyphs>(font, glyphs, advances, count, localAnchor, mode);
+}
+
+void RecorderImpl::recordDrawImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+{
+ append<DrawImageBuffer>(imageBufferIdentifier, destRect, srcRect, options);
+}
+
+void RecorderImpl::recordDrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+{
+ append<DrawNativeImage>(imageIdentifier, imageSize, destRect, srcRect, options);
+}
+
+void RecorderImpl::recordDrawPattern(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
+{
+ append<DrawPattern>(imageIdentifier, imageSize, destRect, tileRect, transform, phase, spacing, options);
+}
+
+void RecorderImpl::recordBeginTransparencyLayer(float opacity)
+{
+ append<BeginTransparencyLayer>(opacity);
+}
+
+void RecorderImpl::recordEndTransparencyLayer()
+{
+ append<EndTransparencyLayer>();
+}
+
+void RecorderImpl::recordDrawRect(const FloatRect& rect, float lineWidth)
+{
+ append<DrawRect>(rect, lineWidth);
+}
+
+void RecorderImpl::recordDrawLine(const FloatPoint& point1, const FloatPoint& point2)
+{
+ append<DrawLine>(point1, point2);
+}
+
+void RecorderImpl::recordDrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines)
+{
+ append<DrawLinesForText>(blockLocation, localAnchor, thickness, widths, printing, doubleLines);
+}
+
+void RecorderImpl::recordDrawDotsForDocumentMarker(const FloatRect& rect, const DocumentMarkerLineStyle& style)
+{
+ append<DrawDotsForDocumentMarker>(rect, style);
+}
+
+void RecorderImpl::recordDrawEllipse(const FloatRect& rect)
+{
+ append<DrawEllipse>(rect);
+}
+
+void RecorderImpl::recordDrawPath(const Path& path)
+{
+ append<DrawPath>(path);
+}
+
+void RecorderImpl::recordDrawFocusRingPath(const Path& path, float width, float offset, const Color& color)
+{
+ append<DrawFocusRingPath>(path, width, offset, color);
+}
+
+void RecorderImpl::recordDrawFocusRingRects(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
+{
+ append<DrawFocusRingRects>(rects, width, offset, color);
+}
+
+void RecorderImpl::recordFillRect(const FloatRect& rect)
+{
+ append<FillRect>(rect);
+}
+
+void RecorderImpl::recordFillRectWithColor(const FloatRect& rect, const Color& color)
+{
+ append<FillRectWithColor>(rect, color);
+}
+
+void RecorderImpl::recordFillRectWithGradient(const FloatRect& rect, Gradient& gradient)
+{
+ append<FillRectWithGradient>(rect, gradient);
+}
+
+void RecorderImpl::recordFillCompositedRect(const FloatRect& rect, const Color& color, CompositeOperator op, BlendMode mode)
+{
+ append<FillCompositedRect>(rect, color, op, mode);
+}
+
+void RecorderImpl::recordFillRoundedRect(const FloatRoundedRect& rect, const Color& color, BlendMode mode)
+{
+ append<FillRoundedRect>(rect, color, mode);
+}
+
+void RecorderImpl::recordFillRectWithRoundedHole(const FloatRect& rect, const FloatRoundedRect& roundedRect, const Color& color)
+{
+ append<FillRectWithRoundedHole>(rect, roundedRect, color);
+}
+
+#if ENABLE(INLINE_PATH_DATA)
+
+void RecorderImpl::recordFillLine(const LineData& line)
+{
+ append<FillLine>(line);
+}
+
+void RecorderImpl::recordFillArc(const ArcData& arc)
+{
+ append<FillArc>(arc);
+}
+
+void RecorderImpl::recordFillQuadCurve(const QuadCurveData& curve)
+{
+ append<FillQuadCurve>(curve);
+}
+
+void RecorderImpl::recordFillBezierCurve(const BezierCurveData& curve)
+{
+ append<FillBezierCurve>(curve);
+}
+
+#endif // ENABLE(INLINE_PATH_DATA)
+
+void RecorderImpl::recordFillPath(const Path& path)
+{
+ append<FillPath>(path);
+}
+
+void RecorderImpl::recordFillEllipse(const FloatRect& rect)
+{
+ append<FillEllipse>(rect);
+}
+
+void RecorderImpl::recordGetPixelBuffer(PixelBufferFormat outputFormat, const IntRect& rect)
+{
+ append<GetPixelBuffer>(outputFormat, rect);
+}
+
+void RecorderImpl::recordPutPixelBuffer(const PixelBuffer& buffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication premultiplication)
+{
+ append<PutPixelBuffer>(buffer, srcRect, destPoint, premultiplication);
+}
+
+void RecorderImpl::recordPaintFrameForMedia(MediaPlayer& player, const FloatRect& destination)
+{
+ append<PaintFrameForMedia>(player, destination);
+}
+
+void RecorderImpl::recordStrokeRect(const FloatRect& rect, float width)
+{
+ append<StrokeRect>(rect, width);
+}
+
+#if ENABLE(INLINE_PATH_DATA)
+
+void RecorderImpl::recordStrokeLine(const LineData& line)
+{
+ append<StrokeLine>(line);
+}
+
+void RecorderImpl::recordStrokeArc(const ArcData& arc)
+{
+ append<StrokeArc>(arc);
+}
+
+void RecorderImpl::recordStrokeQuadCurve(const QuadCurveData& curve)
+{
+ append<StrokeQuadCurve>(curve);
+}
+
+void RecorderImpl::recordStrokeBezierCurve(const BezierCurveData& curve)
+{
+ append<StrokeBezierCurve>(curve);
+}
+
+#endif // ENABLE(INLINE_PATH_DATA)
+
+void RecorderImpl::recordStrokePath(const Path& path)
+{
+ append<StrokePath>(path);
+}
+
+void RecorderImpl::recordStrokeEllipse(const FloatRect& rect)
+{
+ append<StrokeEllipse>(rect);
+}
+
+void RecorderImpl::recordClearRect(const FloatRect& rect)
+{
+ append<ClearRect>(rect);
+}
+
+#if USE(CG)
+
+void RecorderImpl::recordApplyStrokePattern()
+{
+ append<ApplyStrokePattern>();
+}
+
+void RecorderImpl::recordApplyFillPattern()
+{
+ append<ApplyFillPattern>();
+}
+
+#endif // USE(CG)
+
+void RecorderImpl::recordApplyDeviceScaleFactor(float scaleFactor)
+{
+ append<ApplyDeviceScaleFactor>(scaleFactor);
+}
+
+void RecorderImpl::recordResourceUse(NativeImage& image)
+{
+ if (m_delegate)
+ m_delegate->recordNativeImageUse(image);
+ m_displayList.cacheNativeImage(image);
+}
+
+void RecorderImpl::recordResourceUse(Font& font)
+{
+ if (m_delegate)
+ m_delegate->recordFontUse(font);
+ m_displayList.cacheFont(font);
+}
+
+void RecorderImpl::recordResourceUse(ImageBuffer& imageBuffer)
+{
+ if (m_delegate)
+ m_delegate->recordImageBufferUse(imageBuffer);
+ m_displayList.cacheImageBuffer(imageBuffer);
+}
+
+FloatRect RecorderImpl::extentFromLocalBounds(const FloatRect& rect) const
+{
+ FloatRect bounds = rect;
+ auto& state = currentState();
+
+ FloatSize shadowOffset;
+ float shadowRadius;
+ Color shadowColor;
+ if (getShadow(shadowOffset, shadowRadius, shadowColor)) {
+ FloatRect shadowExtent = bounds;
+ shadowExtent.move(shadowOffset);
+ shadowExtent.inflate(shadowPaintingExtent(shadowRadius));
+ bounds.unite(shadowExtent);
+ }
+
+ FloatRect clippedExtent = intersection(state.clipBounds, bounds);
+ return state.ctm.mapRect(clippedExtent);
+}
+
+} // namespace DisplayList
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h (0 => 283848)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "DisplayListRecorder.h"
+
+namespace WebCore {
+
+namespace DisplayList {
+
+class RecorderImpl : public Recorder {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(RecorderImpl);
+public:
+ class Delegate;
+ WEBCORE_EXPORT RecorderImpl(DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Delegate* = nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction = DrawGlyphsRecorder::DrawGlyphsDeconstruction::Deconstruct);
+ RecorderImpl(RecorderImpl& parent, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform& initialCTM);
+
+ WEBCORE_EXPORT virtual ~RecorderImpl();
+
+ bool isEmpty() const { return m_displayList.isEmpty(); }
+
+ class Delegate {
+ public:
+ virtual ~Delegate() { }
+ virtual bool canAppendItemOfType(ItemType) { return false; }
+ virtual void recordNativeImageUse(NativeImage&) { }
+ virtual bool isCachedImageBuffer(const ImageBuffer&) const { return false; }
+ virtual void recordFontUse(Font&) { }
+ virtual void recordImageBufferUse(ImageBuffer&) { }
+ virtual RenderingMode renderingMode() const { return RenderingMode::Unaccelerated; }
+ };
+
+ WEBCORE_EXPORT void getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect) final;
+ WEBCORE_EXPORT void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) final;
+ void flushContext(GraphicsContextFlushIdentifier identifier) final { append<FlushContext>(identifier); }
+
+private:
+ // FIXME: Maybe remove this?
+ bool canDrawImageBuffer(const ImageBuffer&) const final;
+ RenderingMode renderingMode() const final;
+
+ void recordSave() final;
+ void recordRestore() final;
+ void recordTranslate(float x, float y) final;
+ void recordRotate(float angle) final;
+ void recordScale(const FloatSize&) final;
+ void recordSetCTM(const AffineTransform&) final;
+ void recordConcatenateCTM(const AffineTransform&) final;
+ void recordSetInlineFillColor(SRGBA<uint8_t>) final;
+ void recordSetInlineStrokeColor(SRGBA<uint8_t>) final;
+ void recordSetStrokeThickness(float) final;
+ void recordSetState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final;
+ void recordSetLineCap(LineCap) final;
+ void recordSetLineDash(const DashArray&, float dashOffset) final;
+ void recordSetLineJoin(LineJoin) final;
+ void recordSetMiterLimit(float) final;
+ void recordClearShadow() final;
+ void recordClip(const FloatRect&) final;
+ void recordClipOut(const FloatRect&) final;
+ void recordClipToImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destinationRect) final;
+ void recordClipOutToPath(const Path&) final;
+ void recordClipPath(const Path&, WindRule) final;
+ void recordBeginClipToDrawingCommands(const FloatRect& destination, DestinationColorSpace) final;
+ void recordEndClipToDrawingCommands(const FloatRect& destination) final;
+ void recordDrawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode) final;
+ void recordDrawImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
+ void recordDrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) final;
+ void recordDrawPattern(RenderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) final;
+ void recordBeginTransparencyLayer(float) final;
+ void recordEndTransparencyLayer() final;
+ void recordDrawRect(const FloatRect&, float) final;
+ void recordDrawLine(const FloatPoint& point1, const FloatPoint& point2) final;
+ void recordDrawLinesForText(const FloatPoint& blockLocation, const FloatSize& localAnchor, float thickness, const DashArray& widths, bool printing, bool doubleLines) final;
+ void recordDrawDotsForDocumentMarker(const FloatRect&, const DocumentMarkerLineStyle&) final;
+ void recordDrawEllipse(const FloatRect&) final;
+ void recordDrawPath(const Path&) final;
+ void recordDrawFocusRingPath(const Path&, float width, float offset, const Color&) final;
+ void recordDrawFocusRingRects(const Vector<FloatRect>&, float width, float offset, const Color&) final;
+ void recordFillRect(const FloatRect&) final;
+ void recordFillRectWithColor(const FloatRect&, const Color&) final;
+ void recordFillRectWithGradient(const FloatRect&, Gradient&) final;
+ void recordFillCompositedRect(const FloatRect&, const Color&, CompositeOperator, BlendMode) final;
+ void recordFillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode) final;
+ void recordFillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect&, const Color&) final;
+#if ENABLE(INLINE_PATH_DATA)
+ void recordFillLine(const LineData&) final;
+ void recordFillArc(const ArcData&) final;
+ void recordFillQuadCurve(const QuadCurveData&) final;
+ void recordFillBezierCurve(const BezierCurveData&) final;
+#endif
+ void recordFillPath(const Path&) final;
+ void recordFillEllipse(const FloatRect&) final;
+ void recordGetPixelBuffer(PixelBufferFormat outputFormat, const IntRect&) final;
+ void recordPutPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication) final;
+ void recordPaintFrameForMedia(MediaPlayer&, const FloatRect& destination) final;
+ void recordStrokeRect(const FloatRect&, float) final;
+#if ENABLE(INLINE_PATH_DATA)
+ void recordStrokeLine(const LineData&) final;
+ void recordStrokeArc(const ArcData&) final;
+ void recordStrokeQuadCurve(const QuadCurveData&) final;
+ void recordStrokeBezierCurve(const BezierCurveData&) final;
+#endif
+ void recordStrokePath(const Path&) final;
+ void recordStrokeEllipse(const FloatRect&) final;
+ void recordClearRect(const FloatRect&) final;
+#if USE(CG)
+ void recordApplyStrokePattern() final;
+ void recordApplyFillPattern() final;
+#endif
+ void recordApplyDeviceScaleFactor(float) final;
+
+ void recordResourceUse(NativeImage&) final;
+ void recordResourceUse(Font&) final;
+ void recordResourceUse(ImageBuffer&) final;
+
+ std::unique_ptr<GraphicsContext> createNestedContext(const FloatRect& initialClip, const AffineTransform& initialCTM) final;
+
+ template<typename T, class... Args>
+ void append(Args&&... args)
+ {
+ if (UNLIKELY(!canAppendItemOfType(T::itemType)))
+ return;
+
+ m_displayList.append<T>(std::forward<Args>(args)...);
+
+ if constexpr (T::isDrawingItem) {
+ if (LIKELY(!m_displayList.tracksDrawingItemExtents()))
+ return;
+
+ auto item = T(std::forward<Args>(args)...);
+ if (auto rect = item.localBounds(*this))
+ m_displayList.addDrawingItemExtent(extentFromLocalBounds(*rect));
+ else if (auto rect = item.globalBounds())
+ m_displayList.addDrawingItemExtent(*rect);
+ else
+ m_displayList.addDrawingItemExtent(std::nullopt);
+ }
+ }
+
+ FloatRect extentFromLocalBounds(const FloatRect&) const;
+ WEBCORE_EXPORT bool canAppendItemOfType(ItemType) const;
+
+ DisplayList& m_displayList;
+ Delegate* m_delegate { nullptr };
+ bool m_isNested { false };
+};
+
+}
+}
Modified: trunk/Source/WebKit/ChangeLog (283847 => 283848)
--- trunk/Source/WebKit/ChangeLog 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebKit/ChangeLog 2021-10-08 23:09:40 UTC (rev 283848)
@@ -1,3 +1,14 @@
+2021-10-08 Wenson Hsieh <[email protected]>
+
+ Split DisplayList::Recorder into an abstract base class and a concrete implementation
+ https://bugs.webkit.org/show_bug.cgi?id=231404
+
+ Reviewed by Myles Maxfield.
+
+ See WebCore/ChangeLog for more details.
+
+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
2021-10-08 Ben Nham <[email protected]>
Fix crash in NetworkProcess preconnect due to dereferencing deallocated session
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (283847 => 283848)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2021-10-08 23:09:40 UTC (rev 283848)
@@ -47,7 +47,7 @@
template<typename BackendType> class ThreadSafeRemoteImageBufferFlusher;
template<typename BackendType>
-class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public WebCore::DisplayList::Recorder::Delegate, public WebCore::DisplayList::ItemBufferWritingClient {
+class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendType>, public WebCore::DisplayList::RecorderImpl::Delegate, public WebCore::DisplayList::ItemBufferWritingClient {
using BaseDisplayListImageBuffer = WebCore::DisplayList::ImageBuffer<BackendType>;
using BaseDisplayListImageBuffer::m_backend;
using BaseDisplayListImageBuffer::m_drawingContext;
Modified: trunk/Tools/ChangeLog (283847 => 283848)
--- trunk/Tools/ChangeLog 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Tools/ChangeLog 2021-10-08 23:09:40 UTC (rev 283848)
@@ -1,3 +1,15 @@
+2021-10-08 Wenson Hsieh <[email protected]>
+
+ Split DisplayList::Recorder into an abstract base class and a concrete implementation
+ https://bugs.webkit.org/show_bug.cgi?id=231404
+
+ Reviewed by Myles Maxfield.
+
+ See WebCore/ChangeLog for more details.
+
+ * TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
+ (TestWebKitAPI::TEST):
+
2021-10-08 Jonathan Bedard <[email protected]>
[webkitscmpy] Allow caller to differentiate remote branches
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp (283847 => 283848)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-10-08 23:02:19 UTC (rev 283847)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-10-08 23:09:40 UTC (rev 283848)
@@ -32,7 +32,7 @@
#include <WebCore/DisplayList.h>
#include <WebCore/DisplayListItems.h>
#include <WebCore/DisplayListIterator.h>
-#include <WebCore/DisplayListRecorder.h>
+#include <WebCore/DisplayListRecorderImpl.h>
#include <WebCore/FontCascade.h>
#include <WebCore/GradientImage.h>
#include <WebCore/GraphicsContextCG.h>
@@ -55,7 +55,7 @@
GraphicsContextCG primaryContext(primaryCGContext.get());
InMemoryDisplayList displayList;
- Recorder secondaryContext(displayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
+ RecorderImpl secondaryContext(displayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);
@@ -91,10 +91,10 @@
TEST(BifurcatedGraphicsContextTests, TextInBifurcatedContext)
{
InMemoryDisplayList primaryDisplayList;
- Recorder primaryContext(primaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
+ RecorderImpl primaryContext(primaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
InMemoryDisplayList secondaryDisplayList;
- Recorder secondaryContext(secondaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
+ RecorderImpl secondaryContext(secondaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);