Changeset 283273 in webkit
- Timestamp:
- Sep 29, 2021, 4:04:52 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/DrawGlyphsRecorder.h (modified) (3 diffs)
-
platform/graphics/GraphicsContext.h (modified) (2 diffs)
-
platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp (modified) (6 diffs)
-
platform/graphics/displaylists/DisplayListRecorder.cpp (modified) (2 diffs)
-
platform/graphics/displaylists/DisplayListRecorder.h (modified) (3 diffs)
-
platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp (modified) (3 diffs)
-
platform/graphics/win/DrawGlyphsRecorderWin.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r283271 r283273 1 2021-09-29 Devin Rousso <drousso@apple.com> 2 3 Allow `DrawGlyphsRecorder` to be used with any `GraphicsContext` instead of just `DisplayList::Recorder` 4 https://bugs.webkit.org/show_bug.cgi?id=230913 5 6 Reviewed by Myles Maxfield. 7 8 There's really nothing about `DrawGlyphsRecorder` that's specific to display lists other 9 than it's currently only being used by `DisplayList::Recorder`. 10 11 This patch replaces `DisplayList::Recorder` with `GraphicsContext` in `DrawGlyphsRecorder`. 12 It also requires that new methods be added to `GraphicsContext` that are overridden by 13 `DisplayList::Recorder`. This is being done to make `<attachment>` drawing work in the 14 GPUProcess (<https://webkit.org/b/230781>). 15 16 * platform/graphics/DrawGlyphsRecorder.h: 17 * platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp: 18 (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder): 19 (WebCore::DrawGlyphsRecorder::populateInternalState): 20 (WebCore::DrawGlyphsRecorder::prepareInternalContext): 21 (WebCore::DrawGlyphsRecorder::recordDrawGlyphs): 22 (WebCore::DrawGlyphsRecorder::drawGlyphs): 23 * platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp: 24 (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder): 25 (WebCore::DrawGlyphsRecorder::drawGlyphs): 26 * platform/graphics/win/DrawGlyphsRecorderWin.cpp: 27 (WebCore::DrawGlyphsRecorder::DrawGlyphsRecorder): 28 (WebCore::DrawGlyphsRecorder::drawGlyphs): 29 30 * platform/graphics/GraphicsContext.h: 31 (WebCore::GraphicsContext::drawGlyphsAndCacheFont): Added. 32 * platform/graphics/displaylists/DisplayListRecorder.h: 33 * platform/graphics/displaylists/DisplayListRecorder.cpp: 34 (WebCore::DisplayList::Recorder::state const): Added. 35 (WebCore::DisplayList::Recorder::drawGlyphsAndCacheFont): Renamed from `appendDrawGlyphsItemWithCachedFont`. 36 AFAICT it seems like the `m_state` in `GraphicsContext` has the same values (but is a 37 different object) as the `currentState().stateChange.m_state` in `DisplayList::Recorder`. 38 Many of the non-overriden methods on `GraphicsContext` (e.g. `setStrokeColor`) both modify 39 the `m_state` and call `updateState`, which `DisplayList::Recorder` uses to modify its 40 `currentState().stateChange.m_state`. As such, we should be able to expose it as an override 41 for the `state` "getter" so that `DrawGlyphsRecorder` is able to access the current state in 42 a `GraphicsContext`-subclass agnostic way. 43 1 44 2021-09-29 Sihui Liu <sihui_liu@apple.com> 2 45 -
trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h
r283199 r283273 46 46 class GraphicsContext; 47 47 48 namespace DisplayList {49 class Recorder;50 }51 52 48 class DrawGlyphsRecorder { 53 49 public: … … 56 52 DontDeconstruct 57 53 }; 58 explicit DrawGlyphsRecorder( DisplayList::Recorder&, DrawGlyphsDeconstruction);54 explicit DrawGlyphsRecorder(GraphicsContext&, DrawGlyphsDeconstruction); 59 55 60 56 void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode); … … 93 89 #endif 94 90 95 DisplayList::Recorder& m_owner;91 GraphicsContext& m_owner; 96 92 DrawGlyphsDeconstruction m_drawGlyphsDeconstruction; 97 93 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r282723 r283273 354 354 #endif 355 355 356 const GraphicsContextState& state() const { return m_state; }356 virtual const GraphicsContextState& state() const { return m_state; } 357 357 358 358 virtual void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) = 0; … … 470 470 WEBCORE_EXPORT virtual void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from = 0, std::optional<unsigned> to = std::nullopt); 471 471 WEBCORE_EXPORT virtual void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady); 472 473 virtual void drawGlyphsAndCacheFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothingMode) 474 { 475 drawGlyphs(font, glyphs, advances, numGlyphs, point, fontSmoothingMode); 476 } 472 477 473 478 WEBCORE_EXPORT FloatRect computeUnderlineBoundsForText(const FloatRect&, bool printing); -
trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp
r283199 r283273 29 29 #include "BitmapImage.h" 30 30 #include "Color.h" 31 #include "DisplayListItems.h"32 #include "DisplayListRecorder.h"33 31 #include "FloatPoint.h" 34 32 #include "Font.h" … … 87 85 } 88 86 89 DrawGlyphsRecorder::DrawGlyphsRecorder( DisplayList::Recorder& owner, DrawGlyphsDeconstruction drawGlyphsDeconstruction)87 DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, DrawGlyphsDeconstruction drawGlyphsDeconstruction) 90 88 : m_owner(owner) 91 89 , m_drawGlyphsDeconstruction(drawGlyphsDeconstruction) … … 106 104 m_originalState.strokeStyle.pattern = contextState.strokePattern; 107 105 108 m_originalState.ctm = m_owner. currentState().ctm; // FIXME: Deal with base CTM.106 m_originalState.ctm = m_owner.getCTM(); // FIXME: Deal with base CTM. 109 107 110 108 m_originalState.shadow.offset = contextState.shadowOffset; … … 157 155 m_originalTextMatrix = computeVerticalTextMatrix(font, m_originalTextMatrix); 158 156 159 auto& contextState = m_owner. currentState().stateChange.m_state;157 auto& contextState = m_owner.state(); 160 158 populateInternalState(contextState); 161 159 populateInternalContext(contextState); … … 336 334 updateShadow(CGGStateGetStyle(gstate)); 337 335 338 m_owner. appendDrawGlyphsItemWithCachedFont(*m_originalFont, glyphs, computeAdvancesFromPositions(positions, count, currentTextMatrix).data(), count, currentTextMatrix.mapPoint(positions[0]), m_smoothingMode);336 m_owner.drawGlyphsAndCacheFont(*m_originalFont, glyphs, computeAdvancesFromPositions(positions, count, currentTextMatrix).data(), count, currentTextMatrix.mapPoint(positions[0]), m_smoothingMode); 339 337 340 338 m_owner.concatCTM(inverseCTMFixup); … … 414 412 { 415 413 if (m_drawGlyphsDeconstruction == DrawGlyphsDeconstruction::DontDeconstruct) { 416 m_owner. appendDrawGlyphsItemWithCachedFont(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);414 m_owner.drawGlyphsAndCacheFont(font, glyphs, advances, numGlyphs, startPoint, smoothingMode); 417 415 return; 418 416 } -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
r280401 r283273 151 151 } 152 152 153 const GraphicsContextState& Recorder::state() const 154 { 155 return currentState().stateChange.m_state; 156 } 157 153 158 void Recorder::updateState(const GraphicsContextState& state, GraphicsContextState::StateChangeFlags flags) 154 159 { … … 191 196 } 192 197 193 void Recorder:: appendDrawGlyphsItemWithCachedFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode)198 void Recorder::drawGlyphsAndCacheFont(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode smoothingMode) 194 199 { 195 200 if (m_delegate) -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
r283199 r283273 78 78 79 79 private: 80 friend class WebCore::DrawGlyphsRecorder;81 80 Recorder(Recorder& parent, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform& initialCTM); 82 81 … … 95 94 void fillRoundedRectImpl(const FloatRoundedRect&, const Color&) final { ASSERT_NOT_REACHED(); } 96 95 void drawLineForText(const FloatRect&, bool, bool, StrokeStyle) final { ASSERT_NOT_REACHED(); } 96 97 const GraphicsContextState& state() const final; 97 98 98 99 void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags) final; … … 122 123 123 124 void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode) final; 124 125 void appendDrawGlyphsItemWithCachedFont(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode); 125 void drawGlyphsAndCacheFont(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned count, const FloatPoint& localAnchor, FontSmoothingMode); 126 126 127 127 void drawImageBuffer(WebCore::ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) final; -
trunk/Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp
r283199 r283273 27 27 #include "DrawGlyphsRecorder.h" 28 28 29 #include "DisplayListItems.h"30 #include "DisplayListRecorder.h"31 29 #include "FloatPoint.h" 32 30 #include "Font.h" … … 35 33 namespace WebCore { 36 34 37 DrawGlyphsRecorder::DrawGlyphsRecorder( DisplayList::Recorder& owner, DrawGlyphsDeconstruction)35 DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, DrawGlyphsDeconstruction) 38 36 : m_owner(owner) 39 37 { … … 42 40 void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) 43 41 { 44 m_owner. appendDrawGlyphsItemWithCachedFont(font, glyphs, advances, numGlyphs, startPoint, smoothingMode);42 m_owner.drawGlyphsAndCacheFont(font, glyphs, advances, numGlyphs, startPoint, smoothingMode); 45 43 } 46 44 -
trunk/Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp
r283199 r283273 27 27 #include "DrawGlyphsRecorder.h" 28 28 29 #include "DisplayListItems.h"30 #include "DisplayListRecorder.h"31 29 #include "FloatPoint.h" 32 30 #include "Font.h" … … 35 33 namespace WebCore { 36 34 37 DrawGlyphsRecorder::DrawGlyphsRecorder( DisplayList::Recorder& owner, DrawGlyphsDeconstruction)35 DrawGlyphsRecorder::DrawGlyphsRecorder(GraphicsContext& owner, DrawGlyphsDeconstruction) 38 36 : m_owner(owner) 39 37 { … … 42 40 void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) 43 41 { 44 m_owner. appendDrawGlyphsItemWithCachedFont(font, glyphs, advances, numGlyphs, startPoint, m_smoothingMode);42 m_owner.drawGlyphsAndCacheFont(font, glyphs, advances, numGlyphs, startPoint, m_smoothingMode); 45 43 } 46 44
Note:
See TracChangeset
for help on using the changeset viewer.