Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: Source/core/rendering/InlineTextBox.cpp

Issue 554613004: TextBlob: Start caching a text blob per InlineTextBox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: turn off runtime-enabled feature for landing Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/InlineTextBox.h ('k') | Source/core/rendering/TextPainter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/InlineTextBox.cpp
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp
index 91f2688aadb9da8f7aeb5cd44ddddbf48df2953c..45109ad800319d378424a5656e10dc82da562489 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -72,6 +72,9 @@ COMPILE_ASSERT(sizeof(InlineTextBox) == sizeof(SameSizeAsInlineTextBox), InlineT
typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap;
static InlineTextBoxOverflowMap* gTextBoxesWithOverflow;
+typedef WTF::HashMap<const InlineTextBox*, TextBlobPtr> InlineTextBoxBlobCacheMap;
+static InlineTextBoxBlobCacheMap* gTextBlobCache;
+
static const int misspellingLineThickness = 3;
void InlineTextBox::destroy()
@@ -80,11 +83,17 @@ void InlineTextBox::destroy()
if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow)
gTextBoxesWithOverflow->remove(this);
+ if (gTextBlobCache)
+ gTextBlobCache->remove(this);
InlineBox::destroy();
}
void InlineTextBox::markDirty()
{
+ // FIXME: Is it actually possible to try and paint a dirty InlineTextBox?
+ if (gTextBlobCache)
+ gTextBlobCache->remove(this);
+
m_len = 0;
m_start = 0;
InlineBox::markDirty();
@@ -589,7 +598,18 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
startOffset = selectionEnd;
endOffset = selectionStart;
}
- textPainter.paint(startOffset, endOffset, length, textStyle);
+
+ // FIXME: This cache should probably ultimately be held somewhere else.
+ // A hashmap is convenient to avoid a memory hit when the
+ // RuntimeEnabledFeature is off.
+ bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && startOffset == 0 && endOffset == length;
+ TextBlobPtr* cachedTextBlob = 0;
+ if (textBlobIsCacheable) {
+ if (!gTextBlobCache)
+ gTextBlobCache = new InlineTextBoxBlobCacheMap;
+ cachedTextBlob = &gTextBlobCache->add(this, nullptr).storedValue->value;
+ }
+ textPainter.paint(startOffset, endOffset, length, textStyle, cachedTextBlob);
}
if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart < selectionEnd) {
« no previous file with comments | « Source/core/rendering/InlineTextBox.h ('k') | Source/core/rendering/TextPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698