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

Unified Diff: cc/font_atlas.cc

Issue 11272042: improvements of the FPS counter in the HUDLayer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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
Index: cc/font_atlas.cc
diff --git a/cc/font_atlas.cc b/cc/font_atlas.cc
index 0b483c9bb04c4e35940d29fa81b6452d7333f2a9..7bae07b2d19a62733f82d55cfde70b5cf466eb52 100644
--- a/cc/font_atlas.cc
+++ b/cc/font_atlas.cc
@@ -60,6 +60,25 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint
}
}
+IntSize FontAtlas::textSize(const std::string& text)
egraether 2012/10/26 00:06:52 This new method calculates the screen text size of
+{
+ int maxWidth = 0;
+ std::vector<std::string> lines;
+ base::SplitString(text, '\n', &lines);
+
+ for (size_t i = 0; i < lines.size(); ++i) {
+ int lineWidth = 0;
+ for (size_t j = 0; j < lines[i].size(); ++j) {
+ int asciiIndex = (lines[i][j] < 128) ? lines[i][j] : 0;
+ lineWidth += m_asciiToRectTable[asciiIndex].width();
+ }
+ if (lineWidth > maxWidth)
+ maxWidth = lineWidth;
+ }
+
+ return IntSize(maxWidth, m_fontHeight * lines.size());
+}
+
void FontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPosition) const
{
DCHECK(Proxy::isImplThread());
« no previous file with comments | « cc/font_atlas.h ('k') | cc/frame_rate_counter.h » ('j') | cc/frame_rate_counter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698