OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/cocoa/remote_layer_api.h" | 5 #include "ui/base/cocoa/remote_layer_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/mac/mac_util.h" |
8 #include "ui/base/ui_base_switches.h" | 9 #include "ui/base/ui_base_switches.h" |
9 | 10 |
10 #include <objc/runtime.h> | 11 #include <objc/runtime.h> |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 bool RemoteLayerAPISupported() { | 15 bool RemoteLayerAPISupported() { |
15 bool enabled_at_command_line = | 16 // This API only works on Mac OS 10.9 and later. |
| 17 if (!base::mac::IsOSMavericksOrLater()) |
| 18 return false; |
| 19 |
| 20 bool disabled_at_command_line = |
16 CommandLine::ForCurrentProcess()->HasSwitch( | 21 CommandLine::ForCurrentProcess()->HasSwitch( |
17 switches::kEnableRemoteCoreAnimation); | 22 switches::kDisableRemoteCoreAnimation); |
18 if (!enabled_at_command_line) | 23 if (disabled_at_command_line) |
19 return false; | 24 return false; |
20 | 25 |
21 // Verify the GPU process interfaces are present. | 26 // Verify the GPU process interfaces are present. |
22 static Class caContextClass = NSClassFromString(@"CAContext"); | 27 static Class caContextClass = NSClassFromString(@"CAContext"); |
23 if (!caContextClass) | 28 if (!caContextClass) |
24 return false; | 29 return false; |
25 | 30 |
26 // Note that because the contextId and layer properties are dynamic, | 31 // Note that because the contextId and layer properties are dynamic, |
27 // instancesRespondToSelector will return NO for them. | 32 // instancesRespondToSelector will return NO for them. |
28 static bool caContextClassValid = | 33 static bool caContextClassValid = |
(...skipping 14 matching lines...) Expand all Loading... |
43 [caLayerHostClass instancesRespondToSelector:@selector(setContextId:)]; | 48 [caLayerHostClass instancesRespondToSelector:@selector(setContextId:)]; |
44 if (!caLayerHostClassValid) | 49 if (!caLayerHostClassValid) |
45 return false; | 50 return false; |
46 | 51 |
47 // If everything is there, we should be able to use the API. | 52 // If everything is there, we should be able to use the API. |
48 return true; | 53 return true; |
49 } | 54 } |
50 | 55 |
51 } // namespace | 56 } // namespace |
52 | 57 |
OLD | NEW |