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
3 // found in the LICENSE file.
5 #include "ui/base/cocoa/remote_layer_api.h"
7 #include "base/command_line.h"
8 #include "ui/base/ui_base_switches.h"
10 #include <objc/runtime.h>
14 bool RemoteLayerAPISupported() {
15 bool enabled_at_command_line =
16 CommandLine::ForCurrentProcess()->HasSwitch(
17 switches::kEnableRemoteCoreAnimation);
18 if (!enabled_at_command_line)
21 // Verify the GPU process interfaces are present.
22 static Class caContextClass = NSClassFromString(@"CAContext");
26 // Note that because the contextId and layer properties are dynamic,
27 // instancesRespondToSelector will return NO for them.
28 static bool caContextClassValid =
29 [caContextClass respondsToSelector:
30 @selector(contextWithCGSConnection:options:)] &&
31 class_getProperty(caContextClass, "contextId") &&
32 class_getProperty(caContextClass, "layer");
33 if (!caContextClassValid)
36 // Verify the browser process interfaces are present.
37 static Class caLayerHostClass = NSClassFromString(@"CALayerHost");
38 if (!caLayerHostClass)
41 static bool caLayerHostClassValid =
42 [caLayerHostClass instancesRespondToSelector:@selector(contextId)] &&
43 [caLayerHostClass instancesRespondToSelector:@selector(setContextId:)];
44 if (!caLayerHostClassValid)
47 // If everything is there, we should be able to use the API.