| OLD | NEW |
| 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_2.h" | 9 #include "gfx/canvas.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 Canvas2 { | 36 public Canvas { |
| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const SkColor& color, | 109 const SkColor& color, |
| 110 const gfx::Rect& display_rect); | 110 const gfx::Rect& display_rect); |
| 111 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font, | 111 virtual void DrawStringInt(const std::wstring& text, const gfx::Font& font, |
| 112 const SkColor& color, int x, int y, int w, int h, | 112 const SkColor& color, int x, int y, int w, int h, |
| 113 int flags); | 113 int flags); |
| 114 virtual void DrawFocusRect(int x, int y, int width, int height); | 114 virtual void DrawFocusRect(int x, int y, int width, int height); |
| 115 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); |
| 116 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, |
| 117 int dest_x, int dest_y, int w, int h); | 117 int dest_x, int dest_y, int w, int h); |
| 118 virtual SkBitmap ExtractBitmap() const; | 118 virtual SkBitmap ExtractBitmap() const; |
| 119 virtual CanvasSkia* AsCanvasSkia(); |
| 120 virtual const CanvasSkia* AsCanvasSkia() const; |
| 119 | 121 |
| 120 private: | 122 private: |
| 121 #if defined(OS_WIN) | 123 #if defined(OS_WIN) |
| 122 // Draws text with the specified color, font and location. The text is | 124 // Draws text with the specified color, font and location. The text is |
| 123 // aligned to the left, vertically centered, clipped to the region. If the | 125 // aligned to the left, vertically centered, clipped to the region. If the |
| 124 // text is too big, it is truncated and '...' is added to the end. | 126 // text is too big, it is truncated and '...' is added to the end. |
| 125 void DrawStringInt(const std::wstring& text, HFONT font, | 127 void DrawStringInt(const std::wstring& text, HFONT font, |
| 126 const SkColor& color, int x, int y, int w, int h, | 128 const SkColor& color, int x, int y, int w, int h, |
| 127 int flags); | 129 int flags); |
| 128 #endif | 130 #endif |
| 129 | 131 |
| 130 DISALLOW_COPY_AND_ASSIGN(CanvasSkia); | 132 DISALLOW_COPY_AND_ASSIGN(CanvasSkia); |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 } // namespace gfx; | 135 } // namespace gfx; |
| 134 | 136 |
| 135 #endif // GFX_CANVAS_SKIA_H_ | 137 #endif // GFX_CANVAS_SKIA_H_ |
| OLD | NEW |