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

Side by Side Diff: app/gfx/canvas.h

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « app/app.vcproj ('k') | app/gfx/canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 APP_GFX_CHROME_CANVAS_H_ 5 #ifndef APP_GFX_CANVAS_H_
6 #define APP_GFX_CHROME_CANVAS_H_ 6 #define APP_GFX_CANVAS_H_
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "skia/ext/platform_canvas.h" 15 #include "skia/ext/platform_canvas.h"
16 16
17 namespace gfx {
18 class Font;
19 class Rect;
20 }
21
22 #if defined(OS_LINUX) 17 #if defined(OS_LINUX)
23 typedef struct _cairo cairo_t; 18 typedef struct _cairo cairo_t;
24 #endif 19 #endif
25 20
26 // ChromeCanvas is the SkCanvas used by Views for all painting. It 21 namespace gfx {
27 // provides a handful of methods for the common operations used throughout 22
28 // Views. With few exceptions, you should NOT create a ChromeCanvas directly, 23 class Font;
29 // rather one will be passed to you via the various paint methods in view. 24 class Rect;
25
26 // Canvas is a SkCanvas subclass that provides a number of methods for common
27 // operations used throughout an application built using base/gfx and app/gfx.
30 // 28 //
31 // All methods that take integer arguments (as is used throughout views) 29 // All methods that take integer arguments (as is used throughout views)
32 // end with Int. If you need to use methods provided by the superclass 30 // end with Int. If you need to use methods provided by the superclass
33 // you'll need to do a conversion. In particular you'll need to use 31 // you'll need to do a conversion. In particular you'll need to use
34 // macro SkIntToScalar(xxx), or if converting from a scalar to an integer 32 // macro SkIntToScalar(xxx), or if converting from a scalar to an integer
35 // SkScalarRound. 33 // SkScalarRound.
36 // 34 //
37 // A handful of methods in this class are overloaded providing an additional 35 // A handful of methods in this class are overloaded providing an additional
38 // argument of type SkPorterDuff::Mode. SkPorterDuff::Mode specifies how the 36 // argument of type SkPorterDuff::Mode. SkPorterDuff::Mode specifies how the
39 // source and destination colors are combined. Unless otherwise specified, 37 // source and destination colors are combined. Unless otherwise specified,
40 // the variant that does not take a SkPorterDuff::Mode uses a transfer mode 38 // the variant that does not take a SkPorterDuff::Mode uses a transfer mode
41 // of kSrcOver_Mode. 39 // of kSrcOver_Mode.
42 class ChromeCanvas : public skia::PlatformCanvas { 40 class Canvas : public skia::PlatformCanvas {
43 public: 41 public:
44 // Specifies the alignment for text rendered with the DrawStringInt method. 42 // Specifies the alignment for text rendered with the DrawStringInt method.
45 enum { 43 enum {
46 TEXT_ALIGN_LEFT = 1, 44 TEXT_ALIGN_LEFT = 1,
47 TEXT_ALIGN_CENTER = 2, 45 TEXT_ALIGN_CENTER = 2,
48 TEXT_ALIGN_RIGHT = 4, 46 TEXT_ALIGN_RIGHT = 4,
49 TEXT_VALIGN_TOP = 8, 47 TEXT_VALIGN_TOP = 8,
50 TEXT_VALIGN_MIDDLE = 16, 48 TEXT_VALIGN_MIDDLE = 16,
51 TEXT_VALIGN_BOTTOM = 32, 49 TEXT_VALIGN_BOTTOM = 32,
52 50
53 // Specifies the text consists of multiple lines. 51 // Specifies the text consists of multiple lines.
54 MULTI_LINE = 64, 52 MULTI_LINE = 64,
55 53
56 // By default DrawStringInt does not process the prefix ('&') character 54 // By default DrawStringInt does not process the prefix ('&') character
57 // specially. That is, the string "&foo" is rendered as "&foo". When 55 // specially. That is, the string "&foo" is rendered as "&foo". When
58 // rendering text from a resource that uses the prefix character for 56 // rendering text from a resource that uses the prefix character for
59 // mnemonics, the prefix should be processed and can be rendered as an 57 // mnemonics, the prefix should be processed and can be rendered as an
60 // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX). 58 // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX).
61 SHOW_PREFIX = 128, 59 SHOW_PREFIX = 128,
62 HIDE_PREFIX = 256, 60 HIDE_PREFIX = 256,
63 61
64 // Prevent ellipsizing 62 // Prevent ellipsizing
65 NO_ELLIPSIS = 512, 63 NO_ELLIPSIS = 512,
66 64
67 // Specifies if words can be split by new lines. 65 // Specifies if words can be split by new lines.
68 // This only works with MULTI_LINE. 66 // This only works with MULTI_LINE.
69 CHARACTER_BREAK = 1024, 67 CHARACTER_BREAK = 1024,
70 }; 68 };
71 69
72 // Creates an empty ChromeCanvas. Callers must use initialize before using 70 // Creates an empty Canvas. Callers must use initialize before using the
73 // the canvas. 71 // canvas.
74 ChromeCanvas(); 72 Canvas();
75 73
76 ChromeCanvas(int width, int height, bool is_opaque); 74 Canvas(int width, int height, bool is_opaque);
77 75
78 virtual ~ChromeCanvas(); 76 virtual ~Canvas();
79 77
80 // Retrieves the clip rectangle and sets it in the specified rectangle if any. 78 // Retrieves the clip rectangle and sets it in the specified rectangle if any.
81 // Returns true if the clip rect is non-empty. 79 // Returns true if the clip rect is non-empty.
82 bool GetClipRect(gfx::Rect* clip_rect); 80 bool GetClipRect(gfx::Rect* clip_rect);
83 81
84 // Wrapper function that takes integer arguments. 82 // Wrapper function that takes integer arguments.
85 // Returns true if the clip is non-empty. 83 // Returns true if the clip is non-empty.
86 // See clipRect for specifics. 84 // See clipRect for specifics.
87 bool ClipRectInt(int x, int y, int w, int h); 85 bool ClipRectInt(int x, int y, int w, int h);
88 86
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 private: 198 private:
201 #if defined(OS_WIN) 199 #if defined(OS_WIN)
202 // Draws text with the specified color, font and location. The text is 200 // Draws text with the specified color, font and location. The text is
203 // aligned to the left, vertically centered, clipped to the region. If the 201 // aligned to the left, vertically centered, clipped to the region. If the
204 // text is too big, it is truncated and '...' is added to the end. 202 // text is too big, it is truncated and '...' is added to the end.
205 void DrawStringInt(const std::wstring& text, HFONT font, 203 void DrawStringInt(const std::wstring& text, HFONT font,
206 const SkColor& color, int x, int y, int w, int h, 204 const SkColor& color, int x, int y, int w, int h,
207 int flags); 205 int flags);
208 #endif 206 #endif
209 207
210 DISALLOW_EVIL_CONSTRUCTORS(ChromeCanvas); 208 DISALLOW_COPY_AND_ASSIGN(Canvas);
211 }; 209 };
212 210
213 #if defined(OS_WIN) || defined(OS_LINUX) 211 #if defined(OS_WIN) || defined(OS_LINUX)
214 typedef skia::CanvasPaintT<ChromeCanvas> ChromeCanvasPaint; 212 typedef skia::CanvasPaintT<Canvas> CanvasPaint;
215 #endif 213 #endif
216 214
217 #endif // APP_GFX_CHROME_CANVAS_H_ 215 } // namespace gfx;
216
217 #endif // #ifndef APP_GFX_CANVAS_H_
OLDNEW
« no previous file with comments | « app/app.vcproj ('k') | app/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698