scoped_ns_graphics_context_save_gstate_mac.mm 674 B

1234567891011121314151617181920212223
  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. #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
  5. #import <AppKit/AppKit.h>
  6. #include "base/check_op.h"
  7. namespace gfx {
  8. ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState()
  9. : context_([NSGraphicsContext currentContext]) {
  10. [NSGraphicsContext saveGraphicsState];
  11. }
  12. ScopedNSGraphicsContextSaveGState::~ScopedNSGraphicsContextSaveGState() {
  13. [NSGraphicsContext restoreGraphicsState];
  14. DCHECK_EQ(context_, [NSGraphicsContext currentContext]);
  15. }
  16. } // namespace gfx