Chromium Code Reviews| Index: ui/gfx/canvas.h |
| diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h |
| index 367aa8a74416facf0b0c0062944121ffd17dee06..99ca4339e26b212e243a5b674bd214cd9ea0df43 100644 |
| --- a/ui/gfx/canvas.h |
| +++ b/ui/gfx/canvas.h |
| @@ -74,6 +74,21 @@ class GFX_EXPORT Canvas { |
| NO_SUBPIXEL_RENDERING = 1 << 9, |
| }; |
| + // 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*
|
| + // constructed, it saves the state of the supplied Canvas; when a ScopedState |
| + // is destroyed, it restores the state it saved earlier. |
| + class ScopedState { |
| + public: |
| + ScopedState(Canvas* canvas) : canvas_(canvas) { |
| + canvas_->Save(); |
| + } |
| + ~ScopedState() { |
| + canvas_->Restore(); |
| + } |
| + private: |
| + Canvas* canvas_; |
| + }; |
| + |
| // Creates an empty canvas with image_scale of 1x. |
| Canvas(); |