Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: ui/gfx/scoped_canvas.h

Issue 1904753002: MenuButton: support Mac look & feel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only cache one arrow image Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SCOPED_CANVAS_H_ 5 #ifndef UI_GFX_SCOPED_CANVAS_H_
6 #define UI_GFX_SCOPED_CANVAS_H_ 6 #define UI_GFX_SCOPED_CANVAS_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9
tapted 2016/04/27 03:25:11 nit: no blank line here
Elly Fong-Jones 2016/04/28 17:03:11 Done.
9 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/gfx_export.h"
10 12
11 namespace gfx { 13 namespace gfx {
12 14
15 class Rect;
16
13 // Saves the drawing state, and restores the state when going out of scope. 17 // Saves the drawing state, and restores the state when going out of scope.
14 class ScopedCanvas { 18 class GFX_EXPORT ScopedCanvas {
15 public: 19 public:
16 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) { 20 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) {
17 if (canvas_) 21 if (canvas_)
18 canvas_->Save(); 22 canvas_->Save();
19 } 23 }
20 ~ScopedCanvas() { 24 ~ScopedCanvas() {
21 if (canvas_) 25 if (canvas_)
22 canvas_->Restore(); 26 canvas_->Restore();
23 } 27 }
24 28
25 private: 29 private:
26 gfx::Canvas* canvas_; 30 gfx::Canvas* canvas_;
27 31
28 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas); 32 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas);
29 }; 33 };
30 34
35 // Saves the drawing state, and applies an RTL transform for the supplied rect
36 // if the UI is in RTL layout. The resulting transform is such that anything
37 // drawn inside the supplied rect will be flipped horizontally.
38 class GFX_EXPORT ScopedRTLFlipCanvas {
39 public:
40 ScopedRTLFlipCanvas(gfx::Canvas* canvas, const gfx::Rect& rect);
41 ~ScopedRTLFlipCanvas() {}
42
43 private:
44 ScopedCanvas canvas_;
45
46 DISALLOW_COPY_AND_ASSIGN(ScopedRTLFlipCanvas);
47 };
48
31 } // namespace gfx 49 } // namespace gfx
32 50
33 #endif // UI_GFX_SCOPED_CANVAS_H_ 51 #endif // UI_GFX_SCOPED_CANVAS_H_
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/scoped_canvas.cc » ('j') | ui/views/controls/button/menu_button.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698