mas_disable_remote_layer.patch 7.4 KB

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