|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Cheng Zhao <zcbenz@gmail.com> |
| 3 | +Date: Thu, 20 Sep 2018 17:48:49 -0700 |
| 4 | +Subject: mas_disable_remote_layer.patch |
| 5 | + |
| 6 | +Disable remote layer APIs (CAContext and CALayerHost) for MAS build. |
| 7 | + |
| 8 | +diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h |
| 9 | +index f343b7e0e04a..d0ecefd4333c 100644 |
| 10 | +--- a/gpu/ipc/service/image_transport_surface_overlay_mac.h |
| 11 | ++++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h |
| 12 | +@@ -20,7 +20,9 @@ |
| 13 | + #include "ui/gl/gl_surface_egl.h" |
| 14 | + #endif |
| 15 | + |
| 16 | ++#ifndef MAS_BUILD |
| 17 | + @class CAContext; |
| 18 | ++#endif |
| 19 | + @class CALayer; |
| 20 | + |
| 21 | + namespace ui { |
| 22 | +@@ -97,7 +99,9 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass, |
| 23 | + base::WeakPtr<ImageTransportSurfaceDelegate> delegate_; |
| 24 | + |
| 25 | + bool use_remote_layer_api_; |
| 26 | ++#ifndef MAS_BUILD |
| 27 | + base::scoped_nsobject<CAContext> ca_context_; |
| 28 | ++#endif |
| 29 | + std::unique_ptr<ui::CALayerTreeCoordinator> ca_layer_tree_coordinator_; |
| 30 | + |
| 31 | + gfx::Size pixel_size_; |
| 32 | +diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm |
| 33 | +index 10b345d3727c..b52f03be6351 100644 |
| 34 | +--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm |
| 35 | ++++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm |
| 36 | +@@ -63,6 +63,7 @@ |
| 37 | + template <typename BaseClass> |
| 38 | + bool ImageTransportSurfaceOverlayMacBase<BaseClass>::Initialize( |
| 39 | + gl::GLSurfaceFormat format) { |
| 40 | ++#ifndef MAS_BUILD |
| 41 | + // Create the CAContext to send this to the GPU process, and the layer for |
| 42 | + // the context. |
| 43 | + if (use_remote_layer_api_) { |
| 44 | +@@ -71,6 +72,7 @@ |
| 45 | + [CAContext contextWithCGSConnection:connection_id options:@{}] retain]); |
| 46 | + [ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()]; |
| 47 | + } |
| 48 | ++#endif |
| 49 | + return true; |
| 50 | + } |
| 51 | + |
| 52 | +@@ -136,7 +138,9 @@ |
| 53 | + "GLImpl", static_cast<int>(gl::GetGLImplementation()), |
| 54 | + "width", pixel_size_.width()); |
| 55 | + if (use_remote_layer_api_) { |
| 56 | ++#ifndef MAS_BUILD |
| 57 | + params.ca_layer_params.ca_context_id = [ca_context_ contextId]; |
| 58 | ++#endif |
| 59 | + } else { |
| 60 | + IOSurfaceRef io_surface = |
| 61 | + ca_layer_tree_coordinator_->GetIOSurfaceForDisplay(); |
| 62 | +diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm |
| 63 | +index 60abe639bd9c..c38eed5fbdef 100644 |
| 64 | +--- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm |
| 65 | ++++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm |
| 66 | +@@ -98,6 +98,7 @@ - (void)setContentsChanged; |
| 67 | + } |
| 68 | + |
| 69 | + void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) { |
| 70 | ++#ifndef MAS_BUILD |
| 71 | + // Early-out if the remote layer has not changed. |
| 72 | + if ([remote_layer_ contextId] == ca_context_id) |
| 73 | + return; |
| 74 | +@@ -122,6 +123,9 @@ - (void)setContentsChanged; |
| 75 | + [io_surface_layer_ removeFromSuperlayer]; |
| 76 | + io_surface_layer_.reset(); |
| 77 | + } |
| 78 | ++#else |
| 79 | ++ NOTREACHED() << "Remote layer is being used in MAS build"; |
| 80 | ++#endif |
| 81 | + } |
| 82 | + |
| 83 | + void DisplayCALayerTree::GotIOSurfaceFrame( |
| 84 | +diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h |
| 85 | +index 2057fe69d1bb..2aba330fc488 100644 |
| 86 | +--- a/ui/base/cocoa/remote_layer_api.h |
| 87 | ++++ b/ui/base/cocoa/remote_layer_api.h |
| 88 | +@@ -13,6 +13,7 @@ |
| 89 | + |
| 90 | + #include "ui/base/ui_base_export.h" |
| 91 | + |
| 92 | ++#ifndef MAS_BUILD |
| 93 | + // The CGSConnectionID is used to create the CAContext in the process that is |
| 94 | + // going to share the CALayers that it is rendering to another process to |
| 95 | + // display. |
| 96 | +@@ -50,6 +51,8 @@ typedef uint32_t CAContextID; |
| 97 | + |
| 98 | + #endif // __OBJC__ |
| 99 | + |
| 100 | ++#endif // MAS_BUILD |
| 101 | ++ |
| 102 | + namespace ui { |
| 103 | + |
| 104 | + // This function will check if all of the interfaces listed above are supported |
| 105 | +diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm |
| 106 | +index bbaf9f466f49..8c846ce9523a 100644 |
| 107 | +--- a/ui/base/cocoa/remote_layer_api.mm |
| 108 | ++++ b/ui/base/cocoa/remote_layer_api.mm |
| 109 | +@@ -12,6 +12,7 @@ |
| 110 | + namespace ui { |
| 111 | + |
| 112 | + bool RemoteLayerAPISupported() { |
| 113 | ++#ifndef MAS_BUILD |
| 114 | + static bool disabled_at_command_line = |
| 115 | + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 | + switches::kDisableRemoteCoreAnimation); |
| 117 | +@@ -46,6 +47,9 @@ bool RemoteLayerAPISupported() { |
| 118 | + |
| 119 | + // If everything is there, we should be able to use the API. |
| 120 | + return true; |
| 121 | ++#else |
| 122 | ++ return false; |
| 123 | ++#endif // MAS_BUILD |
| 124 | + } |
| 125 | + |
| 126 | + } // namespace |
| 127 | +diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h |
| 128 | +index 528ec883d226..5058eb6048a6 100644 |
| 129 | +--- a/ui/views/cocoa/native_widget_mac_ns_window_host.h |
| 130 | ++++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h |
| 131 | +@@ -446,11 +446,13 @@ class VIEWS_EXPORT NativeWidgetMacNSWindowHost |
| 132 | + // Display link for getting vsync info for |display_|. |
| 133 | + scoped_refptr<ui::DisplayLinkMac> display_link_; |
| 134 | + |
| 135 | ++#ifndef MAS_BUILD |
| 136 | + // Structure to avoid sending IOSurface mach ports over mojo. |
| 137 | + // https://crbug.com/942213 |
| 138 | + class IOSurfaceToRemoteLayerInterceptor; |
| 139 | + std::unique_ptr<IOSurfaceToRemoteLayerInterceptor> |
| 140 | + io_surface_to_remote_layer_interceptor_; |
| 141 | ++#endif |
| 142 | + |
| 143 | + // The geometry of the window and its contents view, in screen coordinates. |
| 144 | + gfx::Rect window_bounds_in_screen_; |
| 145 | +diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm |
| 146 | +index 6aa9e71245f1..89eb028e840b 100644 |
| 147 | +--- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm |
| 148 | ++++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm |
| 149 | +@@ -213,6 +213,7 @@ bool PositionWindowInScreenCoordinates(Widget* widget, |
| 150 | + |
| 151 | + } // namespace |
| 152 | + |
| 153 | ++#ifndef MAS_BUILD |
| 154 | + // A gfx::CALayerParams may pass the content to be drawn across processes via |
| 155 | + // either an IOSurface (sent as mach port) or a CAContextID (which is an |
| 156 | + // integer). For historical reasons, software compositing uses IOSurfaces. |
| 157 | +@@ -267,6 +268,8 @@ void UpdateCALayerParams(gfx::CALayerParams* ca_layer_params) { |
| 158 | + base::scoped_nsobject<CALayer> io_surface_layer_; |
| 159 | + }; |
| 160 | + |
| 161 | ++#endif // MAS_BUILD |
| 162 | ++ |
| 163 | + // static |
| 164 | + NativeWidgetMacNSWindowHost* NativeWidgetMacNSWindowHost::GetFromNativeWindow( |
| 165 | + gfx::NativeWindow native_window) { |
| 166 | +@@ -1472,6 +1475,7 @@ void UpdateCALayerParams(gfx::CALayerParams* ca_layer_params) { |
| 167 | + const gfx::CALayerParams* ca_layer_params = |
| 168 | + compositor_->widget()->GetCALayerParams(); |
| 169 | + if (ca_layer_params) { |
| 170 | ++#ifndef MAS_BUILD |
| 171 | + // Replace IOSurface mach ports with CAContextIDs only when using the |
| 172 | + // out-of-process bridge (to reduce risk, because this workaround is being |
| 173 | + // merged to late-life-cycle release branches) and when an IOSurface |
| 174 | +@@ -1488,8 +1492,11 @@ void UpdateCALayerParams(gfx::CALayerParams* ca_layer_params) { |
| 175 | + &updated_ca_layer_params); |
| 176 | + remote_ns_window_ptr_->SetCALayerParams(updated_ca_layer_params); |
| 177 | + } else { |
| 178 | ++#endif // MAS_BUILD |
| 179 | + GetNSWindowMojo()->SetCALayerParams(*ca_layer_params); |
| 180 | ++#ifndef MAS_BUILD |
| 181 | + } |
| 182 | ++#endif // MAS_BUILD |
| 183 | + } |
| 184 | + |
| 185 | + // Take this opportunity to update the VSync parameters, if needed. |
0 commit comments