Index: ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm |
diff --git a/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm b/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f3992ea0b694a520c9b45b869151144d4237836b |
--- /dev/null |
+++ b/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm |
@@ -0,0 +1,22 @@ |
+// 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. |
+ |
+#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
+ |
+#include <AppKit/AppKit.h> |
+ |
+namespace gfx { |
+ |
+ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState( |
+ NSGraphicsContext* context) : context_([context retain]) { |
+ if (!context_) |
+ context_.reset([[NSGraphicsContext currentContext] retain]); |
+ [context_ saveGraphicsState]; |
+} |
+ |
+ScopedNSGraphicsContextSaveGState::~ScopedNSGraphicsContextSaveGState() { |
+ [context_ restoreGraphicsState]; |
+} |
+ |
+} // namespace gfx |