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

Side by Side Diff: cc/font_atlas.h

Issue 12212099: cc: remove FontAtlas (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 182043 Created 7 years, 10 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/font_atlas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_FONT_ATLAS_H_
6 #define CC_FONT_ATLAS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "cc/cc_export.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/rect.h"
15
16 class SkCanvas;
17
18 namespace gfx {
19 class Point;
20 class Size;
21 }
22
23 namespace cc {
24
25 // This class provides basic ability to draw text onto the heads-up display.
26 class CC_EXPORT FontAtlas {
27 public:
28 static scoped_ptr<FontAtlas> create(SkBitmap bitmap, gfx::Rect asciiToRectTa ble[128], int fontHeight)
29 {
30 return make_scoped_ptr(new FontAtlas(bitmap, asciiToRectTable, fontHeigh t));
31 }
32 ~FontAtlas();
33
34 // Current font height.
35 int fontHeight() const { return m_fontHeight; }
36
37 // Draws multiple lines of text where each line of text is separated by '\n' .
38 // - Correct glyphs will be drawn for ASCII codes in the range 32-127; any c haracters
39 // outside that range will be displayed as a default rectangle glyph.
40 // - gfx::Size clip is used to avoid wasting time drawing things that are ou tside the
41 // target canvas bounds.
42 // - Should only be called on the impl thread.
43 void drawText(SkCanvas*, SkPaint*, const std::string& text, const gfx::Point & destPosition, const gfx::Size& clip) const;
44
45 // Gives a text's width and height on the canvas.
46 gfx::Size textSize(const std::string& text);
47
48 // Sets the text's color.
49 void setColor(const SkColor& color) { m_color = color; }
50
51 // Draws the entire atlas at the specified position, just for debugging purp oses.
52 void drawDebugAtlas(SkCanvas*, const gfx::Point& destPosition) const;
53
54 private:
55 FontAtlas(SkBitmap, gfx::Rect asciiToRectTable[128], int fontHeight);
56
57 void drawOneLineOfTextInternal(SkCanvas*, const SkPaint&, const std::string& , const gfx::Point& destPosition) const;
58
59 // The actual texture atlas containing all the pre-rendered glyphs.
60 SkBitmap m_atlas;
61
62 // The look-up tables mapping ascii characters to their gfx::Rect locations on the atlas.
63 gfx::Rect m_asciiToRectTable[128];
64
65 int m_fontHeight;
66 SkColor m_color;
67
68 DISALLOW_COPY_AND_ASSIGN(FontAtlas);
69 };
70
71 } // namespace cc
72
73 #endif // CC_FONT_ATLAS_H_
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/font_atlas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698