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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "skia/ext/platform_canvas.h" | 14 #include "skia/ext/platform_canvas.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/shadow_value.h" | 17 #include "ui/gfx/shadow_value.h" |
18 | 18 |
19 class SkBitmap; | 19 class SkBitmap; |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 class Transform; | 22 class Transform; |
23 } | 23 } |
24 | 24 |
25 namespace gfx { | 25 namespace gfx { |
26 | 26 |
27 class Brush; | |
28 class Rect; | 27 class Rect; |
29 class Font; | 28 class Font; |
30 class Point; | 29 class Point; |
31 class Size; | 30 class Size; |
32 | 31 |
33 // Canvas is a SkCanvas wrapper that provides a number of methods for | 32 // Canvas is a SkCanvas wrapper that provides a number of methods for |
34 // common operations used throughout an application built using ui/gfx. | 33 // common operations used throughout an application built using ui/gfx. |
35 // | 34 // |
36 // All methods that take integer arguments (as is used throughout views) | 35 // All methods that take integer arguments (as is used throughout views) |
37 // end with Int. If you need to use methods provided by SkCanvas, you'll | 36 // end with Int. If you need to use methods provided by SkCanvas, you'll |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // Builds mip map for returned image rep if necessary. | 404 // Builds mip map for returned image rep if necessary. |
406 // | 405 // |
407 // An optional additional user defined scale can be provided. | 406 // An optional additional user defined scale can be provided. |
408 const gfx::ImageSkiaRep& GetImageRepToPaint( | 407 const gfx::ImageSkiaRep& GetImageRepToPaint( |
409 const gfx::ImageSkia& image) const; | 408 const gfx::ImageSkia& image) const; |
410 const gfx::ImageSkiaRep& GetImageRepToPaint( | 409 const gfx::ImageSkiaRep& GetImageRepToPaint( |
411 const gfx::ImageSkia& image, | 410 const gfx::ImageSkia& image, |
412 float user_defined_scale_factor_x, | 411 float user_defined_scale_factor_x, |
413 float user_defined_scale_factor_y) const; | 412 float user_defined_scale_factor_y) const; |
414 | 413 |
415 #if defined(OS_WIN) | |
416 // Draws text with the specified color, font and location. The text is | |
417 // aligned to the left, vertically centered, clipped to the region. If the | |
418 // text is too big, it is truncated and '...' is added to the end. | |
419 void DrawStringInt(const string16& text, | |
420 HFONT font, | |
421 SkColor color, | |
422 const gfx::Rect& text_bounds, | |
423 int flags); | |
424 #endif | |
425 | |
426 scoped_ptr<skia::PlatformCanvas> owned_canvas_; | 414 scoped_ptr<skia::PlatformCanvas> owned_canvas_; |
427 SkCanvas* canvas_; | 415 SkCanvas* canvas_; |
428 | 416 |
429 // True if the scale factor scales the canvas and the inverse | 417 // True if the scale factor scales the canvas and the inverse |
430 // canvas scale should be applied when the destructor is called. | 418 // canvas scale should be applied when the destructor is called. |
431 bool scale_factor_scales_canvas_; | 419 bool scale_factor_scales_canvas_; |
432 | 420 |
433 // The device scale factor at which drawing on this canvas occurs. | 421 // The device scale factor at which drawing on this canvas occurs. |
434 // An additional scale can be applied via Canvas::Scale(). However, | 422 // An additional scale can be applied via Canvas::Scale(). However, |
435 // Canvas::Scale() does not affect |scale_factor_|. | 423 // Canvas::Scale() does not affect |scale_factor_|. |
436 ui::ScaleFactor scale_factor_; | 424 ui::ScaleFactor scale_factor_; |
437 | 425 |
438 DISALLOW_COPY_AND_ASSIGN(Canvas); | 426 DISALLOW_COPY_AND_ASSIGN(Canvas); |
439 }; | 427 }; |
440 | 428 |
441 } // namespace gfx | 429 } // namespace gfx |
442 | 430 |
443 #endif // UI_GFX_CANVAS_H_ | 431 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |