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-03-15 09:20:32 +00:00
|
|
|
index 4f3673c2766993d9c41a1bc8013a9b26e31d37ce..4d9ca8c945c22801c172d4243bd50653cd441721 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-03-10 16:07:42 +00:00
|
|
|
@@ -17,7 +17,9 @@
|
|
|
|
#include "ui/gl/gl_surface.h"
|
2023-01-06 02:35:34 +00:00
|
|
|
#include "ui/gl/presenter.h"
|
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-03-15 09:20:32 +00:00
|
|
|
@@ -73,10 +75,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-10 16:07:42 +00:00
|
|
|
-#if BUILDFLAG(IS_MAC)
|
|
|
|
+#if BUILDFLAG(IS_MAC) && !IS_MAS_BUILD()
|
2020-03-03 21:35:05 +00:00
|
|
|
bool use_remote_layer_api_;
|
2023-03-10 16:07:42 +00:00
|
|
|
-#endif
|
2020-03-03 21:35:05 +00:00
|
|
|
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
|
2023-03-15 09:20:32 +00:00
|
|
|
index 34723c177874131ae7859671338b7da0be4da24a..1c6d47bae1ffbb621692d412f79a9c4ba5f7df83 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-03-10 16:07:42 +00:00
|
|
|
@@ -55,7 +55,7 @@
|
|
|
|
ImageTransportSurfaceOverlayMacEGL::ImageTransportSurfaceOverlayMacEGL(
|
|
|
|
base::WeakPtr<ImageTransportSurfaceDelegate> delegate)
|
|
|
|
: delegate_(delegate),
|
|
|
|
-#if BUILDFLAG(IS_MAC)
|
|
|
|
+#if BUILDFLAG(IS_MAC) && !IS_MAS_BUILD()
|
|
|
|
use_remote_layer_api_(ui::RemoteLayerAPISupported()),
|
|
|
|
#endif
|
|
|
|
scale_factor_(1),
|
|
|
|
@@ -71,7 +71,7 @@
|
|
|
|
->workarounds()
|
|
|
|
.disable_av_sample_buffer_display_layer;
|
2020-06-22 17:35:10 +00:00
|
|
|
|
2023-03-10 16:07:42 +00:00
|
|
|
-#if BUILDFLAG(IS_MAC)
|
|
|
|
+#if BUILDFLAG(IS_MAC) && !IS_MAS_BUILD()
|
|
|
|
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-03-10 16:07:42 +00:00
|
|
|
@@ -168,7 +168,7 @@
|
|
|
|
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-10 16:07:42 +00:00
|
|
|
-#if BUILDFLAG(IS_MAC)
|
|
|
|
+#if BUILDFLAG(IS_MAC) && !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 {
|
|
|
|
diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
2022-11-14 20:46:52 +00:00
|
|
|
index 2c4821b34f71d30ce814bd1f3cf9a7a76bbaac66..c7dc371c780a405f502a84c77e92251ae08f66e0 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) {
|
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.
|
|
|
|
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
|
2022-11-14 20:46:52 +00:00
|
|
|
index 9b691e2f16c68235dd180a28b6eb2eefc91f8e4c..9d4a7fb36e671980024b895eaafab2d970ac2818 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
|
|
|
|
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.
|
|
|
|
@@ -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
|
2022-11-14 20:46:52 +00:00
|
|
|
index e23eb7719a9798afe984c6af6a422167b93d89b5..d448bc09ee54fc77f1ed4d088d1369b96f83a1db 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
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -10,6 +10,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.
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -17,8 +18,10 @@
|
|
|
|
"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;
|
|
|
|
|
2022-10-03 20:21:00 +00:00
|
|
|
@@ -50,6 +53,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
|