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

Side by Side Diff: gfx/canvas_skia.h

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 | « gfx/canvas_2.h ('k') | gfx/canvas_skia.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 GFX_CANVAS_SKIA_H_ 5 #ifndef GFX_CANVAS_SKIA_H_
6 #define GFX_CANVAS_SKIA_H_ 6 #define GFX_CANVAS_SKIA_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "gfx/canvas.h" 9 #include "gfx/canvas_2.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
11 11
12 #if defined(OS_POSIX) && !defined(OS_MACOSX) 12 #if defined(OS_POSIX) && !defined(OS_MACOSX)
13 typedef struct _GdkPixbuf GdkPixbuf; 13 typedef struct _GdkPixbuf GdkPixbuf;
14 #endif 14 #endif
15 15
16 namespace gfx { 16 namespace gfx {
17 17
18 class Canvas; 18 class Canvas;
19 19
20 // CanvasSkia is a SkCanvas subclass that provides a number of methods for 20 // CanvasSkia is a SkCanvas subclass that provides a number of methods for
21 // common operations used throughout an application built using base/gfx and 21 // common operations used throughout an application built using base/gfx and
22 // app/gfx. 22 // app/gfx.
23 // 23 //
24 // All methods that take integer arguments (as is used throughout views) 24 // All methods that take integer arguments (as is used throughout views)
25 // end with Int. If you need to use methods provided by the superclass 25 // end with Int. If you need to use methods provided by the superclass
26 // you'll need to do a conversion. In particular you'll need to use 26 // you'll need to do a conversion. In particular you'll need to use
27 // macro SkIntToScalar(xxx), or if converting from a scalar to an integer 27 // macro SkIntToScalar(xxx), or if converting from a scalar to an integer
28 // SkScalarRound. 28 // SkScalarRound.
29 // 29 //
30 // A handful of methods in this class are overloaded providing an additional 30 // A handful of methods in this class are overloaded providing an additional
31 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the 31 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the
32 // source and destination colors are combined. Unless otherwise specified, 32 // source and destination colors are combined. Unless otherwise specified,
33 // the variant that does not take a SkXfermode::Mode uses a transfer mode 33 // the variant that does not take a SkXfermode::Mode uses a transfer mode
34 // of kSrcOver_Mode. 34 // of kSrcOver_Mode.
35 class CanvasSkia : public skia::PlatformCanvas, 35 class CanvasSkia : public skia::PlatformCanvas,
36 public Canvas { 36 public Canvas2 {
37 public: 37 public:
38 // Creates an empty Canvas. Callers must use initialize before using the 38 // Creates an empty Canvas. Callers must use initialize before using the
39 // canvas. 39 // canvas.
40 CanvasSkia(); 40 CanvasSkia();
41 41
42 CanvasSkia(int width, int height, bool is_opaque); 42 CanvasSkia(int width, int height, bool is_opaque);
43 43
44 virtual ~CanvasSkia(); 44 virtual ~CanvasSkia();
45 45
46 // Compute the size required to draw some text with the provided font. 46 // Compute the size required to draw some text with the provided font.
(...skipping 22 matching lines...) Expand all
69 // ClearType to be drawn to an otherwise transparenct bitmap for drag images. 69 // ClearType to be drawn to an otherwise transparenct bitmap for drag images.
70 // Drag images have only 1-bit of transparency, so we don't do any fancy 70 // Drag images have only 1-bit of transparency, so we don't do any fancy
71 // blurring. 71 // blurring.
72 void DrawStringWithHalo(const std::wstring& text, 72 void DrawStringWithHalo(const std::wstring& text,
73 const gfx::Font& font, 73 const gfx::Font& font,
74 const SkColor& text_color, 74 const SkColor& text_color,
75 const SkColor& halo_color, 75 const SkColor& halo_color,
76 int x, int y, int w, int h, int flags); 76 int x, int y, int w, int h, int flags);
77 #endif 77 #endif
78 78
79 // Extracts a bitmap from the contents of this canvas.
80 SkBitmap ExtractBitmap() const;
81
82 // Overridden from Canvas2: 79 // Overridden from Canvas2:
83 virtual bool GetClipRect(gfx::Rect* clip_rect); 80 virtual bool GetClipRect(gfx::Rect* clip_rect);
84 virtual bool ClipRectInt(int x, int y, int w, int h); 81 virtual bool ClipRectInt(int x, int y, int w, int h);
85 virtual bool IntersectsClipRectInt(int x, int y, int w, int h); 82 virtual bool IntersectsClipRectInt(int x, int y, int w, int h);
86 virtual void TranslateInt(int x, int y); 83 virtual void TranslateInt(int x, int y);
87 virtual void ScaleInt(int x, int y); 84 virtual void ScaleInt(int x, int y);
88 virtual void FillRectInt(int x, int y, int w, int h, 85 virtual void FillRectInt(int x, int y, int w, int h,
89 const SkPaint& paint); 86 const SkPaint& paint);
90 virtual void FillRectInt(const SkColor& color, int x, int y, int w, 87 virtual void FillRectInt(const SkColor& color, int x, int y, int w,
91 int h); 88 int h);
(...skipping 19 matching lines...) Expand all
111 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font, 108 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
112 const SkColor& color, 109 const SkColor& color,
113 const gfx::Rect& display_rect); 110 const gfx::Rect& display_rect);
114 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font, 111 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font,
115 const SkColor& color, int x, int y, int w, int h, 112 const SkColor& color, int x, int y, int w, int h,
116 int flags); 113 int flags);
117 virtual void DrawFocusRect(int x, int y, int width, int height); 114 virtual void DrawFocusRect(int x, int y, int width, int height);
118 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); 115 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h);
119 virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, 116 virtual void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
120 int dest_x, int dest_y, int w, int h); 117 int dest_x, int dest_y, int w, int h);
121 virtual CanvasSkia* AsCanvasSkia(); 118 virtual SkBitmap ExtractBitmap() const;
122 virtual const CanvasSkia* AsCanvasSkia() const;
123 119
124 private: 120 private:
125 #if defined(OS_WIN) 121 #if defined(OS_WIN)
126 // Draws text with the specified color, font and location. The text is 122 // Draws text with the specified color, font and location. The text is
127 // aligned to the left, vertically centered, clipped to the region. If the 123 // aligned to the left, vertically centered, clipped to the region. If the
128 // text is too big, it is truncated and '...' is added to the end. 124 // text is too big, it is truncated and '...' is added to the end.
129 void DrawStringInt(const std::wstring& text, HFONT font, 125 void DrawStringInt(const std::wstring& text, HFONT font,
130 const SkColor& color, int x, int y, int w, int h, 126 const SkColor& color, int x, int y, int w, int h,
131 int flags); 127 int flags);
132 #endif 128 #endif
133 129
134 DISALLOW_COPY_AND_ASSIGN(CanvasSkia); 130 DISALLOW_COPY_AND_ASSIGN(CanvasSkia);
135 }; 131 };
136 132
137 } // namespace gfx; 133 } // namespace gfx;
138 134
139 #endif // GFX_CANVAS_SKIA_H_ 135 #endif // GFX_CANVAS_SKIA_H_
OLDNEW
« no previous file with comments | « gfx/canvas_2.h ('k') | gfx/canvas_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698