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

Side by Side Diff: cc/font_atlas.cc

Issue 11048044: cc: Switch to Chromium DCHECKs and LOGs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCFontAtlas.h" 7 #include "CCFontAtlas.h"
8 8
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
(...skipping 12 matching lines...) Expand all
23 for (size_t i = 0; i < 128; ++i) 23 for (size_t i = 0; i < 128; ++i)
24 m_asciiToRectTable[i] = asciiToRectTable[i]; 24 m_asciiToRectTable[i] = asciiToRectTable[i];
25 } 25 }
26 26
27 CCFontAtlas::~CCFontAtlas() 27 CCFontAtlas::~CCFontAtlas()
28 { 28 {
29 } 29 }
30 30
31 void CCFontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::st ring& text, const gfx::Point& destPosition, const IntSize& clip) const 31 void CCFontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::st ring& text, const gfx::Point& destPosition, const IntSize& clip) const
32 { 32 {
33 ASSERT(CCProxy::isImplThread()); 33 CC_DCHECK(CCProxy::isImplThread());
34 34
35 std::vector<std::string> lines; 35 std::vector<std::string> lines;
36 base::SplitString(text, '\n', &lines); 36 base::SplitString(text, '\n', &lines);
37 37
38 gfx::Point position = destPosition; 38 gfx::Point position = destPosition;
39 for (size_t i = 0; i < lines.size(); ++i) { 39 for (size_t i = 0; i < lines.size(); ++i) {
40 drawOneLineOfTextInternal(canvas, paint, lines[i], position); 40 drawOneLineOfTextInternal(canvas, paint, lines[i], position);
41 position.set_y(position.y() + m_fontHeight); 41 position.set_y(position.y() + m_fontHeight);
42 if (position.y() > clip.height()) 42 if (position.y() > clip.height())
43 return; 43 return;
44 } 44 }
45 } 45 }
46 46
47 void CCFontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& pai nt, const std::string& textLine, const gfx::Point& destPosition) const 47 void CCFontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& pai nt, const std::string& textLine, const gfx::Point& destPosition) const
48 { 48 {
49 ASSERT(CCProxy::isImplThread()); 49 CC_DCHECK(CCProxy::isImplThread());
50 50
51 gfx::Point position = destPosition; 51 gfx::Point position = destPosition;
52 for (unsigned i = 0; i < textLine.length(); ++i) { 52 for (unsigned i = 0; i < textLine.length(); ++i) {
53 // If the ASCII code is out of bounds, then index 0 is used, which is ju st a plain rectangle glyph. 53 // If the ASCII code is out of bounds, then index 0 is used, which is ju st a plain rectangle glyph.
54 int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0; 54 int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0;
55 IntRect glyphBounds = m_asciiToRectTable[asciiIndex]; 55 IntRect glyphBounds = m_asciiToRectTable[asciiIndex];
56 SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), gly phBounds.width(), glyphBounds.height()); 56 SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), gly phBounds.width(), glyphBounds.height());
57 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint); 57 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint);
58 position.set_x(position.x() + glyphBounds.width()); 58 position.set_x(position.x() + glyphBounds.width());
59 } 59 }
60 } 60 }
61 61
62 void CCFontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPositio n) const 62 void CCFontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPositio n) const
63 { 63 {
64 ASSERT(CCProxy::isImplThread()); 64 CC_DCHECK(CCProxy::isImplThread());
65 65
66 SkIRect source = SkIRect::MakeWH(m_atlas.width(), m_atlas.height()); 66 SkIRect source = SkIRect::MakeWH(m_atlas.width(), m_atlas.height());
67 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(destPosition.x(), destPosition.y(), m_atlas.width(), m_atlas.height())); 67 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(destPosition.x(), destPosition.y(), m_atlas.width(), m_atlas.height()));
68 } 68 }
69 69
70 } // namespace cc 70 } // namespace cc
OLDNEW
« no previous file with comments | « cc/draw_quad.cc ('k') | cc/frame_rate_controller.cc » ('j') | cc/yuv_video_draw_quad.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698