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

Side by Side Diff: ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm

Issue 10837158: mac: Delete more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mark Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « skia/ext/skia_utils_mac.mm ('k') | ui/gfx/video_decode_acceleration_support_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 5 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h"
11 10
12 namespace gfx { 11 namespace gfx {
13 12
14 ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState() 13 ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState()
15 : context_([NSGraphicsContext currentContext]) { 14 : context_([NSGraphicsContext currentContext]) {
16 [NSGraphicsContext saveGraphicsState]; 15 [NSGraphicsContext saveGraphicsState];
17 } 16 }
18 17
19 ScopedNSGraphicsContextSaveGState::~ScopedNSGraphicsContextSaveGState() { 18 ScopedNSGraphicsContextSaveGState::~ScopedNSGraphicsContextSaveGState() {
20 [NSGraphicsContext restoreGraphicsState]; 19 [NSGraphicsContext restoreGraphicsState];
21 if (!context_ && base::mac::IsOSLeopardOrEarlier()) {
22 // On 10.5 and earlier, there is a bug. If the current graphics context was
23 // nil when +[NSGraphicsContext saveGraphicsState] was called, then calling
24 // +[NSGraphicsContext restoreGraphicsState] will not restore a nil current
25 // context, but will leave the current context in place. Because allowing
26 // that stale context (which will be deallocated soon) to remain current
27 // will only lead to heartache and pain, the current context must be
28 // manually nilled out.
29 [NSGraphicsContext setCurrentContext:nil];
30 }
31 DCHECK_EQ(context_, [NSGraphicsContext currentContext]); 20 DCHECK_EQ(context_, [NSGraphicsContext currentContext]);
32 } 21 }
33 22
34 } // namespace gfx 23 } // namespace gfx
OLDNEW
« no previous file with comments | « skia/ext/skia_utils_mac.mm ('k') | ui/gfx/video_decode_acceleration_support_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698