Flutter Engine
 
Loading...
Searching...
No Matches
shell_test_platform_view.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <memory>
8
10
11namespace flutter::testing {
12
13std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::Create(
14 BackendType backend,
15 PlatformView::Delegate& delegate,
16 const TaskRunners& task_runners,
17 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
18 const CreateVsyncWaiter& create_vsync_waiter,
19 const std::shared_ptr<ShellTestExternalViewEmbedder>&
20 shell_test_external_view_embedder,
21 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
22 // TODO(gw280): https://github.com/flutter/flutter/issues/50298
23 // Make this fully runtime configurable
24 switch (backend) {
25 case BackendType::kGLBackend:
26 return CreateGL(delegate, task_runners, vsync_clock, create_vsync_waiter,
27 shell_test_external_view_embedder,
28 is_gpu_disabled_sync_switch);
29 case BackendType::kMetalBackend:
30 return CreateMetal(delegate, task_runners, vsync_clock,
31 create_vsync_waiter, shell_test_external_view_embedder,
32 is_gpu_disabled_sync_switch);
33 case BackendType::kVulkanBackend:
34 return CreateVulkan(
35 delegate, task_runners, vsync_clock, create_vsync_waiter,
36 shell_test_external_view_embedder, is_gpu_disabled_sync_switch);
37 }
38}
39
40#ifndef SHELL_ENABLE_GL
41std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::CreateGL(
42 PlatformView::Delegate& delegate,
43 const TaskRunners& task_runners,
44 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
45 const CreateVsyncWaiter& create_vsync_waiter,
46 const std::shared_ptr<ShellTestExternalViewEmbedder>&
47 shell_test_external_view_embedder,
48 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
49 FML_LOG(FATAL) << "OpenGL backend not enabled in this build";
50 return nullptr;
51}
52#endif // SHELL_ENABLE_GL
53#ifndef SHELL_ENABLE_METAL
54std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::CreateMetal(
55 PlatformView::Delegate& delegate,
56 const TaskRunners& task_runners,
57 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
58 const CreateVsyncWaiter& create_vsync_waiter,
59 const std::shared_ptr<ShellTestExternalViewEmbedder>&
60 shell_test_external_view_embedder,
61 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
62 FML_LOG(FATAL) << "Metal backend not enabled in this build";
63 return nullptr;
64}
65#endif // SHELL_ENABLE_METAL
66#ifndef SHELL_ENABLE_VULKAN
67std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::CreateVulkan(
68 PlatformView::Delegate& delegate,
69 const TaskRunners& task_runners,
70 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
71 const CreateVsyncWaiter& create_vsync_waiter,
72 const std::shared_ptr<ShellTestExternalViewEmbedder>&
73 shell_test_external_view_embedder,
74 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
75 FML_LOG(FATAL) << "Vulkan backend not enabled in this build";
76 return nullptr;
77}
78#endif // SHELL_ENABLE_VULKAN
79
82
83std::unique_ptr<PlatformView> ShellTestPlatformViewBuilder::operator()(
84 Shell& shell) {
85 const TaskRunners& task_runners = shell.GetTaskRunners();
86 const auto vsync_clock = std::make_shared<ShellTestVsyncClock>();
87 CreateVsyncWaiter create_vsync_waiter = [&task_runners, vsync_clock,
88 simulate_vsync =
89 config_.simulate_vsync]() {
90 if (simulate_vsync) {
91 return static_cast<std::unique_ptr<VsyncWaiter>>(
92 std::make_unique<ShellTestVsyncWaiter>(task_runners, vsync_clock));
93 } else {
94 return static_cast<std::unique_ptr<VsyncWaiter>>(
95 std::make_unique<VsyncWaiterFallback>(task_runners, true));
96 }
97 };
99 config_.rendering_backend, //
100 shell, //
101 task_runners, //
102 vsync_clock, //
103 create_vsync_waiter, //
106 );
107}
108
109} // namespace flutter::testing
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
const TaskRunners & GetTaskRunners() const override
If callers wish to interact directly with any shell subcomponents, they must (on the platform thread)...
Definition shell.cc:911
std::shared_ptr< const fml::SyncSwitch > GetIsGpuDisabledSyncSwitch() const override
Accessor for the disable GPU SyncSwitch.
Definition shell.cc:2351
std::unique_ptr< PlatformView > operator()(Shell &shell)
static std::unique_ptr< ShellTestPlatformView > Create(BackendType backend, PlatformView::Delegate &delegate, const TaskRunners &task_runners, const std::shared_ptr< ShellTestVsyncClock > &vsync_clock, const CreateVsyncWaiter &create_vsync_waiter, const std::shared_ptr< ShellTestExternalViewEmbedder > &shell_test_external_view_embedder, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
static std::unique_ptr< ShellTestPlatformView > CreateVulkan(PlatformView::Delegate &delegate, const TaskRunners &task_runners, const std::shared_ptr< ShellTestVsyncClock > &vsync_clock, const CreateVsyncWaiter &create_vsync_waiter, const std::shared_ptr< ShellTestExternalViewEmbedder > &shell_test_external_view_embedder, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
static std::unique_ptr< ShellTestPlatformView > CreateMetal(PlatformView::Delegate &delegate, const TaskRunners &task_runners, const std::shared_ptr< ShellTestVsyncClock > &vsync_clock, const CreateVsyncWaiter &create_vsync_waiter, const std::shared_ptr< ShellTestExternalViewEmbedder > &shell_test_external_view_embedder, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
static std::unique_ptr< ShellTestPlatformView > CreateGL(PlatformView::Delegate &delegate, const TaskRunners &task_runners, const std::shared_ptr< ShellTestVsyncClock > &vsync_clock, const CreateVsyncWaiter &create_vsync_waiter, const std::shared_ptr< ShellTestExternalViewEmbedder > &shell_test_external_view_embedder, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
#define FML_LOG(severity)
Definition logging.h:101
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
Definition ref_ptr.h:261
std::shared_ptr< ShellTestExternalViewEmbedder > shell_test_external_view_embedder