Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_ | |
| OLD | NEW |