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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // Specifies if words can be split by new lines. | 67 // Specifies if words can be split by new lines. |
| 68 // This only works with MULTI_LINE. | 68 // This only works with MULTI_LINE. |
| 69 CHARACTER_BREAK = 1 << 8, | 69 CHARACTER_BREAK = 1 << 8, |
| 70 | 70 |
| 71 // Instructs DrawStringRect() to not use subpixel rendering. This is useful | 71 // Instructs DrawStringRect() to not use subpixel rendering. This is useful |
| 72 // when rendering text onto a fully- or partially-transparent background | 72 // when rendering text onto a fully- or partially-transparent background |
| 73 // that will later be blended with another image. | 73 // that will later be blended with another image. |
| 74 NO_SUBPIXEL_RENDERING = 1 << 9, | 74 NO_SUBPIXEL_RENDERING = 1 << 9, |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 // This class represents a scoped state of a Canvas. When a ScopedState is | |
|
tapted
2016/03/21 07:09:04
ui/gfx/scoped_canvas.h?
Elly Fong-Jones
2016/03/21 18:53:56
Ach! The idiom I'm used to is having these Scoped*
| |
| 78 // constructed, it saves the state of the supplied Canvas; when a ScopedState | |
| 79 // is destroyed, it restores the state it saved earlier. | |
| 80 class ScopedState { | |
| 81 public: | |
| 82 ScopedState(Canvas* canvas) : canvas_(canvas) { | |
| 83 canvas_->Save(); | |
| 84 } | |
| 85 ~ScopedState() { | |
| 86 canvas_->Restore(); | |
| 87 } | |
| 88 private: | |
| 89 Canvas* canvas_; | |
| 90 }; | |
| 91 | |
| 77 // Creates an empty canvas with image_scale of 1x. | 92 // Creates an empty canvas with image_scale of 1x. |
| 78 Canvas(); | 93 Canvas(); |
| 79 | 94 |
| 80 // Creates canvas with provided DIP |size| and |image_scale|. | 95 // Creates canvas with provided DIP |size| and |image_scale|. |
| 81 // If this canvas is not opaque, it's explicitly cleared to transparent before | 96 // If this canvas is not opaque, it's explicitly cleared to transparent before |
| 82 // being returned. | 97 // being returned. |
| 83 Canvas(const Size& size, float image_scale, bool is_opaque); | 98 Canvas(const Size& size, float image_scale, bool is_opaque); |
| 84 | 99 |
| 85 // Constructs a canvas with the size and the image_scale of the provided | 100 // Constructs a canvas with the size and the image_scale of the provided |
| 86 // |image_rep|, and draws the |image_rep| into it. | 101 // |image_rep|, and draws the |image_rep| into it. |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 float image_scale_; | 465 float image_scale_; |
| 451 | 466 |
| 452 skia::RefPtr<SkCanvas> canvas_; | 467 skia::RefPtr<SkCanvas> canvas_; |
| 453 | 468 |
| 454 DISALLOW_COPY_AND_ASSIGN(Canvas); | 469 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 455 }; | 470 }; |
| 456 | 471 |
| 457 } // namespace gfx | 472 } // namespace gfx |
| 458 | 473 |
| 459 #endif // UI_GFX_CANVAS_H_ | 474 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |