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

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: Rebase to 165943 Created 8 years, 1 month 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 | « cc/font_atlas.h ('k') | cc/frame_rate_counter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/font_atlas.cc
diff --git a/cc/font_atlas.cc b/cc/font_atlas.cc
index 2d157663b22005047e8bd872bf98cd818dd81eaa..099e7f0d5819c0e774783d40e883b869fe08c8d9 100644
--- a/cc/font_atlas.cc
+++ b/cc/font_atlas.cc
@@ -57,6 +57,25 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint
}
}
+gfx::Size 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 gfx::Size(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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698