Chromium Code Reviews| Index: ui/gfx/scoped_ns_graphics_context_state_mac.h |
| diff --git a/ui/gfx/scoped_ns_graphics_context_state_mac.h b/ui/gfx/scoped_ns_graphics_context_state_mac.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aa3ef039fdd832095440f6c852a170c5a2b655ee |
| --- /dev/null |
| +++ b/ui/gfx/scoped_ns_graphics_context_state_mac.h |
| @@ -0,0 +1,36 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_ |
| +#define UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_ |
| + |
| +#include "base/basictypes.h" |
| + |
| +#import <AppKit/AppKit.h> |
| + |
| +namespace gfx { |
| + |
| +// What this class does should be self-evident and self-documenting. |
| +class ScopedNSGraphicsContextState { |
| + public: |
| + explicit ScopedNSGraphicsContextState(NSGraphicsContext* context = nil) |
| + : context_(context) { |
| + if (!context_) |
| + context_ = [NSGraphicsContext currentContext]; |
| + [context_ saveGraphicsState]; |
| + } |
| + |
| + ~ScopedNSGraphicsContextState() { |
| + [context_ restoreGraphicsState]; |
| + } |
| + |
| + private: |
| + 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.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedNSGraphicsContextState); |
| +}; |
| + |
| +} // 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
|
| + |
| +#endif // UI_GFX_SCOPED_NS_GRAPHICS_CONTEXT_STATE_MAC_H_ |