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

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

Issue 2803583003: ui: Remove use of bitmaps when painting tab backgrounds. (Closed)
Patch Set: tabbackground: . Created 3 years, 8 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 | « chrome/browser/ui/views/tabs/tab.cc ('k') | no next file » | 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 #include "ui/gfx/gfx_export.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 13
14 // Saves the drawing state, and restores the state when going out of scope. 14 // Saves the drawing state, and restores the state when going out of scope.
15 class GFX_EXPORT ScopedCanvas { 15 class GFX_EXPORT ScopedCanvas {
16 public: 16 public:
17 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) { 17 explicit ScopedCanvas(gfx::Canvas* canvas) : canvas_(canvas) {
18 if (canvas_) 18 if (canvas_)
19 canvas_->Save(); 19 canvas_->Save();
20 } 20 }
21 ~ScopedCanvas() { 21 ~ScopedCanvas() {
22 if (canvas_) 22 if (canvas_)
23 canvas_->Restore(); 23 canvas_->Restore();
24 } 24 }
25 25
26 ScopedCanvas(ScopedCanvas&& o) {
27 canvas_ = o.canvas_;
28 o.canvas_ = nullptr;
29 }
30 ScopedCanvas& operator=(ScopedCanvas&& o) {
31 if (canvas_)
32 canvas_->Restore();
33 canvas_ = o.canvas_;
34 o.canvas_ = nullptr;
danakj 2017/04/05 22:01:37 Oops, was missing the return here when I changed t
danakj 2017/04/05 22:07:01 Alternatively i could keep passing a null instead
35 }
36
26 private: 37 private:
27 gfx::Canvas* canvas_; 38 gfx::Canvas* canvas_;
28 39
29 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas); 40 DISALLOW_COPY_AND_ASSIGN(ScopedCanvas);
30 }; 41 };
31 42
32 // Saves the drawing state. If |flip| is true, and the UI is in RTL layout, 43 // Saves the drawing state. If |flip| is true, and the UI is in RTL layout,
33 // applies a transform such that anything drawn inside the supplied width will 44 // applies a transform such that anything drawn inside the supplied width will
34 // be flipped horizontally. 45 // be flipped horizontally.
35 class GFX_EXPORT ScopedRTLFlipCanvas { 46 class GFX_EXPORT ScopedRTLFlipCanvas {
36 public: 47 public:
37 ScopedRTLFlipCanvas(gfx::Canvas* canvas, int width, bool flip = true); 48 ScopedRTLFlipCanvas(gfx::Canvas* canvas, int width, bool flip = true);
38 ~ScopedRTLFlipCanvas() {} 49 ~ScopedRTLFlipCanvas() {}
39 50
40 private: 51 private:
41 ScopedCanvas canvas_; 52 ScopedCanvas canvas_;
42 53
43 DISALLOW_COPY_AND_ASSIGN(ScopedRTLFlipCanvas); 54 DISALLOW_COPY_AND_ASSIGN(ScopedRTLFlipCanvas);
44 }; 55 };
45 56
46 } // namespace gfx 57 } // namespace gfx
47 58
48 #endif // UI_GFX_SCOPED_CANVAS_H_ 59 #endif // UI_GFX_SCOPED_CANVAS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698