| OLD | NEW |
| 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_CANVAS_H_ | 5 #ifndef APP_GFX_CANVAS_H_ |
| 6 #define APP_GFX_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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Canvas is a SkCanvas subclass that provides a number of methods for common | 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. | 27 // operations used throughout an application built using base/gfx and app/gfx. |
| 28 // | 28 // |
| 29 // All methods that take integer arguments (as is used throughout views) | 29 // All methods that take integer arguments (as is used throughout views) |
| 30 // 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 |
| 31 // 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 |
| 32 // 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 |
| 33 // SkScalarRound. | 33 // SkScalarRound. |
| 34 // | 34 // |
| 35 // 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 |
| 36 // argument of type SkPorterDuff::Mode. SkPorterDuff::Mode specifies how the | 36 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the |
| 37 // source and destination colors are combined. Unless otherwise specified, | 37 // source and destination colors are combined. Unless otherwise specified, |
| 38 // the variant that does not take a SkPorterDuff::Mode uses a transfer mode | 38 // the variant that does not take a SkXfermode::Mode uses a transfer mode |
| 39 // of kSrcOver_Mode. | 39 // of kSrcOver_Mode. |
| 40 class Canvas : public skia::PlatformCanvas { | 40 class Canvas : public skia::PlatformCanvas { |
| 41 public: | 41 public: |
| 42 // Specifies the alignment for text rendered with the DrawStringInt method. | 42 // Specifies the alignment for text rendered with the DrawStringInt method. |
| 43 enum { | 43 enum { |
| 44 TEXT_ALIGN_LEFT = 1, | 44 TEXT_ALIGN_LEFT = 1, |
| 45 TEXT_ALIGN_CENTER = 2, | 45 TEXT_ALIGN_CENTER = 2, |
| 46 TEXT_ALIGN_RIGHT = 4, | 46 TEXT_ALIGN_RIGHT = 4, |
| 47 TEXT_VALIGN_TOP = 8, | 47 TEXT_VALIGN_TOP = 8, |
| 48 TEXT_VALIGN_MIDDLE = 16, | 48 TEXT_VALIGN_MIDDLE = 16, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 void TranslateInt(int x, int y); | 92 void TranslateInt(int x, int y); |
| 93 | 93 |
| 94 // Wrapper function that takes integer arguments. | 94 // Wrapper function that takes integer arguments. |
| 95 // See scale() for specifics. | 95 // See scale() for specifics. |
| 96 void ScaleInt(int x, int y); | 96 void ScaleInt(int x, int y); |
| 97 | 97 |
| 98 // Fills the given rectangle with the given paint's parameters. | 98 // Fills the given rectangle with the given paint's parameters. |
| 99 void FillRectInt(int x, int y, int w, int h, const SkPaint& paint); | 99 void FillRectInt(int x, int y, int w, int h, const SkPaint& paint); |
| 100 | 100 |
| 101 // Fills the specified region with the specified color using a transfer | 101 // Fills the specified region with the specified color using a transfer |
| 102 // mode of SkPorterDuff::kSrcOver_Mode. | 102 // mode of SkXfermode::kSrcOver_Mode. |
| 103 void FillRectInt(const SkColor& color, int x, int y, int w, int h); | 103 void FillRectInt(const SkColor& color, int x, int y, int w, int h); |
| 104 | 104 |
| 105 // Draws a single pixel rect in the specified region with the specified | 105 // Draws a single pixel rect in the specified region with the specified |
| 106 // color, using a transfer mode of SkPorterDuff::kSrcOver_Mode. | 106 // color, using a transfer mode of SkXfermode::kSrcOver_Mode. |
| 107 // | 107 // |
| 108 // NOTE: if you need a single pixel line, use DraLineInt. | 108 // NOTE: if you need a single pixel line, use DraLineInt. |
| 109 void DrawRectInt(const SkColor& color, int x, int y, int w, int h); | 109 void DrawRectInt(const SkColor& color, int x, int y, int w, int h); |
| 110 | 110 |
| 111 // Draws a single pixel rect in the specified region with the specified | 111 // Draws a single pixel rect in the specified region with the specified |
| 112 // color and transfer mode. | 112 // color and transfer mode. |
| 113 // | 113 // |
| 114 // NOTE: if you need a single pixel line, use DraLineInt. | 114 // NOTE: if you need a single pixel line, use DraLineInt. |
| 115 void DrawRectInt(const SkColor& color, int x, int y, int w, int h, | 115 void DrawRectInt(const SkColor& color, int x, int y, int w, int h, |
| 116 SkPorterDuff::Mode mode); | 116 SkXfermode::Mode mode); |
| 117 | 117 |
| 118 // Draws a single pixel line with the specified color. | 118 // Draws a single pixel line with the specified color. |
| 119 void DrawLineInt(const SkColor& color, int x1, int y1, int x2, int y2); | 119 void DrawLineInt(const SkColor& color, int x1, int y1, int x2, int y2); |
| 120 | 120 |
| 121 // Draws a bitmap with the origin at the specified location. The upper left | 121 // Draws a bitmap with the origin at the specified location. The upper left |
| 122 // corner of the bitmap is rendered at the specified location. | 122 // corner of the bitmap is rendered at the specified location. |
| 123 void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); | 123 void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); |
| 124 | 124 |
| 125 // Draws a bitmap with the origin at the specified location, using the | 125 // Draws a bitmap with the origin at the specified location, using the |
| 126 // specified paint. The upper left corner of the bitmap is rendered at the | 126 // specified paint. The upper left corner of the bitmap is rendered at the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 const SkColor& color, int x, int y, int w, int h, | 204 const SkColor& color, int x, int y, int w, int h, |
| 205 int flags); | 205 int flags); |
| 206 #endif | 206 #endif |
| 207 | 207 |
| 208 DISALLOW_COPY_AND_ASSIGN(Canvas); | 208 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 } // namespace gfx; | 211 } // namespace gfx; |
| 212 | 212 |
| 213 #endif // #ifndef APP_GFX_CANVAS_H_ | 213 #endif // #ifndef APP_GFX_CANVAS_H_ |
| OLD | NEW |