Title: [277075] trunk/Source/WebCore
- Revision
- 277075
- Author
- [email protected]
- Date
- 2021-05-06 01:52:52 -0700 (Thu, 06 May 2021)
Log Message
Split context state change item appending out of DisplayList::Recorder::canAppendItemOfType.
https://bugs.webkit.org/show_bug.cgi?id=225424
Reviewed by Simon Fraser.
It's non-obvious from the name that canAppendItemOfType can also end
up appending an item. So let's split out the context state change
item out into a separate function.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::canAppendItemOfType):
(WebCore::DisplayList::Recorder::appendStateChangeItemIfNecessary):
Added.
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::append):
(WebCore::DisplayList::Recorder::itemNeedsState): Added this as a
constexpr helper function, to ensure we make a decision about needing
to call appendStateChangeItemIfNecessary at compile time.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (277074 => 277075)
--- trunk/Source/WebCore/ChangeLog 2021-05-06 08:40:38 UTC (rev 277074)
+++ trunk/Source/WebCore/ChangeLog 2021-05-06 08:52:52 UTC (rev 277075)
@@ -1,5 +1,26 @@
2021-05-06 Cameron McCormack <[email protected]>
+ Split context state change item appending out of DisplayList::Recorder::canAppendItemOfType.
+ https://bugs.webkit.org/show_bug.cgi?id=225424
+
+ Reviewed by Simon Fraser.
+
+ It's non-obvious from the name that canAppendItemOfType can also end
+ up appending an item. So let's split out the context state change
+ item out into a separate function.
+
+ * platform/graphics/displaylists/DisplayListRecorder.cpp:
+ (WebCore::DisplayList::Recorder::canAppendItemOfType):
+ (WebCore::DisplayList::Recorder::appendStateChangeItemIfNecessary):
+ Added.
+ * platform/graphics/displaylists/DisplayListRecorder.h:
+ (WebCore::DisplayList::Recorder::append):
+ (WebCore::DisplayList::Recorder::itemNeedsState): Added this as a
+ constexpr helper function, to ensure we make a decision about needing
+ to call appendStateChangeItemIfNecessary at compile time.
+
+2021-05-06 Cameron McCormack <[email protected]>
+
Make DisplayList::dump print out the display list contents
https://bugs.webkit.org/show_bug.cgi?id=225431
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (277074 => 277075)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-05-06 08:40:38 UTC (rev 277074)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2021-05-06 08:52:52 UTC (rev 277075)
@@ -121,27 +121,22 @@
append<SetInlineFillGradient>(*changes.m_state.fillGradient, changes.m_state.fillGradientSpaceTransform);
}
-bool Recorder::canAppendItemOfType(ItemType type)
+bool Recorder::canAppendItemOfType(ItemType type) const
{
- if (m_delegate && !m_delegate->canAppendItemOfType(type))
- return false;
+ return !m_delegate || m_delegate->canAppendItemOfType(type);
+}
- if (isDrawingItem(type)
-#if USE(CG)
- || type == ItemType::ApplyFillPattern || type == ItemType::ApplyStrokePattern
-#endif
- ) {
- GraphicsContextStateChange& stateChanges = currentState().stateChange;
- GraphicsContextState::StateChangeFlags changesFromLastState = stateChanges.changesFromState(currentState().lastDrawingState);
- if (changesFromLastState) {
- LOG_WITH_STREAM(DisplayLists, stream << "pre-drawing, saving state " << GraphicsContextStateChange(stateChanges.m_state, changesFromLastState));
- appendStateChangeItem(stateChanges, changesFromLastState);
- stateChanges.m_changeFlags = { };
- currentState().lastDrawingState = stateChanges.m_state;
- }
- }
+void Recorder::appendStateChangeItemIfNecessary()
+{
+ auto& stateChanges = currentState().stateChange;
+ auto changesFromLastState = stateChanges.changesFromState(currentState().lastDrawingState);
+ if (!changesFromLastState)
+ return;
- return true;
+ LOG_WITH_STREAM(DisplayLists, stream << "pre-drawing, saving state " << GraphicsContextStateChange(stateChanges.m_state, changesFromLastState));
+ appendStateChangeItem(stateChanges, changesFromLastState);
+ stateChanges.m_changeFlags = { };
+ currentState().lastDrawingState = stateChanges.m_state;
}
void Recorder::updateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags)
Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (277074 => 277075)
--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-05-06 08:40:38 UTC (rev 277074)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h 2021-05-06 08:52:52 UTC (rev 277075)
@@ -160,6 +160,9 @@
if (UNLIKELY(!canAppendItemOfType(T::itemType)))
return;
+ if constexpr (itemNeedsState<T>())
+ appendStateChangeItemIfNecessary();
+
m_displayList.append<T>(std::forward<Args>(args)...);
if constexpr (T::isDrawingItem) {
@@ -176,10 +179,14 @@
}
}
- WEBCORE_EXPORT bool canAppendItemOfType(ItemType);
+ WEBCORE_EXPORT bool canAppendItemOfType(ItemType) const;
+ template<typename T>
+ static constexpr bool itemNeedsState();
+
void cacheNativeImage(NativeImage&);
+ void appendStateChangeItemIfNecessary();
void appendStateChangeItem(const GraphicsContextStateChange&, GraphicsContextState::StateChangeFlags);
FloatRect extentFromLocalBounds(const FloatRect&) const;
@@ -232,6 +239,20 @@
DrawGlyphsRecorder m_drawGlyphsRecorder;
};
+template<typename T>
+constexpr bool Recorder::itemNeedsState()
+{
+ if (T::isDrawingItem)
+ return true;
+
+#if USE(CG)
+ if (T::itemType == ItemType::ApplyFillPattern || T::itemType == ItemType::ApplyStrokePattern)
+ return true;
+#endif
+
+ return false;
}
+
}
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes