electron/patches/chromium/mas_disable_remote_layer.patch
electron-roller[bot] 49e62f1261
chore: bump chromium to 95.0.4629.0 (main) (#30676)
* chore: bump chromium in DEPS to 95.0.4620.0

* chore: update patches

* 3076261: Move args_ to private in ExtensionFunction

https://chromium-review.googlesource.com/c/chromium/src/+/3076261

* [GURL -> SiteForCookies] content/public/browser/content_browser_client.h

https://chromium-review.googlesource.com/c/chromium/src/+/3107759

* chore: fix -Wunreachable-code-return in node

* Tracing to diagnose ContentScriptTracker-related bad message reports

https://chromium-review.googlesource.com/c/chromium/src/+/3057922

* chore: bump chromium in DEPS to 95.0.4621.0

* chore: update patches

* Remove title from the URL format on Windows.

https://chromium-review.googlesource.com/c/chromium/src/+/3108445

* chore: bump chromium in DEPS to 95.0.4623.0

* Revert "chore: disable v8 oilpan"

This reverts commit 5d255cf1d8e8efbb906047937a713279e5f800d0.

(cherry picked from commit ba5cde4da2428020d99b7fb603c702878f95da78)

* Change file paths in network context params to be relative.

https://chromium-review.googlesource.com/c/chromium/src/+/3092927

* Code Health: Rename/replace content::WebUI::RegisterMessageCallback().

https://chromium-review.googlesource.com/c/chromium/src/+/3104691

* Migrate CanExecuteContentScriptSync to Mojo

https://chromium-review.googlesource.com/c/chromium/src/+/3108452

* chore: update patches

* remove unreachable code

* Revert "Revert "chore: disable v8 oilpan""

This reverts commit fef495c0294e21760df51bddb5f7bf1ec9ed5f1e.

* fixup mas patch

* Reland "[include] Split out v8.h"

https://chromium-review.googlesource.com/c/v8/v8/+/3113629

* chore: bump chromium in DEPS to 95.0.4624.0

* chore: bump chromium in DEPS to 95.0.4625.0

* chore: bump chromium in DEPS to 95.0.4626.0

* 3033504: Pass NavigationDownloadPolicy in CreateNewWindowParams

https://chromium-review.googlesource.com/c/chromium/src/+/3033504

* 3058038: Introduce TestPrintingContext & test UpdatePrintSettings

https://chromium-review.googlesource.com/c/chromium/src/+/3058038

* 3114943: [Conditional Focus][#4] Add tests and remove flag gating

https://chromium-review.googlesource.com/c/chromium/src/+/3114943

* chore: update patch indices

* chore: bump chromium in DEPS to 95.0.4627.0

* chore: update patches

* 3093591: ozone: webpagepopups: calculate anchor for menu bounds. 4/*

https://chromium-review.googlesource.com/c/chromium/src/+/3093591

* 3110414: [PA] Remove the leading cookie

https://chromium-review.googlesource.com/c/chromium/src/+/3110414

* chore: update patches

* 3076261: Move args_ to private in ExtensionFunction

https://chromium-review.googlesource.com/c/chromium/src/+/3076261

* 3113629: Reland "[include] Split out v8.h"

https://chromium-review.googlesource.com/c/v8/v8/+/3113629

* chore: bump chromium in DEPS to 95.0.4628.0

* chore: update patches

* chore: bump chromium in DEPS to 95.0.4629.0

* chore: update patches

* Fix chrome root store codegen for cross-compile builds.

https://chromium-review.googlesource.com/c/chromium/src/+/3133701

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-09-01 15:55:07 -04:00

137 lines
5 KiB
Diff

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 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).
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
index c49b1befb9cd7bdcb5982db014ced3203b4fd561..c2a9347da27bc51cc2216520801d410c467f9b0b 100644
--- 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 {
@@ -118,7 +120,9 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
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_;
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
index d7d7ab38ed248663bf0bb08a72b591c87e0b9459..07e243419f6d52af992fbdd009dce2d08f8adde2 100644
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
@@ -53,7 +53,7 @@
ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
use_remote_layer_api_, allow_av_sample_buffer_display_layer);
-
+#ifndef MAS_BUILD
// Create the CAContext to send this to the GPU process, and the layer for
// the context.
if (use_remote_layer_api_) {
@@ -62,6 +62,7 @@
options:@{}] retain]);
[ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
}
+#endif
}
template <typename BaseClass>
@@ -142,7 +143,9 @@
"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
index a55934320e475af475f7169a5b30954c7e98d775..78d626f2c5be20106ebd54b71a9b0663c55086da 100644
--- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
+++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
@@ -99,6 +99,7 @@ - (void)setContentsChanged;
}
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;
@@ -123,6 +124,9 @@ - (void)setContentsChanged;
[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
index d684614589c9e55965450d712ee6dc0deef6aade..e0446753a3d972215423c079160fe8bfd2f9c3be 100644
--- a/ui/base/cocoa/remote_layer_api.h
+++ b/ui/base/cocoa/remote_layer_api.h
@@ -13,6 +13,7 @@
#include "base/component_export.h"
+#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
index bbaf9f466f4999acb5bfccf3b9565fd8f556ca2f..8c846ce9523a4b2f6fbdbdbeae4f94b45ac3c115 100644
--- 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