[tvOS] Adapt to "[ios blink] Use BELayerHierarchy for passing surfaces"
Also known as https://crrev.com/c/6254053, which introduced a code path dependent on BrowserEngineKit for iOS in some classes used by tvOS, like ImageTransportSurfaceOverlayMac and CALayerFrameSinkProvider. Try to disrupt the existing iOS code as little as possible while making tvOS work again by: - Adding some ifdefs and corresponding GN checks around BrowserEngineKit APIs and includes. - Making tvOS use the previous RWHV<->CALayerFrameSinkProvider code path by subclassing RenderWidgetHostViewIOS and making UpdateCALayerTree() use ui::DisplayCALayerTree. - Making CALayerFrameSinkProvider build without BrowserEngineKit again by varying its parent class depending on whether we are building for iOS or tvOS. Bug: 391914246 Cq-Include-Trybots: luci.chromium.try:ios-blink-dbg-fyi Change-Id: Ib4259daf5d81199c1cff4ede389716c97737905f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6343678 Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Mustafa Emre Acer <meacer@chromium.org> Reviewed-by: Colin Blundell <blundell@chromium.org> Commit-Queue: Raphael Kubo da Costa <kubo@igalia.com> Cr-Commit-Position: refs/heads/main@{#1431608}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
863efb11cb
commit
89caa0b7c8
@ -2861,7 +2861,11 @@ source_set("browser") {
|
||||
sources += [ "child_process_launcher_helper_ios.mm" ]
|
||||
frameworks += [ "BrowserEngineKit.framework" ]
|
||||
} else {
|
||||
sources += [ "child_process_launcher_helper_tvos.mm" ]
|
||||
sources += [
|
||||
"child_process_launcher_helper_tvos.mm",
|
||||
"renderer_host/render_widget_host_view_tvos.h",
|
||||
"renderer_host/render_widget_host_view_tvos.mm",
|
||||
]
|
||||
}
|
||||
|
||||
frameworks += [ "IOSurface.framework" ]
|
||||
|
37
content/browser/renderer_host/render_widget_host_view_tvos.h
Normal file
37
content/browser/renderer_host/render_widget_host_view_tvos.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_TVOS_H_
|
||||
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_TVOS_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "content/browser/renderer_host/render_widget_host_view_ios.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
class DisplayCALayerTree;
|
||||
|
||||
} // namespace ui
|
||||
|
||||
namespace content {
|
||||
|
||||
class CONTENT_EXPORT RenderWidgetHostViewTVOS : public RenderWidgetHostViewIOS {
|
||||
public:
|
||||
RenderWidgetHostViewTVOS(RenderWidgetHost* widget);
|
||||
~RenderWidgetHostViewTVOS() override;
|
||||
|
||||
RenderWidgetHostViewTVOS(const RenderWidgetHostViewTVOS&) = delete;
|
||||
RenderWidgetHostViewTVOS& operator=(const RenderWidgetHostViewTVOS&) = delete;
|
||||
|
||||
// ui::CALayerFrameSink overrides:
|
||||
void UpdateCALayerTree(const gfx::CALayerParams& ca_layer_params) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ui::DisplayCALayerTree> display_tree_;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_TVOS_H_
|
@ -0,0 +1,27 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/browser/renderer_host/render_widget_host_view_tvos.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include "ui/accelerated_widget_mac/display_ca_layer_tree.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
RenderWidgetHostViewTVOS::RenderWidgetHostViewTVOS(RenderWidgetHost* widget)
|
||||
: RenderWidgetHostViewIOS(widget) {
|
||||
display_tree_ =
|
||||
std::make_unique<ui::DisplayCALayerTree>([GetNativeView().Get() layer]);
|
||||
}
|
||||
|
||||
RenderWidgetHostViewTVOS::~RenderWidgetHostViewTVOS() = default;
|
||||
|
||||
void RenderWidgetHostViewTVOS::UpdateCALayerTree(
|
||||
const gfx::CALayerParams& ca_layer_params) {
|
||||
DCHECK(display_tree_);
|
||||
display_tree_->UpdateCALayerTree(ca_layer_params);
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -21,6 +21,10 @@
|
||||
#include "ui/base/cocoa/animation_utils.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
#if BUILDFLAG(IS_IOS_TVOS)
|
||||
#include "content/browser/renderer_host/render_widget_host_view_tvos.h"
|
||||
#endif
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
@ -30,6 +34,12 @@ WebContentsViewIOS::RenderWidgetHostViewCreateFunction
|
||||
|
||||
} // namespace
|
||||
|
||||
#if !BUILDFLAG(IS_IOS_TVOS)
|
||||
using RenderWidgetHostViewClass = RenderWidgetHostViewIOS;
|
||||
#else
|
||||
using RenderWidgetHostViewClass = RenderWidgetHostViewTVOS;
|
||||
#endif
|
||||
|
||||
// static
|
||||
void WebContentsViewIOS::InstallCreateHookForTests(
|
||||
RenderWidgetHostViewCreateFunction create_render_widget_host_view) {
|
||||
@ -211,12 +221,12 @@ RenderWidgetHostViewBase* WebContentsViewIOS::CreateViewForWidget(
|
||||
if (g_create_render_widget_host_view) {
|
||||
return g_create_render_widget_host_view(render_widget_host);
|
||||
}
|
||||
return new RenderWidgetHostViewIOS(render_widget_host);
|
||||
return new RenderWidgetHostViewClass(render_widget_host);
|
||||
}
|
||||
|
||||
RenderWidgetHostViewBase* WebContentsViewIOS::CreateViewForChildWidget(
|
||||
RenderWidgetHost* render_widget_host) {
|
||||
return new RenderWidgetHostViewIOS(render_widget_host);
|
||||
return new RenderWidgetHostViewClass(render_widget_host);
|
||||
}
|
||||
|
||||
void WebContentsViewIOS::SetPageTitle(const std::u16string& title) {
|
||||
|
@ -7,6 +7,10 @@ import("//components/nacl/toolchain.gni")
|
||||
import("//gpu/vulkan/features.gni")
|
||||
import("//mojo/public/tools/bindings/mojom.gni")
|
||||
|
||||
if (is_ios) {
|
||||
import("//build/config/apple/mobile_config.gni") # For `target_platform`
|
||||
}
|
||||
|
||||
group("common") {
|
||||
if (is_component_build) {
|
||||
public_deps = [ "//gpu" ]
|
||||
@ -158,7 +162,7 @@ source_set("ipc_common_sources") {
|
||||
frameworks = [ "IOSurface.framework" ]
|
||||
}
|
||||
|
||||
if (is_ios) {
|
||||
if (is_ios && target_platform == "iphoneos") {
|
||||
sources += [
|
||||
"ios/be_layer_hierarchy_transport.cc",
|
||||
"ios/be_layer_hierarchy_transport.h",
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "ui/display/types/display_constants.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
#if BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)
|
||||
#include <BrowserEngineKit/BrowserEngineKit.h>
|
||||
#endif
|
||||
|
||||
@ -110,7 +110,7 @@ class ImageTransportSurfaceOverlayMacEGL : public gl::Presenter {
|
||||
base::TimeDelta frame_interval_;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
#if BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)
|
||||
BELayerHierarchy* __strong layer_hierarchy_;
|
||||
#endif
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "ui/gfx/overlay_plane_data.h"
|
||||
#include "ui/gl/ca_renderer_layer_params.h"
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
#if BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)
|
||||
#include "gpu/ipc/common/ios/be_layer_hierarchy_transport.h"
|
||||
#endif
|
||||
|
||||
@ -124,7 +124,7 @@ ImageTransportSurfaceOverlayMacEGL::ImageTransportSurfaceOverlayMacEGL(
|
||||
ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
|
||||
!av_disabled_at_command_line, std::move(buffer_presented_callback));
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
#if BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)
|
||||
// The BELayerHierarchy needs to be created on a thread that supports
|
||||
// libdispatch, so we proxy over to the main dispatch queue to do that.
|
||||
CALayer* root_ca_layer = ca_layer_tree_coordinator_->root_ca_layer();
|
||||
@ -147,7 +147,7 @@ ImageTransportSurfaceOverlayMacEGL::ImageTransportSurfaceOverlayMacEGL(
|
||||
ImageTransportSurfaceOverlayMacEGL::~ImageTransportSurfaceOverlayMacEGL() {
|
||||
ca_layer_tree_coordinator_.reset();
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
#if BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS)
|
||||
BELayerHierarchy* layer_hierarchy = std::move(layer_hierarchy_);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[layer_hierarchy invalidate];
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/config/apple/mobile_config.gni")
|
||||
import("//testing/test.gni")
|
||||
|
||||
component("accelerated_widget_mac") {
|
||||
@ -36,7 +37,10 @@ component("accelerated_widget_mac") {
|
||||
"ca_layer_frame_sink_provider.h",
|
||||
"ca_layer_frame_sink_provider.mm",
|
||||
]
|
||||
frameworks += [ "BrowserEngineKit.framework" ]
|
||||
|
||||
if (target_platform == "iphoneos") {
|
||||
frameworks += [ "BrowserEngineKit.framework" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
@ -46,8 +50,6 @@ component("accelerated_widget_mac") {
|
||||
"accelerated_widget_mac_export.h",
|
||||
"ca_transaction_observer.h",
|
||||
"ca_transaction_observer.mm",
|
||||
"display_ca_layer_tree.h",
|
||||
"display_ca_layer_tree.mm",
|
||||
"io_surface_context.h",
|
||||
"io_surface_context.mm",
|
||||
"window_resize_helper_mac.cc",
|
||||
@ -57,6 +59,13 @@ component("accelerated_widget_mac") {
|
||||
frameworks += [ "OpenGL.framework" ]
|
||||
}
|
||||
|
||||
if (is_mac || (is_ios && target_platform != "iphoneos")) {
|
||||
sources += [
|
||||
"display_ca_layer_tree.h",
|
||||
"display_ca_layer_tree.mm",
|
||||
]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//components/metal_util",
|
||||
|
@ -5,18 +5,25 @@
|
||||
#ifndef UI_ACCELERATED_WIDGET_MAC_CA_LAYER_FRAME_SINK_PROVIDER_H_
|
||||
#define UI_ACCELERATED_WIDGET_MAC_CA_LAYER_FRAME_SINK_PROVIDER_H_
|
||||
|
||||
#include <BrowserEngineKit/BrowserEngineKit.h>
|
||||
#include <UIKit/UIKit.h>
|
||||
|
||||
#include "ui/accelerated_widget_mac/accelerated_widget_mac_export.h"
|
||||
#include "ui/gfx/ca_layer_params.h"
|
||||
#include "build/build_config.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
#if !BUILDFLAG(IS_IOS_TVOS)
|
||||
#include <BrowserEngineKit/BrowserEngineKit.h>
|
||||
#endif // !BUILDFLAG(IS_IOS_TVOS)
|
||||
|
||||
namespace ui {
|
||||
class CALayerFrameSink;
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_IOS_TVOS)
|
||||
@interface CALayerFrameSinkProvider : BELayerHierarchyHostingView
|
||||
#else
|
||||
@interface CALayerFrameSinkProvider : UIView
|
||||
#endif
|
||||
|
||||
- (id)init;
|
||||
- (ui::CALayerFrameSink*)frameSink;
|
||||
- (gfx::AcceleratedWidget)viewHandle;
|
||||
|
Reference in New Issue
Block a user