Chromium Code Reviews| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|, | 33 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|, |
| 34 // or if converting from a scalar to an integer |SkScalarRound()|. | 34 // or if converting from a scalar to an integer |SkScalarRound()|. |
| 35 // | 35 // |
| 36 // A handful of methods in this class are overloaded providing an additional | 36 // A handful of methods in this class are overloaded providing an additional |
| 37 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the | 37 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the |
| 38 // source and destination colors are combined. Unless otherwise specified, | 38 // source and destination colors are combined. Unless otherwise specified, |
| 39 // the variant that does not take a SkXfermode::Mode uses a transfer mode | 39 // the variant that does not take a SkXfermode::Mode uses a transfer mode |
| 40 // of kSrcOver_Mode. | 40 // of kSrcOver_Mode. |
| 41 class GFX_EXPORT Canvas { | 41 class GFX_EXPORT Canvas { |
| 42 public: | 42 public: |
| 43 // Specifies the alignment for text rendered with the DrawStringRect method. | 43 // Specifies the alignment for text rendered with the DrawStringRect method. |
|
msw
2015/02/25 17:05:20
nit: move this comment inside the enum to be group
oshima
2015/03/04 08:01:50
Done.
| |
| 44 enum { | 44 enum { |
| 45 TEXT_ALIGN_LEFT = 1 << 0, | 45 TEXT_ALIGN_LEFT = 1 << 0, |
| 46 TEXT_ALIGN_CENTER = 1 << 1, | 46 TEXT_ALIGN_CENTER = 1 << 1, |
| 47 TEXT_ALIGN_RIGHT = 1 << 2, | 47 TEXT_ALIGN_RIGHT = 1 << 2, |
| 48 TEXT_ALIGN_TO_HEAD = 1 << 3, | |
| 48 | 49 |
| 49 // Specifies the text consists of multiple lines. | 50 // Specifies the text consists of multiple lines. |
| 50 MULTI_LINE = 1 << 3, | 51 MULTI_LINE = 1 << 4, |
| 51 | 52 |
| 52 // By default DrawStringRect does not process the prefix ('&') character | 53 // By default DrawStringRect does not process the prefix ('&') character |
| 53 // specially. That is, the string "&foo" is rendered as "&foo". When | 54 // specially. That is, the string "&foo" is rendered as "&foo". When |
| 54 // rendering text from a resource that uses the prefix character for | 55 // rendering text from a resource that uses the prefix character for |
| 55 // mnemonics, the prefix should be processed and can be rendered as an | 56 // mnemonics, the prefix should be processed and can be rendered as an |
| 56 // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX). | 57 // underline (SHOW_PREFIX), or not rendered at all (HIDE_PREFIX). |
| 57 SHOW_PREFIX = 1 << 4, | 58 SHOW_PREFIX = 1 << 5, |
| 58 HIDE_PREFIX = 1 << 5, | 59 HIDE_PREFIX = 1 << 6, |
| 59 | 60 |
| 60 // Prevent ellipsizing | 61 // Prevent ellipsizing |
| 61 NO_ELLIPSIS = 1 << 6, | 62 NO_ELLIPSIS = 1 << 7, |
| 62 | 63 |
| 63 // Specifies if words can be split by new lines. | 64 // Specifies if words can be split by new lines. |
| 64 // This only works with MULTI_LINE. | 65 // This only works with MULTI_LINE. |
| 65 CHARACTER_BREAK = 1 << 7, | 66 CHARACTER_BREAK = 1 << 8, |
| 66 | |
| 67 // Instructs DrawStringRect() to render the text using RTL directionality. | |
| 68 // In most cases, passing this flag is not necessary because information | |
| 69 // about the text directionality is going to be embedded within the string | |
| 70 // in the form of special Unicode characters. However, we don't insert | |
| 71 // directionality characters into strings if the locale is LTR because some | |
| 72 // platforms (for example, an English Windows XP with no RTL fonts | |
| 73 // installed) don't support these characters. Thus, this flag should be | |
| 74 // used to render text using RTL directionality when the locale is LTR. | |
| 75 FORCE_RTL_DIRECTIONALITY = 1 << 8, | |
| 76 | |
| 77 // Similar to FORCE_RTL_DIRECTIONALITY, but left-to-right. | |
| 78 // See FORCE_RTL_DIRECTIONALITY for details. | |
| 79 FORCE_LTR_DIRECTIONALITY = 1 << 9, | |
| 80 | 67 |
| 81 // Instructs DrawStringRect() to not use subpixel rendering. This is useful | 68 // Instructs DrawStringRect() to not use subpixel rendering. This is useful |
| 82 // when rendering text onto a fully- or partially-transparent background | 69 // when rendering text onto a fully- or partially-transparent background |
| 83 // that will later be blended with another image. | 70 // that will later be blended with another image. |
| 84 NO_SUBPIXEL_RENDERING = 1 << 10, | 71 NO_SUBPIXEL_RENDERING = 1 << 9, |
| 85 }; | 72 }; |
| 86 | 73 |
| 87 // Creates an empty canvas with image_scale of 1x. | 74 // Creates an empty canvas with image_scale of 1x. |
| 88 Canvas(); | 75 Canvas(); |
| 89 | 76 |
| 90 // Creates canvas with provided DIP |size| and |image_scale|. | 77 // Creates canvas with provided DIP |size| and |image_scale|. |
| 91 // If this canvas is not opaque, it's explicitly cleared to transparent before | 78 // If this canvas is not opaque, it's explicitly cleared to transparent before |
| 92 // being returned. | 79 // being returned. |
| 93 Canvas(const Size& size, float image_scale, bool is_opaque); | 80 Canvas(const Size& size, float image_scale, bool is_opaque); |
| 94 | 81 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 | 443 |
| 457 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 444 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
| 458 SkCanvas* canvas_; | 445 SkCanvas* canvas_; |
| 459 | 446 |
| 460 DISALLOW_COPY_AND_ASSIGN(Canvas); | 447 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 461 }; | 448 }; |
| 462 | 449 |
| 463 } // namespace gfx | 450 } // namespace gfx |
| 464 | 451 |
| 465 #endif // UI_GFX_CANVAS_H_ | 452 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |