From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Cheng Zhao 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 29b75456a779ff9c36bb0cc2cdc4a1b2a1aa5966..4157e90fdbc265ab34405e4e9c1efbff06c26d70 100644 --- a/gpu/ipc/service/image_transport_surface_overlay_mac.h +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h @@ -18,7 +18,9 @@ #include "ui/gl/gpu_switching_observer.h" #include "ui/gl/presenter.h" +#if !IS_MAS_BUILD() @class CAContext; +#endif @class CALayer; namespace ui { @@ -89,7 +91,9 @@ class ImageTransportSurfaceOverlayMacEGL : public gl::Presenter, base::WeakPtr delegate_; bool use_remote_layer_api_; +#if !IS_MAS_BUILD() base::scoped_nsobject ca_context_; +#endif std::unique_ptr 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 e2b4368c08ba9e30cb46218988c6212a46c98217..02db1e7041f18bae8c90539fee0e768b353fa523 100644 --- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm @@ -74,12 +74,14 @@ // Create the CAContext to send this to the GPU process, and the layer for // the context. +#if !IS_MAS_BUILD() if (use_remote_layer_api_) { CGSConnectionID connection_id = CGSMainConnectionID(); ca_context_.reset([[CAContext contextWithCGSConnection:connection_id options:@{}] retain]); [ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()]; } +#endif } ImageTransportSurfaceOverlayMacEGL::~ImageTransportSurfaceOverlayMacEGL() { @@ -174,7 +176,9 @@ "GLImpl", static_cast(gl::GetGLImplementation()), "width", pixel_size_.width()); if (use_remote_layer_api_) { +#if !IS_MAS_BUILD() 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 2c4821b34f71d30ce814bd1f3cf9a7a76bbaac66..c7dc371c780a405f502a84c77e92251ae08f66e0 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) { +#if !IS_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 9b691e2f16c68235dd180a28b6eb2eefc91f8e4c..9d4a7fb36e671980024b895eaafab2d970ac2818 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" +#if !IS_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 e23eb7719a9798afe984c6af6a422167b93d89b5..d448bc09ee54fc77f1ed4d088d1369b96f83a1db 100644 --- a/ui/base/cocoa/remote_layer_api.mm +++ b/ui/base/cocoa/remote_layer_api.mm @@ -10,6 +10,7 @@ namespace ui { +#if !IS_MAS_BUILD() namespace { // Control use of cross-process CALayers to display content directly from the // GPU process on Mac. @@ -17,8 +18,10 @@ "RemoteCoreAnimationAPI", base::FEATURE_ENABLED_BY_DEFAULT); } // namespace +#endif bool RemoteLayerAPISupported() { +#if !IS_MAS_BUILD() if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI)) return false; @@ -50,6 +53,9 @@ bool RemoteLayerAPISupported() { // If everything is there, we should be able to use the API. return true; +#else + return false; +#endif // MAS_BUILD } } // namespace