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

Side by Side Diff: ui/gfx/mac/scoped_cocoa_disable_screen_updates.h

Issue 2271653006: base::mac::IsOSSierra() -> base::mac::IsOS10_12(), etc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Nits Created 4 years, 3 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
« no previous file with comments | « ui/gfx/mac/io_surface.cc ('k') | ui/gfx/render_text_mac.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 #ifndef UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_ 5 #ifndef UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_
6 #define UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_ 6 #define UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 14
15 // A stack-based class to disable Cocoa screen updates. When instantiated, it 15 // A stack-based class to disable Cocoa screen updates. When instantiated, it
16 // disables screen updates and enables them when destroyed. Update disabling 16 // disables screen updates and enables them when destroyed. Update disabling
17 // can be nested, and there is a time-maximum (about 1 second) after which 17 // can be nested, and there is a time-maximum (about 1 second) after which
18 // Cocoa will automatically re-enable updating. This class doesn't attempt to 18 // Cocoa will automatically re-enable updating. This class doesn't attempt to
19 // overrule that. 19 // overrule that.
20 class ScopedCocoaDisableScreenUpdates { 20 class ScopedCocoaDisableScreenUpdates {
21 public: 21 public:
22 ScopedCocoaDisableScreenUpdates() { 22 ScopedCocoaDisableScreenUpdates() {
23 if (base::mac::IsOSElCapitanOrLater()) { 23 if (base::mac::IsAtLeastOS10_11()) {
24 // Beginning with OS X 10.11, [NSAnimationContext beginGrouping] is the 24 // Beginning with OS X 10.11, [NSAnimationContext beginGrouping] is the
25 // preferred way of disabling screen updates. Use of 25 // preferred way of disabling screen updates. Use of
26 // NSDisableScreenUpdates() is discouraged. 26 // NSDisableScreenUpdates() is discouraged.
27 [NSAnimationContext beginGrouping]; 27 [NSAnimationContext beginGrouping];
28 } else { 28 } else {
29 NSDisableScreenUpdates(); 29 NSDisableScreenUpdates();
30 } 30 }
31 } 31 }
32 ~ScopedCocoaDisableScreenUpdates() { 32 ~ScopedCocoaDisableScreenUpdates() {
33 if (base::mac::IsOSElCapitanOrLater()) { 33 if (base::mac::IsAtLeastOS10_11()) {
34 [NSAnimationContext endGrouping]; 34 [NSAnimationContext endGrouping];
35 } else { 35 } else {
36 NSEnableScreenUpdates(); 36 NSEnableScreenUpdates();
37 } 37 }
38 } 38 }
39 39
40 private: 40 private:
41 DISALLOW_COPY_AND_ASSIGN(ScopedCocoaDisableScreenUpdates); 41 DISALLOW_COPY_AND_ASSIGN(ScopedCocoaDisableScreenUpdates);
42 }; 42 };
43 43
44 } // namespace gfx 44 } // namespace gfx
45 45
46 #endif // UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_ 46 #endif // UI_GFX_MAC_SCOPED_COCOA_DISABLE_SCREEN_UPDATES_H_
OLDNEW
« no previous file with comments | « ui/gfx/mac/io_surface.cc ('k') | ui/gfx/render_text_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698