123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Cheng Zhao <[email protected]>
- Date: Thu, 20 Sep 2018 17:48:49 -0700
- Subject: mas_disable_remote_layer.patch
- Disable remote layer APIs (CAContext and CALayerHost) for MAS build.
- diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
- index 8b72554c48ab9d89525e52db0f20a6578675eb18..ce7cbc6cf0d7e71519d21c39a7aebec869dfae7e 100644
- --- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
- +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
- @@ -16,7 +16,9 @@
- #include "ui/gl/gl_surface.h"
- #include "ui/gl/gpu_switching_observer.h"
-
- +#ifndef MAS_BUILD
- @class CAContext;
- +#endif
- @class CALayer;
-
- namespace ui {
- @@ -83,7 +85,9 @@ class ImageTransportSurfaceOverlayMac : public gl::GLSurface,
- base::WeakPtr<ImageTransportSurfaceDelegate> delegate_;
-
- bool use_remote_layer_api_;
- +#ifndef MAS_BUILD
- base::scoped_nsobject<CAContext> ca_context_;
- +#endif
- std::unique_ptr<ui::CALayerTreeCoordinator> ca_layer_tree_coordinator_;
-
- gfx::Size pixel_size_;
- diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
- index cf6b3450c209db70c2f0bd8658258e01b9f7421c..af720dc0ef327011ec9e965603d4ee6cb9c9edee 100644
- --- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
- +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
- @@ -57,6 +57,7 @@ ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() {
- }
-
- bool ImageTransportSurfaceOverlayMac::Initialize(gl::GLSurfaceFormat format) {
- +#ifndef MAS_BUILD
- // Create the CAContext to send this to the GPU process, and the layer for
- // the context.
- if (use_remote_layer_api_) {
- @@ -65,6 +66,7 @@ bool ImageTransportSurfaceOverlayMac::Initialize(gl::GLSurfaceFormat format) {
- [CAContext contextWithCGSConnection:connection_id options:@{}] retain]);
- [ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
- }
- +#endif
- return true;
- }
-
- @@ -123,7 +125,9 @@ gfx::SwapResult ImageTransportSurfaceOverlayMac::SwapBuffersInternal(
- "GLImpl", static_cast<int>(gl::GetGLImplementation()),
- "width", pixel_size_.width());
- if (use_remote_layer_api_) {
- +#ifndef MAS_BUILD
- params.ca_layer_params.ca_context_id = [ca_context_ contextId];
- +#endif
- } else {
- IOSurfaceRef io_surface =
- ca_layer_tree_coordinator_->GetIOSurfaceForDisplay();
- diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
- index 60abe639bd9c9cf6885f811c741a45eeb683ec58..c38eed5fbdefc96a3d60e4ab70d3b007264ccb3c 100644
- --- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
- +++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
- @@ -98,6 +98,7 @@ void DisplayCALayerTree::UpdateCALayerTree(
- }
-
- void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
- +#ifndef MAS_BUILD
- // Early-out if the remote layer has not changed.
- if ([remote_layer_ contextId] == ca_context_id)
- return;
- @@ -122,6 +123,9 @@ void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
- [io_surface_layer_ removeFromSuperlayer];
- io_surface_layer_.reset();
- }
- +#else
- + NOTREACHED() << "Remote layer is being used in MAS build";
- +#endif
- }
-
- void DisplayCALayerTree::GotIOSurfaceFrame(
- diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h
- index 2057fe69d1bb4a2eb0b1dabc5473a30d676847fe..2aba330fc488660ef874caae26a06e6847cdaf93 100644
- --- a/ui/base/cocoa/remote_layer_api.h
- +++ b/ui/base/cocoa/remote_layer_api.h
- @@ -13,6 +13,7 @@
-
- #include "ui/base/ui_base_export.h"
-
- +#ifndef MAS_BUILD
- // The CGSConnectionID is used to create the CAContext in the process that is
- // going to share the CALayers that it is rendering to another process to
- // display.
- @@ -50,6 +51,8 @@ typedef uint32_t CAContextID;
-
- #endif // __OBJC__
-
- +#endif // MAS_BUILD
- +
- namespace ui {
-
- // This function will check if all of the interfaces listed above are supported
- diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
- index bbaf9f466f4999acb5bfccf3b9565fd8f556ca2f..8c846ce9523a4b2f6fbdbdbeae4f94b45ac3c115 100644
- --- a/ui/base/cocoa/remote_layer_api.mm
- +++ b/ui/base/cocoa/remote_layer_api.mm
- @@ -12,6 +12,7 @@
- namespace ui {
-
- bool RemoteLayerAPISupported() {
- +#ifndef MAS_BUILD
- static bool disabled_at_command_line =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableRemoteCoreAnimation);
- @@ -46,6 +47,9 @@ bool RemoteLayerAPISupported() {
-
- // If everything is there, we should be able to use the API.
- return true;
- +#else
- + return false;
- +#endif // MAS_BUILD
- }
-
- } // namespace
- diff --git a/ui/views/cocoa/bridged_native_widget_host_impl.h b/ui/views/cocoa/bridged_native_widget_host_impl.h
- index 75f3dd1ec826857a88851c62e2c22899b6221b81..eb874f0d4bcd6e08ddecfab5a0f9b18b562d6d92 100644
- --- a/ui/views/cocoa/bridged_native_widget_host_impl.h
- +++ b/ui/views/cocoa/bridged_native_widget_host_impl.h
- @@ -431,11 +431,13 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
- // Display link for getting vsync info for |display_|.
- scoped_refptr<ui::DisplayLinkMac> display_link_;
-
- +#ifndef MAS_BUILD
- // Structure to avoid sending IOSurface mach ports over mojo.
- // https://crbug.com/942213
- class IOSurfaceToRemoteLayerInterceptor;
- std::unique_ptr<IOSurfaceToRemoteLayerInterceptor>
- io_surface_to_remote_layer_interceptor_;
- +#endif
-
- // The geometry of the window and its contents view, in screen coordinates.
- gfx::Rect window_bounds_in_screen_;
- diff --git a/ui/views/cocoa/bridged_native_widget_host_impl.mm b/ui/views/cocoa/bridged_native_widget_host_impl.mm
- index be87bb2cede4e859486cc5e4daa1ac435ee8fefa..dd3365aa841dc7d4d9c998ff097ffc8f21c811eb 100644
- --- a/ui/views/cocoa/bridged_native_widget_host_impl.mm
- +++ b/ui/views/cocoa/bridged_native_widget_host_impl.mm
- @@ -211,6 +211,8 @@ uint64_t g_last_bridged_native_widget_id = 0;
-
- } // namespace
-
- +#ifndef MAS_BUILD
- +
- // A gfx::CALayerParams may pass the content to be drawn across processes via
- // either an IOSurface (sent as mach port) or a CAContextID (which is an
- // integer). For historical reasons, software compositing uses IOSurfaces.
- @@ -265,6 +267,8 @@ class BridgedNativeWidgetHostImpl::IOSurfaceToRemoteLayerInterceptor {
- base::scoped_nsobject<CALayer> io_surface_layer_;
- };
-
- +#endif // MAS_BUILD
- +
- // static
- BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromNativeWindow(
- gfx::NativeWindow native_window) {
- @@ -1451,6 +1455,7 @@ void BridgedNativeWidgetHostImpl::AcceleratedWidgetCALayerParamsUpdated() {
- const gfx::CALayerParams* ca_layer_params =
- compositor_->widget()->GetCALayerParams();
- if (ca_layer_params) {
- +#ifndef MAS_BUILD
- // Replace IOSurface mach ports with CAContextIDs only when using the
- // out-of-process bridge (to reduce risk, because this workaround is being
- // merged to late-life-cycle release branches) and when an IOSurface
- @@ -1467,8 +1472,11 @@ void BridgedNativeWidgetHostImpl::AcceleratedWidgetCALayerParamsUpdated() {
- &updated_ca_layer_params);
- bridge_ptr_->SetCALayerParams(updated_ca_layer_params);
- } else {
- +#endif // MAS_BUILD
- bridge()->SetCALayerParams(*ca_layer_params);
- +#ifndef MAS_BUILD
- }
- +#endif // MAS_BUILD
- }
-
- // Take this opportunity to update the VSync parameters, if needed.
|