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

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

Issue 1971333002: Views: factor out Combobox background and const-ify style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ios build break 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
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/scoped_canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/gfx_export.h"
10 11
11 namespace gfx { 12 namespace gfx {
12 13
14 class Rect;
15
13 // Saves the drawing state, and restores the state when going out of scope. 16 // Saves the drawing state, and restores the state when going out of scope.
14 class ScopedCanvas { 17 class GFX_EXPORT ScopedCanvas {
15 public: 18 public:
16 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) { 19 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) {
17 if (canvas_) 20 if (canvas_)
18 canvas_->Save(); 21 canvas_->Save();
19 } 22 }
20 ~ScopedCanvas() { 23 ~ScopedCanvas() {
21 if (canvas_) 24 if (canvas_)
22 canvas_->Restore(); 25 canvas_->Restore();
23 } 26 }
24 27
25 private: 28 private:
26 gfx::Canvas* canvas_; 29 gfx::Canvas* canvas_;
27 30
28 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas); 31 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas);
29 }; 32 };
30 33
34 // Saves the drawing state, and applies an RTL transform for the supplied rect
35 // if the UI is in RTL layout. The resulting transform is such that anything
36 // drawn inside the supplied rect will be flipped horizontally.
37 class GFX_EXPORT ScopedRTLFlipCanvas {
38 public:
39 ScopedRTLFlipCanvas(gfx::Canvas* canvas, const gfx::Rect& rect);
40 ~ScopedRTLFlipCanvas() {}
41
42 private:
43 ScopedCanvas canvas_;
44
45 DISALLOW_COPY_AND_ASSIGN(ScopedRTLFlipCanvas);
46 };
47
31 } // namespace gfx 48 } // namespace gfx
32 49
33 #endif // UI_GFX_SCOPED_CANVAS_H_ 50 #endif // UI_GFX_SCOPED_CANVAS_H_
OLDNEW
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/scoped_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698