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> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
16 #include "third_party/skia/include/core/SkRefCnt.h" | 16 #include "third_party/skia/include/core/SkRefCnt.h" |
17 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
18 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/shadow_value.h" | |
20 #include "ui/gfx/text_constants.h" | 19 #include "ui/gfx/text_constants.h" |
21 | 20 |
22 namespace gfx { | 21 namespace gfx { |
23 | 22 |
24 class Rect; | 23 class Rect; |
25 class RectF; | 24 class RectF; |
26 class FontList; | 25 class FontList; |
27 class Point; | 26 class Point; |
28 class PointF; | 27 class PointF; |
29 class Size; | 28 class Size; |
30 class Transform; | 29 class Transform; |
| 30 class Vector2d; |
31 | 31 |
32 // 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 |
33 // common operations used throughout an application built using ui/gfx. | 33 // common operations used throughout an application built using ui/gfx. |
34 // | 34 // |
35 // All methods that take integer arguments (as is used throughout views) | 35 // All methods that take integer arguments (as is used throughout views) |
36 // 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 |
37 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|, | 37 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|, |
38 // or if converting from a scalar to an integer |SkScalarRound()|. | 38 // or if converting from a scalar to an integer |SkScalarRound()|. |
39 // | 39 // |
40 // A handful of methods in this class are overloaded providing an additional | 40 // A handful of methods in this class are overloaded providing an additional |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 400 |
401 // Draws text with the specified color, fonts and location. The last argument | 401 // Draws text with the specified color, fonts and location. The last argument |
402 // specifies flags for how the text should be rendered. It can be one of | 402 // specifies flags for how the text should be rendered. It can be one of |
403 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. | 403 // TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT. |
404 void DrawStringRectWithFlags(const base::string16& text, | 404 void DrawStringRectWithFlags(const base::string16& text, |
405 const FontList& font_list, | 405 const FontList& font_list, |
406 SkColor color, | 406 SkColor color, |
407 const Rect& display_rect, | 407 const Rect& display_rect, |
408 int flags); | 408 int flags); |
409 | 409 |
410 // Similar to above DrawStringRect method but with text shadows support. | |
411 // Currently it's only implemented for canvas skia. Specifying a 0 line_height | |
412 // will cause the default height to be used. | |
413 void DrawStringRectWithShadows(const base::string16& text, | |
414 const FontList& font_list, | |
415 SkColor color, | |
416 const Rect& text_bounds, | |
417 int line_height, | |
418 int flags, | |
419 const ShadowValues& shadows); | |
420 | |
421 // Draws a dotted gray rectangle used for focus purposes. | 410 // Draws a dotted gray rectangle used for focus purposes. |
422 // DEPRECATED in favor of the RectF version below. | 411 // DEPRECATED in favor of the RectF version below. |
423 // TODO(funkysidd): Remove this (http://crbug.com/553726) | 412 // TODO(funkysidd): Remove this (http://crbug.com/553726) |
424 void DrawFocusRect(const Rect& rect); | 413 void DrawFocusRect(const Rect& rect); |
425 | 414 |
426 // Draws a dotted gray rectangle used for focus purposes. | 415 // Draws a dotted gray rectangle used for focus purposes. |
427 void DrawFocusRect(const RectF& rect); | 416 void DrawFocusRect(const RectF& rect); |
428 | 417 |
429 // Draws a |rect| in the specified region with the specified |color| with a | 418 // Draws a |rect| in the specified region with the specified |color| with a |
430 // with of one logical pixel which might be more device pixels. | 419 // with of one logical pixel which might be more device pixels. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // but canvas_owner_ will be null. | 500 // but canvas_owner_ will be null. |
512 std::unique_ptr<SkCanvas> canvas_owner_; | 501 std::unique_ptr<SkCanvas> canvas_owner_; |
513 SkCanvas* canvas_; | 502 SkCanvas* canvas_; |
514 | 503 |
515 DISALLOW_COPY_AND_ASSIGN(Canvas); | 504 DISALLOW_COPY_AND_ASSIGN(Canvas); |
516 }; | 505 }; |
517 | 506 |
518 } // namespace gfx | 507 } // namespace gfx |
519 | 508 |
520 #endif // UI_GFX_CANVAS_H_ | 509 #endif // UI_GFX_CANVAS_H_ |
OLD | NEW |