Flutter Engine
 
Loading...
Searching...
No Matches
shell_test_platform_view.h
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#ifndef FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_H_
6#define FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_H_
7
8#include <exception>
9
13
14namespace flutter::testing {
15
17 public:
18 enum class BackendType {
22 };
23
25#if defined(SHELL_ENABLE_GL)
26 return BackendType::kGLBackend;
27#elif defined(SHELL_ENABLE_METAL)
28 return BackendType::kMetalBackend;
29#elif defined(SHELL_ENABLE_VULKAN)
30 return BackendType::kVulkanBackend;
31#else
32 FML_LOG(FATAL) << "No backend is enabled in this build.";
33 std::terminate();
34#endif
35 }
36
37 static std::unique_ptr<ShellTestPlatformView> Create(
38 BackendType backend,
39 PlatformView::Delegate& delegate,
40 const TaskRunners& task_runners,
41 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
42 const CreateVsyncWaiter& create_vsync_waiter,
43 const std::shared_ptr<ShellTestExternalViewEmbedder>&
44 shell_test_external_view_embedder,
45 const std::shared_ptr<const fml::SyncSwitch>&
46 is_gpu_disabled_sync_switch);
47
48 virtual void SimulateVSync() = 0;
49
50 protected:
52 const TaskRunners& task_runners)
53 : PlatformView(delegate, task_runners) {}
54
55 static std::unique_ptr<ShellTestPlatformView> CreateGL(
56 PlatformView::Delegate& delegate,
57 const TaskRunners& task_runners,
58 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
59 const CreateVsyncWaiter& create_vsync_waiter,
60 const std::shared_ptr<ShellTestExternalViewEmbedder>&
61 shell_test_external_view_embedder,
62 const std::shared_ptr<const fml::SyncSwitch>&
63 is_gpu_disabled_sync_switch);
64 static std::unique_ptr<ShellTestPlatformView> CreateMetal(
65 PlatformView::Delegate& delegate,
66 const TaskRunners& task_runners,
67 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
68 const CreateVsyncWaiter& create_vsync_waiter,
69 const std::shared_ptr<ShellTestExternalViewEmbedder>&
70 shell_test_external_view_embedder,
71 const std::shared_ptr<const fml::SyncSwitch>&
72 is_gpu_disabled_sync_switch);
73 static std::unique_ptr<ShellTestPlatformView> CreateVulkan(
74 PlatformView::Delegate& delegate,
75 const TaskRunners& task_runners,
76 const std::shared_ptr<ShellTestVsyncClock>& vsync_clock,
77 const CreateVsyncWaiter& create_vsync_waiter,
78 const std::shared_ptr<ShellTestExternalViewEmbedder>&
79 shell_test_external_view_embedder,
80 const std::shared_ptr<const fml::SyncSwitch>&
81 is_gpu_disabled_sync_switch);
82
84};
85
86// Create a ShellTestPlatformView from configuration struct.
88 public:
89 struct Config {
90 bool simulate_vsync = false;
91 std::shared_ptr<ShellTestExternalViewEmbedder>
95 };
96
97 explicit ShellTestPlatformViewBuilder(Config config);
99
100 // Override operator () to make this class assignable to std::function.
101 std::unique_ptr<PlatformView> operator()(Shell& shell);
102
103 private:
104 Config config_;
105};
106
107} // namespace flutter::testing
108
109#endif // FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_H_
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
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)
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView)
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)
ShellTestPlatformView(PlatformView::Delegate &delegate, const TaskRunners &task_runners)
#define FML_LOG(severity)
Definition logging.h:101
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
std::shared_ptr< ShellTestExternalViewEmbedder > shell_test_external_view_embedder