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

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: updated patch, isBadFrameInterval fix, adapted graph drawing range 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 d8294da8276076af6c7872eccb2b1d2cf6babe4a..8449e9a42e3b2ee6f8ae1ff1a41e2345b3b7aec4 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)
+{
+ 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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698