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

Side by Side Diff: cc/font_atlas.h

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some missed intstuff 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 | Annotate | Revision Log
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 #ifndef CCFontAtlas_h 5 #ifndef CCFontAtlas_h
6 #define CCFontAtlas_h 6 #define CCFontAtlas_h
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "IntRect.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/rect.h"
14 14
15 class SkCanvas; 15 class SkCanvas;
16 16
17 namespace gfx { 17 namespace gfx {
18 class Point; 18 class Point;
19 } 19 }
20 20
21 namespace cc { 21 namespace cc {
22 22
23 class IntSize;
24
25 // This class provides basic ability to draw text onto the heads-up display. 23 // This class provides basic ability to draw text onto the heads-up display.
26 class FontAtlas { 24 class FontAtlas {
27 public: 25 public:
28 static scoped_ptr<FontAtlas> create(SkBitmap bitmap, IntRect asciiToRectTabl e[128], int fontHeight) 26 static scoped_ptr<FontAtlas> create(SkBitmap bitmap, gfx::Rect asciiToRectTa ble[128], int fontHeight)
29 { 27 {
30 return make_scoped_ptr(new FontAtlas(bitmap, asciiToRectTable, fontHeigh t)); 28 return make_scoped_ptr(new FontAtlas(bitmap, asciiToRectTable, fontHeigh t));
31 } 29 }
32 ~FontAtlas(); 30 ~FontAtlas();
33 31
34 // Draws multiple lines of text where each line of text is separated by '\n' . 32 // Draws multiple lines of text where each line of text is separated by '\n' .
35 // - Correct glyphs will be drawn for ASCII codes in the range 32-127; any c haracters 33 // - Correct glyphs will be drawn for ASCII codes in the range 32-127; any c haracters
36 // outside that range will be displayed as a default rectangle glyph. 34 // outside that range will be displayed as a default rectangle glyph.
37 // - IntSize clip is used to avoid wasting time drawing things that are outs ide the 35 // - gfx::Size clip is used to avoid wasting time drawing things that are ou tside the
38 // target canvas bounds. 36 // target canvas bounds.
39 // - Should only be called only on the impl thread. 37 // - Should only be called only on the impl thread.
40 void drawText(SkCanvas*, const SkPaint&, const std::string& text, const gfx: :Point& destPosition, const IntSize& clip) const; 38 void drawText(SkCanvas*, const SkPaint&, const std::string& text, const gfx: :Point& destPosition, const gfx::Size& clip) const;
41 39
42 // Draws the entire atlas at the specified position, just for debugging purp oses. 40 // Draws the entire atlas at the specified position, just for debugging purp oses.
43 void drawDebugAtlas(SkCanvas*, const gfx::Point& destPosition) const; 41 void drawDebugAtlas(SkCanvas*, const gfx::Point& destPosition) const;
44 42
45 private: 43 private:
46 FontAtlas(SkBitmap, IntRect asciiToRectTable[128], int fontHeight); 44 FontAtlas(SkBitmap, gfx::Rect asciiToRectTable[128], int fontHeight);
47 45
48 void drawOneLineOfTextInternal(SkCanvas*, const SkPaint&, const std::string& , const gfx::Point& destPosition) const; 46 void drawOneLineOfTextInternal(SkCanvas*, const SkPaint&, const std::string& , const gfx::Point& destPosition) const;
49 47
50 // The actual texture atlas containing all the pre-rendered glyphs. 48 // The actual texture atlas containing all the pre-rendered glyphs.
51 SkBitmap m_atlas; 49 SkBitmap m_atlas;
52 50
53 // The look-up tables mapping ascii characters to their IntRect locations on the atlas. 51 // The look-up tables mapping ascii characters to their gfx::Rect locations on the atlas.
54 IntRect m_asciiToRectTable[128]; 52 gfx::Rect m_asciiToRectTable[128];
55 53
56 int m_fontHeight; 54 int m_fontHeight;
57 55
58 DISALLOW_COPY_AND_ASSIGN(FontAtlas); 56 DISALLOW_COPY_AND_ASSIGN(FontAtlas);
59 }; 57 };
60 58
61 } // namespace cc 59 } // namespace cc
62 60
63 #endif 61 #endif
OLDNEW
« no previous file with comments | « cc/draw_quad_unittest.cc ('k') | cc/font_atlas.cc » ('j') | cc/layer_quad.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698