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

Unified Diff: ui/base/cocoa/remote_layer_api.mm

Issue 347653005: Make cross-process CALayers work on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@image_transport_1
Patch Set: Incorporate review feedback Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/cocoa/remote_layer_api.mm
diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c58402ffe9ae3e84d0d3a4134c739f39810d1840
--- /dev/null
+++ b/ui/base/cocoa/remote_layer_api.mm
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/cocoa/remote_layer_api.h"
+
+#include <objc/runtime.h>
+
+namespace ui {
+
+bool RemoteLayerAPISupported() {
+ // Verify the GPU process interfaces are present.
+ static Class caContextClass = NSClassFromString(@"CAContext");
+ if (!caContextClass)
+ return false;
+
+ // Note that because the contextId and layer properties are dynamic,
+ // instancesRespondToSelector will return NO for them.
+ static bool caContextClassValid =
+ [caContextClass respondsToSelector:
+ @selector(contextWithCGSConnection:options:)] &&
+ class_getProperty(caContextClass, "contextId") &&
+ class_getProperty(caContextClass, "layer");
+ if (!caContextClassValid)
+ return false;
+
+ // Verify the browser process interfaces are present.
+ static Class caLayerHostClass = NSClassFromString(@"CALayerHost");
+ if (!caLayerHostClass)
+ return false;
+
+ static bool caLayerHostClassValid =
+ [caLayerHostClass instancesRespondToSelector:@selector(contextId)] &&
+ [caLayerHostClass instancesRespondToSelector:@selector(setContextId:)];
+ if (!caLayerHostClassValid)
+ return false;
+
+ // If everything is there, we should be able to use the API.
+ return true;
+}
+
+} // namespace
+

Powered by Google App Engine
This is Rietveld 408576698