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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698