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

Side by Side Diff: cc/font_atlas.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests 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 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 <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 for (size_t i = 0; i < 128; ++i) 24 for (size_t i = 0; i < 128; ++i)
25 m_asciiToRectTable[i] = asciiToRectTable[i]; 25 m_asciiToRectTable[i] = asciiToRectTable[i];
26 } 26 }
27 27
28 FontAtlas::~FontAtlas() 28 FontAtlas::~FontAtlas()
29 { 29 {
30 } 30 }
31 31
32 void FontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::stri ng& text, const gfx::Point& destPosition, const IntSize& clip) const 32 void FontAtlas::drawText(SkCanvas* canvas, const SkPaint& paint, const std::stri ng& text, const gfx::Point& destPosition, const IntSize& clip) const
33 { 33 {
34 DCHECK(Proxy::isImplThread()); 34 DCHECK(m_threadChecker.CalledOnValidThread());
35 35
36 std::vector<std::string> lines; 36 std::vector<std::string> lines;
37 base::SplitString(text, '\n', &lines); 37 base::SplitString(text, '\n', &lines);
38 38
39 gfx::Point position = destPosition; 39 gfx::Point position = destPosition;
40 for (size_t i = 0; i < lines.size(); ++i) { 40 for (size_t i = 0; i < lines.size(); ++i) {
41 drawOneLineOfTextInternal(canvas, paint, lines[i], position); 41 drawOneLineOfTextInternal(canvas, paint, lines[i], position);
42 position.set_y(position.y() + m_fontHeight); 42 position.set_y(position.y() + m_fontHeight);
43 if (position.y() > clip.height()) 43 if (position.y() > clip.height())
44 return; 44 return;
45 } 45 }
46 } 46 }
47 47
48 void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint , const std::string& textLine, const gfx::Point& destPosition) const 48 void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint , const std::string& textLine, const gfx::Point& destPosition) const
49 { 49 {
50 DCHECK(Proxy::isImplThread()); 50 DCHECK(m_threadChecker.CalledOnValidThread());
51 51
52 gfx::Point position = destPosition; 52 gfx::Point position = destPosition;
53 for (unsigned i = 0; i < textLine.length(); ++i) { 53 for (unsigned i = 0; i < textLine.length(); ++i) {
54 // If the ASCII code is out of bounds, then index 0 is used, which is ju st a plain rectangle glyph. 54 // If the ASCII code is out of bounds, then index 0 is used, which is ju st a plain rectangle glyph.
55 int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0; 55 int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0;
56 IntRect glyphBounds = m_asciiToRectTable[asciiIndex]; 56 IntRect glyphBounds = m_asciiToRectTable[asciiIndex];
57 SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), gly phBounds.width(), glyphBounds.height()); 57 SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), gly phBounds.width(), glyphBounds.height());
58 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint); 58 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint);
59 position.set_x(position.x() + glyphBounds.width()); 59 position.set_x(position.x() + glyphBounds.width());
60 } 60 }
61 } 61 }
62 62
63 void FontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPosition) const 63 void FontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPosition) const
64 { 64 {
65 DCHECK(Proxy::isImplThread()); 65 DCHECK(m_threadChecker.CalledOnValidThread());
66 66
67 SkIRect source = SkIRect::MakeWH(m_atlas.width(), m_atlas.height()); 67 SkIRect source = SkIRect::MakeWH(m_atlas.width(), m_atlas.height());
68 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(destPosition.x(), destPosition.y(), m_atlas.width(), m_atlas.height())); 68 canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(destPosition.x(), destPosition.y(), m_atlas.width(), m_atlas.height()));
69 } 69 }
70 70
71 } // namespace cc 71 } // namespace cc
OLDNEW
« no previous file with comments | « cc/font_atlas.h ('k') | cc/frame_rate_counter.h » ('j') | cc/gl_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698