Changeset 230544 in webkit
- Timestamp:
- Apr 11, 2018 1:29:49 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230542 r230544 1 2018-04-11 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Cache glyphs (using display lists) when painting at high frequency 4 https://bugs.webkit.org/show_bug.cgi?id=178750 5 <rdar://problem/35201729> 6 7 Reviewed by Antti Koivisto. 8 9 This patch adds support for caching of glyph drawing commands when painting 10 at high frequency. Caching the glyph drawing will be done using DisplayLists. 11 12 GlyphDisplayListCache is basically a hash map which maps InlineTextBox 13 or SimpleLineLayout::Run to DisplayList. Before adding a new entry to it 14 we have to check whether the conditions for caching the glyph DisplayList 15 are met or not. If no entry is found for a given run, a new DisplayList 16 is created and a new entry is add to the cache. 17 18 * WebCore.xcodeproj/project.pbxproj: 19 * page/MemoryRelease.cpp: 20 (WebCore::releaseNoncriticalMemory): Make GlyphDisplayListCache respond 21 to memory pressure. 22 23 * platform/graphics/FontCascade.cpp: 24 (WebCore::FontCascade::displayListForTextRun const): 25 * platform/graphics/FontCascade.h: 26 (WebCore::FontCascade::displayListForTextRun): 27 Record the drawing of a glyph run into a DisplayList. 28 29 * rendering/GlyphDisplayListCache.h: Added. 30 (WebCore::GlyphDisplayListCache::singleton): 31 (WebCore::GlyphDisplayListCache::get): 32 (WebCore::GlyphDisplayListCache::remove): 33 (WebCore::GlyphDisplayListCache::clear): 34 (WebCore::GlyphDisplayListCache::size const): 35 (WebCore::GlyphDisplayListCache::sizeInBytes const): 36 A simple cache for the TextRun DisplayList. Adding a new entry in the 37 cache happens under restricted conditions. So this cache is not expected 38 to grow much. 39 40 * rendering/InlineTextBox.cpp: 41 (WebCore::InlineTextBox::~InlineTextBox): 42 (WebCore::InlineTextBox::paint): 43 (WebCore::InlineTextBox::paintMarkedTexts): 44 (WebCore::InlineTextBox::paintMarkedTextBackground): 45 (WebCore::InlineTextBox::paintMarkedTextForeground): 46 (WebCore::InlineTextBox::paintMarkedTextDecoration): 47 (WebCore::InlineTextBox::paintCompositionBackground): 48 (WebCore::InlineTextBox::paintCompositionUnderlines const): 49 (WebCore::InlineTextBox::paintCompositionUnderline const): 50 * rendering/InlineTextBox.h: 51 (WebCore::InlineTextBox::paintMarkedTexts): 52 InlineTextBox::paintMarkedTextForeground() now requires PaintInfo to know 53 whether the entry in the GlyphDisplayListCache should be removed or not. 54 Change all the GraphicsContext arguments to be PaintInfo. 55 56 * rendering/SimpleLineLayout.cpp: 57 (WebCore::SimpleLineLayout::Layout::~Layout): 58 * rendering/SimpleLineLayout.h: 59 * rendering/SimpleLineLayoutFunctions.cpp: 60 (WebCore::SimpleLineLayout::paintFlow): 61 (WebCore::SimpleLineLayout::simpleLineLayoutWillBeDeleted): 62 * rendering/SimpleLineLayoutFunctions.h: 63 * rendering/SimpleLineLayoutResolver.h: 64 (WebCore::SimpleLineLayout::RunResolver::Run::simpleRun const): 65 Implement the glyph caching for SimpleLineLayout::Run. 66 67 * rendering/TextPainter.cpp: 68 (WebCore::TextPainter::paintTextOrEmphasisMarks): If the DisplayList is 69 available, replay it back into the GraphicsContext. Make sure to reset to 70 the DisplayList pointer to nullptr after painting. 71 72 (WebCore::TextPainter::clearGlyphDisplayLists): 73 (WebCore::TextPainter::shouldUseGlyphDisplayList): Check whether we should 74 use DisplayList to the draw glyph run. 75 76 * rendering/TextPainter.h: 77 (WebCore::TextPainter::setGlyphDisplayListIfNeeded): Check whether we should 78 should use DisplayList to the draw glyph run and if we should, ensure first 79 the DisplayList is cached and set it in the TextPainter so it uses it when 80 the run is painted. 81 82 (WebCore::TextPainter::removeGlyphDisplayList): Remove the cached DisplayList 83 entry for a glyph layout run. 84 1 85 2018-04-11 Brent Fulgham <bfulgham@apple.com> 2 86 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r230368 r230544 8255 8255 5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; }; 8256 8256 5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; }; 8257 5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; }; 8257 8258 55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; }; 8258 8259 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBackingStore.h; sourceTree = "<group>"; }; … … 25479 25480 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */, 25480 25481 935C477409AC4D8D00A6AAB4 /* GapRects.h */, 25482 5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */, 25481 25483 E112F4701E3A85F200D6CDFD /* Grid.cpp */, 25482 25484 E112F46F1E3A85D800D6CDFD /* Grid.h */, -
trunk/Source/WebCore/page/MemoryRelease.cpp
r230211 r230544 47 47 #include "StyleScope.h" 48 48 #include "StyledElement.h" 49 #include "TextPainter.h" 49 50 #include "WorkerThread.h" 50 51 #include <wtf/FastMalloc.h> … … 65 66 66 67 clearWidthCaches(); 68 TextPainter::clearGlyphDisplayLists(); 67 69 68 70 for (auto* document : Document::allDocuments()) -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r224223 r230544 27 27 #include "CharacterProperties.h" 28 28 #include "ComplexTextController.h" 29 #include "DisplayListRecorder.h" 29 30 #include "FloatRect.h" 30 31 #include "FontCache.h" … … 306 307 } 307 308 309 std::unique_ptr<DisplayList::DisplayList> FontCascade::displayListForTextRun(GraphicsContext& context, const TextRun& run, unsigned from, std::optional<unsigned> to, CustomFontNotReadyAction customFontNotReadyAction) const 310 { 311 ASSERT(!context.paintingDisabled()); 312 unsigned destination = to.value_or(run.length()); 313 314 // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 315 CodePath codePathToUse = codePath(run); 316 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || destination != run.length())) 317 codePathToUse = Complex; 318 319 GlyphBuffer glyphBuffer; 320 float startX = glyphBufferForTextRun(codePathToUse, run, from, destination, glyphBuffer); 321 // We couldn't generate any glyphs for the run. Give up. 322 if (glyphBuffer.isEmpty()) 323 return nullptr; 324 325 std::unique_ptr<DisplayList::DisplayList> displayList = std::make_unique<DisplayList::DisplayList>(); 326 GraphicsContext recordingContext([&](GraphicsContext& displayListContext) { 327 return std::make_unique<DisplayList::Recorder>(displayListContext, *displayList, context.state(), FloatRect(), AffineTransform()); 328 }); 329 330 FloatPoint startPoint(startX, 0); 331 drawGlyphBuffer(recordingContext, glyphBuffer, startPoint, customFontNotReadyAction); 332 return displayList; 333 } 334 308 335 float FontCascade::widthOfTextRange(const TextRun& run, unsigned from, unsigned to, HashSet<const Font*>* fallbackFonts, float* outWidthBeforeRange, float* outWidthAfterRange) const 309 336 { -
trunk/Source/WebCore/platform/graphics/FontCascade.h
r224223 r230544 49 49 class TextRun; 50 50 51 namespace DisplayList { 52 class DisplayList; 53 } 54 51 55 struct GlyphData; 52 56 … … 198 202 WeakPtr<FontCascade> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<FontCascade*>(this)); } 199 203 204 std::unique_ptr<DisplayList::DisplayList> displayListForTextRun(GraphicsContext&, const TextRun&, unsigned from = 0, std::optional<unsigned> to = { }, CustomFontNotReadyAction = CustomFontNotReadyAction::DoNotPaintIfFontNotReady) const; 205 200 206 private: 201 207 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r230452 r230544 74 74 if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) 75 75 gTextBoxesWithOverflow->remove(this); 76 TextPainter::removeGlyphDisplayList(*this); 76 77 } 77 78 … … 504 505 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseTextClip && !isPrinting) { 505 506 if (containsComposition && !useCustomUnderlines) 506 paintCompositionBackground( context, boxOrigin);507 paintCompositionBackground(paintInfo, boxOrigin); 507 508 508 509 Vector<MarkedText> markedTexts = collectMarkedTextsForDocumentMarkers(TextPaintPhase::Background); … … 519 520 auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areBackgroundMarkedTextStylesEqual); 520 521 521 paintMarkedTexts( context, TextPaintPhase::Background, boxRect, coalescedStyledMarkedTexts);522 paintMarkedTexts(paintInfo, TextPaintPhase::Background, boxRect, coalescedStyledMarkedTexts); 522 523 } 523 524 … … 565 566 auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areForegroundMarkedTextStylesEqual); 566 567 567 paintMarkedTexts( context, TextPaintPhase::Foreground, boxRect, coalescedStyledMarkedTexts);568 paintMarkedTexts(paintInfo, TextPaintPhase::Foreground, boxRect, coalescedStyledMarkedTexts); 568 569 569 570 // Paint decorations … … 602 603 auto coalescedStyledMarkedTexts = coalesceAdjacentMarkedTexts(styledMarkedTexts, &MarkedTextStyle::areDecorationMarkedTextStylesEqual); 603 604 604 paintMarkedTexts( context, TextPaintPhase::Decoration, boxRect, coalescedStyledMarkedTexts, textDecorationSelectionClipOutRect);605 paintMarkedTexts(paintInfo, TextPaintPhase::Decoration, boxRect, coalescedStyledMarkedTexts, textDecorationSelectionClipOutRect); 605 606 } 606 607 … … 610 611 611 612 if (useCustomUnderlines) 612 paintCompositionUnderlines( context, boxOrigin);613 paintCompositionUnderlines(paintInfo, boxOrigin); 613 614 } 614 615 … … 944 945 } 945 946 946 void InlineTextBox::paintMarkedTexts( GraphicsContext& context, TextPaintPhase phase, const FloatRect& boxRect, const Vector<StyledMarkedText>& markedTexts, const FloatRect& decorationClipOutRect)947 void InlineTextBox::paintMarkedTexts(PaintInfo& paintInfo, TextPaintPhase phase, const FloatRect& boxRect, const Vector<StyledMarkedText>& markedTexts, const FloatRect& decorationClipOutRect) 947 948 { 948 949 switch (phase) { 949 950 case TextPaintPhase::Background: 950 951 for (auto& markedText : markedTexts) 951 paintMarkedTextBackground( context, boxRect.location(), markedText.style.backgroundColor, markedText.startOffset, markedText.endOffset);952 paintMarkedTextBackground(paintInfo, boxRect.location(), markedText.style.backgroundColor, markedText.startOffset, markedText.endOffset); 952 953 return; 953 954 case TextPaintPhase::Foreground: 954 955 for (auto& markedText : markedTexts) 955 paintMarkedTextForeground( context, boxRect, markedText);956 paintMarkedTextForeground(paintInfo, boxRect, markedText); 956 957 return; 957 958 case TextPaintPhase::Decoration: 958 959 for (auto& markedText : markedTexts) 959 paintMarkedTextDecoration( context, boxRect, decorationClipOutRect, markedText);960 return; 961 } 962 } 963 964 void InlineTextBox::paintMarkedTextBackground( GraphicsContext& context, const FloatPoint& boxOrigin, const Color& color, unsigned clampedStartOffset, unsigned clampedEndOffset)960 paintMarkedTextDecoration(paintInfo, boxRect, decorationClipOutRect, markedText); 961 return; 962 } 963 } 964 965 void InlineTextBox::paintMarkedTextBackground(PaintInfo& paintInfo, const FloatPoint& boxOrigin, const Color& color, unsigned clampedStartOffset, unsigned clampedEndOffset) 965 966 { 966 967 if (clampedStartOffset >= clampedEndOffset) 967 968 return; 968 969 970 GraphicsContext& context = paintInfo.context(); 969 971 GraphicsContextStateSaver stateSaver { context }; 970 972 updateGraphicsContext(context, TextPaintStyle { color }); // Don't draw text at all! … … 990 992 } 991 993 992 void InlineTextBox::paintMarkedTextForeground( GraphicsContext& context, const FloatRect& boxRect, const StyledMarkedText& markedText)994 void InlineTextBox::paintMarkedTextForeground(PaintInfo& paintInfo, const FloatRect& boxRect, const StyledMarkedText& markedText) 993 995 { 994 996 if (markedText.startOffset >= markedText.endOffset) 995 997 return; 996 998 999 GraphicsContext& context = paintInfo.context(); 997 1000 const FontCascade& font = lineFont(); 998 1001 const RenderStyle& lineStyle = this->lineStyle(); … … 1013 1016 textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, combinedText()); 1014 1017 1018 TextRun textRun = createTextRun(); 1019 textPainter.setGlyphDisplayListIfNeeded(*this, paintInfo, font, context, textRun); 1020 1015 1021 GraphicsContextStateSaver stateSaver { context, false }; 1016 1022 if (markedText.type == MarkedText::DraggedContent) { … … 1019 1025 } 1020 1026 // TextPainter wants the box rectangle and text origin of the entire line box. 1021 textPainter.paintRange( createTextRun(), boxRect, textOriginFromBoxRect(boxRect), markedText.startOffset, markedText.endOffset);1022 } 1023 1024 void InlineTextBox::paintMarkedTextDecoration( GraphicsContext& context, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText& markedText)1027 textPainter.paintRange(textRun, boxRect, textOriginFromBoxRect(boxRect), markedText.startOffset, markedText.endOffset); 1028 } 1029 1030 void InlineTextBox::paintMarkedTextDecoration(PaintInfo& paintInfo, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText& markedText) 1025 1031 { 1026 1032 if (m_truncation == cFullTruncation) 1027 1033 return; 1028 1034 1035 GraphicsContext& context = paintInfo.context(); 1029 1036 updateGraphicsContext(context, markedText.style.textStyles); 1030 1037 … … 1074 1081 } 1075 1082 1076 void InlineTextBox::paintCompositionBackground( GraphicsContext& context, const FloatPoint& boxOrigin)1077 { 1078 paintMarkedTextBackground( context, boxOrigin, Color::compositionFill, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd()));1079 } 1080 1081 void InlineTextBox::paintCompositionUnderlines( GraphicsContext& context, const FloatPoint& boxOrigin) const1083 void InlineTextBox::paintCompositionBackground(PaintInfo& paintInfo, const FloatPoint& boxOrigin) 1084 { 1085 paintMarkedTextBackground(paintInfo, boxOrigin, Color::compositionFill, clampedOffset(renderer().frame().editor().compositionStart()), clampedOffset(renderer().frame().editor().compositionEnd())); 1086 } 1087 1088 void InlineTextBox::paintCompositionUnderlines(PaintInfo& paintInfo, const FloatPoint& boxOrigin) const 1082 1089 { 1083 1090 if (m_truncation == cFullTruncation) … … 1096 1103 1097 1104 // Underline intersects this run. Paint it. 1098 paintCompositionUnderline( context, boxOrigin, underline);1105 paintCompositionUnderline(paintInfo, boxOrigin, underline); 1099 1106 1100 1107 if (underline.endOffset > end() + 1) … … 1110 1117 } 1111 1118 1112 void InlineTextBox::paintCompositionUnderline( GraphicsContext& context, const FloatPoint& boxOrigin, const CompositionUnderline& underline) const1119 void InlineTextBox::paintCompositionUnderline(PaintInfo& paintInfo, const FloatPoint& boxOrigin, const CompositionUnderline& underline) const 1113 1120 { 1114 1121 if (m_truncation == cFullTruncation) … … 1151 1158 width -= 2; 1152 1159 1160 GraphicsContext& context = paintInfo.context(); 1153 1161 context.setStrokeColor(underline.compositionUnderlineColor == CompositionUnderlineColor::TextColor ? renderer().style().visitedDependentColor(CSSPropertyWebkitTextFillColor) : underline.color); 1154 1162 context.setStrokeThickness(lineThickness); -
trunk/Source/WebCore/rendering/InlineTextBox.h
r230452 r230544 169 169 FloatPoint textOriginFromBoxRect(const FloatRect&) const; 170 170 171 void paintMarkedTexts( GraphicsContext&, TextPaintPhase, const FloatRect& boxRect, const Vector<StyledMarkedText>&, const FloatRect& decorationClipOutRect = { });171 void paintMarkedTexts(PaintInfo&, TextPaintPhase, const FloatRect& boxRect, const Vector<StyledMarkedText>&, const FloatRect& decorationClipOutRect = { }); 172 172 173 173 void paintPlatformDocumentMarker(GraphicsContext&, const FloatPoint& boxOrigin, const MarkedText&); 174 174 void paintPlatformDocumentMarkers(GraphicsContext&, const FloatPoint& boxOrigin); 175 175 176 void paintCompositionBackground( GraphicsContext&, const FloatPoint& boxOrigin);177 void paintCompositionUnderlines( GraphicsContext&, const FloatPoint& boxOrigin) const;178 void paintCompositionUnderline( GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&) const;179 180 void paintMarkedTextBackground( GraphicsContext&, const FloatPoint& boxOrigin, const Color&, unsigned clampedStartOffset, unsigned clampedEndOffset);181 void paintMarkedTextForeground( GraphicsContext&, const FloatRect& boxRect, const StyledMarkedText&);182 void paintMarkedTextDecoration( GraphicsContext&, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText&);176 void paintCompositionBackground(PaintInfo&, const FloatPoint& boxOrigin); 177 void paintCompositionUnderlines(PaintInfo&, const FloatPoint& boxOrigin) const; 178 void paintCompositionUnderline(PaintInfo&, const FloatPoint& boxOrigin, const CompositionUnderline&) const; 179 180 void paintMarkedTextBackground(PaintInfo&, const FloatPoint& boxOrigin, const Color&, unsigned clampedStartOffset, unsigned clampedEndOffset); 181 void paintMarkedTextForeground(PaintInfo&, const FloatRect& boxRect, const StyledMarkedText&); 182 void paintMarkedTextDecoration(PaintInfo&, const FloatRect& boxRect, const FloatRect& clipOutRect, const StyledMarkedText&); 183 183 184 184 const RenderCombineText* combinedText() const; -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r230452 r230544 979 979 } 980 980 981 } 982 } 981 Layout::~Layout() 982 { 983 simpleLineLayoutWillBeDeleted(*this); 984 } 985 986 } 987 } -
trunk/Source/WebCore/rendering/SimpleLineLayout.h
r213009 r230544 82 82 static std::unique_ptr<Layout> create(const RunVector&, unsigned lineCount); 83 83 84 ~Layout(); 85 84 86 unsigned lineCount() const { return m_lineCount; } 85 87 -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
r226138 r230544 121 121 textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize()); 122 122 FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(run.baselinePosition() + paintOffset.y(), deviceScaleFactor) }; 123 124 textPainter.setGlyphDisplayListIfNeeded(run.simpleRun(), paintInfo, style.fontCascade(), paintInfo.context(), textRun); 123 125 textPainter.paint(textRun, rect, textOrigin); 124 126 if (textDecorationPainter) { … … 262 264 } 263 265 266 void simpleLineLayoutWillBeDeleted(const Layout& layout) 267 { 268 for (unsigned i = 0; i < layout.runCount(); ++i) 269 TextPainter::removeGlyphDisplayList(layout.runAt(i)); 270 } 271 264 272 #if ENABLE(TREE_DEBUGGING) 265 273 static void printPrefix(TextStream& stream, int& printedCharacters, int depth) -
trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h
r225117 r230544 66 66 67 67 const RenderObject& rendererForPosition(const FlowContents&, unsigned); 68 69 void simpleLineLayoutWillBeDeleted(const Layout&); 68 70 69 71 #if ENABLE(TREE_DEBUGGING) -
trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h
r218793 r230544 57 57 bool isEndOfLine() const; 58 58 bool hasHyphen() const { return m_iterator.simpleRun().hasHyphen; } 59 const SimpleLineLayout::Run& simpleRun() const { return m_iterator.simpleRun(); } 59 60 60 61 unsigned lineIndex() const; -
trunk/Source/WebCore/rendering/TextPainter.cpp
r226138 r230544 24 24 #include "TextPainter.h" 25 25 26 #include "DisplayListReplayer.h" 26 27 #include "GraphicsContext.h" 27 28 #include "InlineTextBox.h" 28 29 #include "RenderCombineText.h" 30 #include "RenderLayer.h" 29 31 #include "ShadowData.h" 30 32 #include <wtf/NeverDestroyed.h> … … 99 101 { 100 102 ASSERT(startOffset < endOffset); 101 if (emphasisMark.isEmpty()) 103 if (!emphasisMark.isEmpty()) 104 m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + FloatSize(0, emphasisMarkOffset), startOffset, endOffset); 105 else if (startOffset || endOffset < textRun.length() || !m_glyphDisplayList) 102 106 m_context.drawText(font, textRun, textOrigin, startOffset, endOffset); 103 else 104 m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + FloatSize(0, emphasisMarkOffset), startOffset, endOffset); 107 else { 108 // Replaying back a whole cached glyph run to the GraphicsContext. 109 m_context.translate(textOrigin); 110 DisplayList::Replayer replayer(m_context, *m_glyphDisplayList); 111 replayer.replay(); 112 m_context.translate(-textOrigin); 113 } 114 m_glyphDisplayList = nullptr; 105 115 } 106 116 … … 196 206 } 197 207 208 void TextPainter::clearGlyphDisplayLists() 209 { 210 GlyphDisplayListCache<InlineTextBox>::singleton().clear(); 211 GlyphDisplayListCache<SimpleLineLayout::Run>::singleton().clear(); 212 } 213 214 bool TextPainter::shouldUseGlyphDisplayList(const PaintInfo& paintInfo) 215 { 216 return !paintInfo.context().paintingDisabled() && paintInfo.enclosingSelfPaintingLayer() && paintInfo.enclosingSelfPaintingLayer()->paintingFrequently(); 217 } 218 198 219 } // namespace WebCore -
trunk/Source/WebCore/rendering/TextPainter.h
r226138 r230544 25 25 #include "AffineTransform.h" 26 26 #include "FloatRect.h" 27 #include "GlyphDisplayListCache.h" 27 28 #include "TextFlags.h" 28 29 #include "TextPaintStyle.h" … … 59 60 void paintRange(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end); 60 61 62 template<typename LayoutRun> 63 void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const FontCascade& font, GraphicsContext& context, const TextRun& textRun) 64 { 65 if (!TextPainter::shouldUseGlyphDisplayList(paintInfo)) 66 TextPainter::removeGlyphDisplayList(run); 67 else 68 m_glyphDisplayList = GlyphDisplayListCache<LayoutRun>::singleton().get(run, font, context, textRun); 69 } 70 71 template<typename LayoutRun> 72 static void removeGlyphDisplayList(const LayoutRun& run) { GlyphDisplayListCache<LayoutRun>::singleton().remove(run); } 73 74 static void clearGlyphDisplayLists(); 75 static bool shouldUseGlyphDisplayList(const PaintInfo&); 76 61 77 private: 62 78 void paintTextOrEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& emphasisMark, float emphasisMarkOffset, … … 75 91 float m_emphasisMarkOffset { 0 }; 76 92 bool m_textBoxIsHorizontal { true }; 93 DisplayList::DisplayList* m_glyphDisplayList { nullptr }; 77 94 }; 78 95
Note: See TracChangeset
for help on using the changeset viewer.