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

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

Issue 6904026: Add and use gfx::ScopedNSGraphicsContextState (ui/gfx/scoped_ns_graphics_context_state_mac.h). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_
6 #define UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_
7
8 #include "base/basictypes.h"
9
10 #import <AppKit/AppKit.h>
11
12 namespace gfx {
13
14 // What this class does should be self-evident and self-documenting.
15 class ScopedNSGraphicsContextState {
16 public:
17 explicit ScopedNSGraphicsContextState(NSGraphicsContext* context = nil)
18 : context_(context) {
19 if (!context_)
20 context_ = [NSGraphicsContext currentContext];
21 [context_ saveGraphicsState];
22 }
23
24 ~ScopedNSGraphicsContextState() {
25 [context_ restoreGraphicsState];
26 }
27
28 private:
29 NSGraphicsContext* context_;
Nico 2011/04/26 17:56:28 If you keep this in a variable, this should probab
Robert Sesek 2011/04/26 18:50:53 Done.
30
31 DISALLOW_COPY_AND_ASSIGN(ScopedNSGraphicsContextState);
32 };
33
34 } // namespace gfx
Avi (use Gerrit) 2011/04/26 17:50:29 Can't you just do [NSGraphicsContext saveGraphicsS
Robert Sesek 2011/04/26 17:51:25 Sure. Would you ever want to operate on a separate
35
36 #endif // UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698