2020-02-24 03:08:57 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
|
|
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.
|
|
|
|
|
|
|
|
Accordin to ccameron:
|
|
|
|
|
|
|
|
For apps that spend a lot of time watching video (especially fullscreen video),
|
|
|
|
the power/battery usage will likely increase 1.5x to 2x. For something that is,
|
|
|
|
e.g, scrolling, it'll be smaller, more like 1.15x or 1.25x.
|
|
|
|
|
|
|
|
In terms of performance, the impact will likely be fairly small -- any app that
|
|
|
|
could hit 60fps before will likely still be able to hit 60fps. There may even be
|
|
|
|
cases where performance improves when disabling remote CoreAnimation (remote
|
|
|
|
CoreAnimation is really only about battery usage).
|
|
|
|
|
2020-03-03 21:35:05 +00:00
|
|
|
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
2020-07-14 01:13:34 +00:00
|
|
|
index d565d2ab23d7a42e6787b58103fd40a8675b8e28..4cb9681c1f810a0cbd7f7ef04c4a7c73ca10c2b0 100644
|
2020-03-03 21:35:05 +00:00
|
|
|
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
|
|
|
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
|
|
|
@@ -20,7 +20,9 @@
|
|
|
|
#include "ui/gl/gl_surface_egl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
@class CAContext;
|
|
|
|
+#endif
|
|
|
|
@class CALayer;
|
|
|
|
|
|
|
|
namespace ui {
|
2020-07-14 01:13:34 +00:00
|
|
|
@@ -116,7 +118,9 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
|
2020-03-03 21:35:05 +00:00
|
|
|
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_;
|
2020-02-24 03:08:57 +00:00
|
|
|
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
2020-07-14 01:13:34 +00:00
|
|
|
index 67e0efb23c717c3194f27695215a8bd20dbbb957..cf02fab328d9fe7a6e9f53c712a7c1c871b8b304 100644
|
2020-02-24 03:08:57 +00:00
|
|
|
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
|
|
|
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -51,7 +51,7 @@
|
2020-06-22 17:35:10 +00:00
|
|
|
|
|
|
|
ca_layer_tree_coordinator_.reset(new ui::CALayerTreeCoordinator(
|
|
|
|
use_remote_layer_api_, allow_av_sample_buffer_display_layer));
|
|
|
|
-
|
2020-02-24 03:08:57 +00:00
|
|
|
+#ifndef MAS_BUILD
|
|
|
|
// Create the CAContext to send this to the GPU process, and the layer for
|
|
|
|
// the context.
|
|
|
|
if (use_remote_layer_api_) {
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -60,6 +60,7 @@
|
2020-06-22 17:35:10 +00:00
|
|
|
options:@{}] retain]);
|
2020-02-24 03:08:57 +00:00
|
|
|
[ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
2020-06-22 17:35:10 +00:00
|
|
|
template <typename BaseClass>
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -140,7 +141,9 @@
|
2020-02-24 03:08:57 +00:00
|
|
|
"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
|
2020-10-16 01:30:41 +00:00
|
|
|
index a55934320e475af475f7169a5b30954c7e98d775..78d626f2c5be20106ebd54b71a9b0663c55086da 100644
|
2020-02-24 03:08:57 +00:00
|
|
|
--- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
|
|
|
+++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
2020-10-16 01:30:41 +00:00
|
|
|
@@ -99,6 +99,7 @@ - (void)setContentsChanged;
|
2020-02-24 03:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-10-16 01:30:41 +00:00
|
|
|
@@ -123,6 +124,9 @@ - (void)setContentsChanged;
|
2020-02-24 03:08:57 +00:00
|
|
|
[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
|
2020-05-26 20:06:26 +00:00
|
|
|
index d684614589c9e55965450d712ee6dc0deef6aade..e0446753a3d972215423c079160fe8bfd2f9c3be 100644
|
2020-02-24 03:08:57 +00:00
|
|
|
--- a/ui/base/cocoa/remote_layer_api.h
|
|
|
|
+++ b/ui/base/cocoa/remote_layer_api.h
|
|
|
|
@@ -13,6 +13,7 @@
|
|
|
|
|
2020-05-26 20:06:26 +00:00
|
|
|
#include "base/component_export.h"
|
2020-02-24 03:08:57 +00:00
|
|
|
|
|
|
|
+#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
|
2020-03-03 21:35:05 +00:00
|
|
|
index bbaf9f466f4999acb5bfccf3b9565fd8f556ca2f..8c846ce9523a4b2f6fbdbdbeae4f94b45ac3c115 100644
|
2020-02-24 03:08:57 +00:00
|
|
|
--- 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
|