Flutter Engine
The 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
5#include "flutter/shell/common/shell_test_platform_view.h"
6
7#ifdef SHELL_ENABLE_GL
8#include "flutter/shell/common/shell_test_platform_view_gl.h"
9#endif // SHELL_ENABLE_GL
10#ifdef SHELL_ENABLE_VULKAN
11#include "flutter/shell/common/shell_test_platform_view_vulkan.h"
12#endif // SHELL_ENABLE_VULKAN
13#ifdef SHELL_ENABLE_METAL
14#include "flutter/shell/common/shell_test_platform_view_metal.h"
15#endif // SHELL_ENABLE_METAL
16
17#include "flutter/shell/common/vsync_waiter_fallback.h"
18
19namespace flutter {
20namespace testing {
21
22std::unique_ptr<ShellTestPlatformView> ShellTestPlatformView::Create(
23 PlatformView::Delegate& delegate,
24 const TaskRunners& task_runners,
25 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
26 const CreateVsyncWaiter& create_vsync_waiter,
27 BackendType backend,
28 const std::shared_ptr<ShellTestExternalViewEmbedder>&
29 shell_test_external_view_embedder,
30 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
31 // TODO(gw280): https://github.com/flutter/flutter/issues/50298
32 // Make this fully runtime configurable
33 switch (backend) {
34 case BackendType::kDefaultBackend:
35#ifdef SHELL_ENABLE_GL
36 case BackendType::kGLBackend:
37 return std::make_unique<ShellTestPlatformViewGL>(
38 delegate, task_runners, vsync_clock, create_vsync_waiter,
39 shell_test_external_view_embedder);
40#endif // SHELL_ENABLE_GL
41#ifdef SHELL_ENABLE_VULKAN
42 case BackendType::kVulkanBackend:
43 return std::make_unique<ShellTestPlatformViewVulkan>(
44 delegate, task_runners, vsync_clock, create_vsync_waiter,
45 shell_test_external_view_embedder);
46#endif // SHELL_ENABLE_VULKAN
47#ifdef SHELL_ENABLE_METAL
48 case BackendType::kMetalBackend:
49 return std::make_unique<ShellTestPlatformViewMetal>(
50 delegate, task_runners, vsync_clock, create_vsync_waiter,
51 shell_test_external_view_embedder, is_gpu_disabled_sync_switch);
52#endif // SHELL_ENABLE_METAL
53
54 default:
55 FML_LOG(FATAL) << "No backends supported for ShellTestPlatformView";
56 return nullptr;
57 }
58}
59
62
63std::unique_ptr<PlatformView> ShellTestPlatformViewBuilder::operator()(
64 Shell& shell) {
65 const TaskRunners& task_runners = shell.GetTaskRunners();
66 const auto vsync_clock = std::make_shared<ShellTestVsyncClock>();
67 CreateVsyncWaiter create_vsync_waiter = [&task_runners, vsync_clock,
68 simulate_vsync =
69 config_.simulate_vsync]() {
70 if (simulate_vsync) {
71 return static_cast<std::unique_ptr<VsyncWaiter>>(
72 std::make_unique<ShellTestVsyncWaiter>(task_runners, vsync_clock));
73 } else {
74 return static_cast<std::unique_ptr<VsyncWaiter>>(
75 std::make_unique<VsyncWaiterFallback>(task_runners, true));
76 }
77 };
79 shell, //
80 task_runners, //
81 vsync_clock, //
82 create_vsync_waiter, //
83 config_.rendering_backend, //
85 shell.GetIsGpuDisabledSyncSwitch() //
86 );
87}
88
89} // namespace testing
90} // namespace flutter
const char * backend
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
std::unique_ptr< PlatformView > operator()(Shell &shell)
static std::unique_ptr< ShellTestPlatformView > Create(PlatformView::Delegate &delegate, const TaskRunners &task_runners, const std::shared_ptr< ShellTestVsyncClock > &vsync_clock, const CreateVsyncWaiter &create_vsync_waiter, BackendType backend, const std::shared_ptr< ShellTestExternalViewEmbedder > &shell_test_external_view_embedder, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
#define FATAL(error)
#define FML_LOG(severity)
Definition logging.h:82
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
Definition ref_ptr.h:256
std::shared_ptr< ShellTestExternalViewEmbedder > shell_test_external_view_embedder