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
|
2021-05-19 18:20:12 +00:00
|
|
|
Subject: mas: disable remote layer APIs (CAContext and CALayerHost) for MAS
|
|
|
|
build
|
2020-02-24 03:08:57 +00:00
|
|
|
|
|
|
|
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
|
2023-07-16 14:14:43 +00:00
|
|
|
index c4eda85ebb59f2f9fc440c93590b99d1e8a16447..5f518ffa672ef62a94dd043e5bc4a53c8775defa 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
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -28,7 +28,9 @@
|
|
|
|
#error "This file requires ARC support."
|
2023-05-10 14:47:48 +00:00
|
|
|
#endif
|
2020-03-03 21:35:05 +00:00
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-03-03 21:35:05 +00:00
|
|
|
@class CAContext;
|
|
|
|
+#endif
|
|
|
|
@class CALayer;
|
|
|
|
|
|
|
|
namespace ui {
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -83,8 +85,10 @@ class ImageTransportSurfaceOverlayMacEGL : public gl::Presenter {
|
2023-03-10 16:07:42 +00:00
|
|
|
|
2020-03-03 21:35:05 +00:00
|
|
|
base::WeakPtr<ImageTransportSurfaceDelegate> delegate_;
|
|
|
|
|
2023-03-20 11:06:57 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
|
|
|
const bool use_remote_layer_api_;
|
2023-07-16 14:14:43 +00:00
|
|
|
CAContext* __strong ca_context_;
|
2020-03-03 21:35:05 +00:00
|
|
|
+#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
|
2023-07-20 07:36:59 +00:00
|
|
|
index 2972a8ad8e4eaffbc798ee57cd94400661f854bc..99b3dab8d0b29ffea8f11f3a15ccb90d42537a02 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
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -57,7 +57,9 @@
|
2023-03-10 16:07:42 +00:00
|
|
|
ImageTransportSurfaceOverlayMacEGL::ImageTransportSurfaceOverlayMacEGL(
|
|
|
|
base::WeakPtr<ImageTransportSurfaceDelegate> delegate)
|
|
|
|
: delegate_(delegate),
|
2023-03-20 11:06:57 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2023-03-10 16:07:42 +00:00
|
|
|
use_remote_layer_api_(ui::RemoteLayerAPISupported()),
|
2023-03-20 11:06:57 +00:00
|
|
|
+#endif
|
2023-03-10 16:07:42 +00:00
|
|
|
scale_factor_(1),
|
2023-03-20 11:06:57 +00:00
|
|
|
weak_ptr_factory_(this) {
|
2023-05-10 14:47:48 +00:00
|
|
|
static bool av_disabled_at_command_line =
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -69,6 +71,7 @@
|
2023-03-10 16:07:42 +00:00
|
|
|
->workarounds()
|
|
|
|
.disable_av_sample_buffer_display_layer;
|
2020-06-22 17:35:10 +00:00
|
|
|
|
2023-03-20 11:06:57 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2023-03-10 16:07:42 +00:00
|
|
|
ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
|
|
|
|
use_remote_layer_api_, allow_av_sample_buffer_display_layer);
|
2020-02-24 03:08:57 +00:00
|
|
|
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -89,6 +92,10 @@
|
2023-03-20 11:06:57 +00:00
|
|
|
#endif
|
2023-07-16 14:14:43 +00:00
|
|
|
ca_context_.layer = ca_layer_tree_coordinator_->GetCALayerForDisplay();
|
2023-03-20 11:06:57 +00:00
|
|
|
}
|
|
|
|
+#else
|
|
|
|
+ ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
|
|
|
|
+ /*allow_remote_layers=*/false, allow_av_sample_buffer_display_layer);
|
|
|
|
+#endif
|
|
|
|
|
2023-05-10 14:47:48 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
|
|
if (features::UseGpuVsync()) {
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -180,9 +187,13 @@
|
2023-03-10 16:07:42 +00:00
|
|
|
TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", TRACE_EVENT_SCOPE_THREAD,
|
2020-02-24 03:08:57 +00:00
|
|
|
"GLImpl", static_cast<int>(gl::GetGLImplementation()),
|
|
|
|
"width", pixel_size_.width());
|
2023-03-20 11:06:57 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-02-24 03:08:57 +00:00
|
|
|
if (use_remote_layer_api_) {
|
2022-06-27 20:50:08 +00:00
|
|
|
params.ca_context_id = [ca_context_ contextId];
|
2020-02-24 03:08:57 +00:00
|
|
|
} else {
|
2023-03-20 11:06:57 +00:00
|
|
|
+#else
|
|
|
|
+ if (true) {
|
|
|
|
+#endif
|
|
|
|
IOSurfaceRef io_surface =
|
|
|
|
ca_layer_tree_coordinator_->GetIOSurfaceForDisplay();
|
|
|
|
if (io_surface) {
|
2020-02-24 03:08:57 +00:00
|
|
|
diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
2023-07-16 14:14:43 +00:00
|
|
|
index 9f4869f00f31c6d3ad5081b1e7b67c4cf495fbdd..228b8d2e8835dc3a4f0454521a2bbd523cfd8933 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
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -124,6 +124,7 @@ - (void)setContentsChanged;
|
2020-02-24 03:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-02-24 03:08:57 +00:00
|
|
|
// Early-out if the remote layer has not changed.
|
2023-07-16 14:14:43 +00:00
|
|
|
if (remote_layer_.contextId == ca_context_id) {
|
2020-02-24 03:08:57 +00:00
|
|
|
return;
|
2023-07-16 14:14:43 +00:00
|
|
|
@@ -153,6 +154,9 @@ - (void)setContentsChanged;
|
2020-02-24 03:08:57 +00:00
|
|
|
[io_surface_layer_ removeFromSuperlayer];
|
2023-07-16 14:14:43 +00:00
|
|
|
io_surface_layer_ = nil;
|
2020-02-24 03:08:57 +00:00
|
|
|
}
|
|
|
|
+#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
|
2023-06-09 23:08:36 +00:00
|
|
|
index 59dc2f82214cfd883b6ebef3b0fb25af6387a9cd..d585ba14b34021a93c878d0d9f9d9ef70eed32ca 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
|
2023-03-20 11:06:57 +00:00
|
|
|
@@ -17,6 +17,7 @@
|
2020-02-24 03:08:57 +00:00
|
|
|
|
2023-03-20 11:06:57 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2020-02-24 03:08:57 +00:00
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2020-02-24 03:08:57 +00:00
|
|
|
// 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.
|
2023-03-20 11:06:57 +00:00
|
|
|
@@ -68,6 +69,8 @@ extern NSString* const kCAContextIgnoresHitTest;
|
2020-02-24 03:08:57 +00:00
|
|
|
|
2023-03-20 11:06:57 +00:00
|
|
|
#endif // __OBJC__
|
2020-02-24 03:08:57 +00:00
|
|
|
|
|
|
|
+#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
|
2023-06-09 23:08:36 +00:00
|
|
|
index 4aaf26f077c397184e2a304ecb827377b002b8bf..65ff1f2d0c9118734f86d3ecfc720a2f4415241f 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
|
2023-06-09 23:08:36 +00:00
|
|
|
@@ -14,6 +14,7 @@
|
2022-02-10 02:58:52 +00:00
|
|
|
|
2020-02-24 03:08:57 +00:00
|
|
|
namespace ui {
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2022-02-10 02:58:52 +00:00
|
|
|
namespace {
|
|
|
|
// Control use of cross-process CALayers to display content directly from the
|
|
|
|
// GPU process on Mac.
|
2023-06-09 23:08:36 +00:00
|
|
|
@@ -21,8 +22,10 @@
|
2022-10-03 20:21:00 +00:00
|
|
|
"RemoteCoreAnimationAPI",
|
|
|
|
base::FEATURE_ENABLED_BY_DEFAULT);
|
2022-02-10 02:58:52 +00:00
|
|
|
} // namespace
|
|
|
|
+#endif
|
|
|
|
|
2020-02-24 03:08:57 +00:00
|
|
|
bool RemoteLayerAPISupported() {
|
2022-11-14 20:46:52 +00:00
|
|
|
+#if !IS_MAS_BUILD()
|
2022-02-10 02:58:52 +00:00
|
|
|
if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI))
|
|
|
|
return false;
|
|
|
|
|
2023-06-09 23:08:36 +00:00
|
|
|
@@ -59,6 +62,9 @@ bool RemoteLayerAPISupported() {
|
2020-02-24 03:08:57 +00:00
|
|
|
|
|
|
|
// If everything is there, we should be able to use the API.
|
|
|
|
return true;
|
|
|
|
+#else
|
|
|
|
+ return false;
|
|
|
|
+#endif // MAS_BUILD
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|