OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_GFX_CANVAS_H_ | 5 #ifndef UI_GFX_CANVAS_H_ |
6 #define UI_GFX_CANVAS_H_ | 6 #define UI_GFX_CANVAS_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
13 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
14 #include "skia/ext/refptr.h" | 16 #include "skia/ext/refptr.h" |
15 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
16 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/shadow_value.h" | 19 #include "ui/gfx/shadow_value.h" |
18 #include "ui/gfx/text_constants.h" | 20 #include "ui/gfx/text_constants.h" |
19 | 21 |
20 namespace gfx { | 22 namespace gfx { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 float UndoDeviceScaleFactor(); | 174 float UndoDeviceScaleFactor(); |
173 | 175 |
174 // Saves a copy of the drawing state onto a stack, operating on this copy | 176 // Saves a copy of the drawing state onto a stack, operating on this copy |
175 // until a balanced call to Restore() is made. | 177 // until a balanced call to Restore() is made. |
176 void Save(); | 178 void Save(); |
177 | 179 |
178 // As with Save(), except draws to a layer that is blended with the canvas | 180 // As with Save(), except draws to a layer that is blended with the canvas |
179 // at the specified alpha once Restore() is called. | 181 // at the specified alpha once Restore() is called. |
180 // |layer_bounds| are the bounds of the layer relative to the current | 182 // |layer_bounds| are the bounds of the layer relative to the current |
181 // transform. | 183 // transform. |
182 void SaveLayerAlpha(uint8 alpha); | 184 void SaveLayerAlpha(uint8_t alpha); |
183 void SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds); | 185 void SaveLayerAlpha(uint8_t alpha, const Rect& layer_bounds); |
184 | 186 |
185 // Restores the drawing state after a call to Save*(). It is an error to | 187 // Restores the drawing state after a call to Save*(). It is an error to |
186 // call Restore() more times than Save*(). | 188 // call Restore() more times than Save*(). |
187 void Restore(); | 189 void Restore(); |
188 | 190 |
189 // Adds |rect| to the current clip. | 191 // Adds |rect| to the current clip. |
190 void ClipRect(const Rect& rect); | 192 void ClipRect(const Rect& rect); |
191 | 193 |
192 // Adds |path| to the current clip. |do_anti_alias| is true if the clip | 194 // Adds |path| to the current clip. |do_anti_alias| is true if the clip |
193 // should be antialiased. | 195 // should be antialiased. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 void DrawPath(const SkPath& path, const SkPaint& paint); | 263 void DrawPath(const SkPath& path, const SkPaint& paint); |
262 | 264 |
263 // Draws an image with the origin at the specified location. The upper left | 265 // Draws an image with the origin at the specified location. The upper left |
264 // corner of the bitmap is rendered at the specified location. | 266 // corner of the bitmap is rendered at the specified location. |
265 // Parameters are specified relative to current canvas scale not in pixels. | 267 // Parameters are specified relative to current canvas scale not in pixels. |
266 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1. | 268 // Thus, x is 2 pixels if canvas scale = 2 & |x| = 1. |
267 void DrawImageInt(const ImageSkia&, int x, int y); | 269 void DrawImageInt(const ImageSkia&, int x, int y); |
268 | 270 |
269 // Helper for DrawImageInt(..., paint) that constructs a temporary paint and | 271 // Helper for DrawImageInt(..., paint) that constructs a temporary paint and |
270 // calls paint.setAlpha(alpha). | 272 // calls paint.setAlpha(alpha). |
271 void DrawImageInt(const ImageSkia&, int x, int y, uint8 alpha); | 273 void DrawImageInt(const ImageSkia&, int x, int y, uint8_t alpha); |
272 | 274 |
273 // Draws an image with the origin at the specified location, using the | 275 // Draws an image with the origin at the specified location, using the |
274 // specified paint. The upper left corner of the bitmap is rendered at the | 276 // specified paint. The upper left corner of the bitmap is rendered at the |
275 // specified location. | 277 // specified location. |
276 // Parameters are specified relative to current canvas scale not in pixels. | 278 // Parameters are specified relative to current canvas scale not in pixels. |
277 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. | 279 // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. |
278 void DrawImageInt(const ImageSkia& image, | 280 void DrawImageInt(const ImageSkia& image, |
279 int x, | 281 int x, |
280 int y, | 282 int y, |
281 const SkPaint& paint); | 283 const SkPaint& paint); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 442 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
441 SkCanvas* canvas_; | 443 SkCanvas* canvas_; |
442 | 444 |
443 DISALLOW_COPY_AND_ASSIGN(Canvas); | 445 DISALLOW_COPY_AND_ASSIGN(Canvas); |
444 }; | 446 }; |
445 | 447 |
446 } // namespace gfx | 448 } // namespace gfx |
447 | 449 |
448 #endif // UI_GFX_CANVAS_H_ | 450 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |