Flutter Engine
shell_test_platform_view_vulkan.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_VULKAN_H_
6 #define FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_VULKAN_H_
7 
8 #include "flutter/shell/common/shell_test_external_view_embedder.h"
9 #include "flutter/shell/common/shell_test_platform_view.h"
10 #include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h"
11 #include "flutter/vulkan/vulkan_application.h"
12 #include "flutter/vulkan/vulkan_device.h"
13 
14 namespace flutter {
15 namespace testing {
16 
18  public:
20  TaskRunners task_runners,
21  std::shared_ptr<ShellTestVsyncClock> vsync_clock,
22  CreateVsyncWaiter create_vsync_waiter,
23  std::shared_ptr<ShellTestExternalViewEmbedder>
24  shell_test_external_view_embedder);
25 
27 
28  void SimulateVSync() override;
29 
30  private:
31  class OffScreenSurface : public flutter::Surface {
32  public:
33  OffScreenSurface(fml::RefPtr<vulkan::VulkanProcTable> vk,
34  std::shared_ptr<ShellTestExternalViewEmbedder>
35  shell_test_external_view_embedder);
36 
37  ~OffScreenSurface() override;
38 
39  // |Surface|
40  bool IsValid() override;
41 
42  // |Surface|
43  std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
44 
45  SkMatrix GetRootTransformation() const override;
46 
47  // |Surface|
48  GrDirectContext* GetContext() override;
49 
50  flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;
51 
52  private:
53  bool valid_;
55  std::shared_ptr<ShellTestExternalViewEmbedder>
56  shell_test_external_view_embedder_;
57  std::unique_ptr<vulkan::VulkanApplication> application_;
58  std::unique_ptr<vulkan::VulkanDevice> logical_device_;
59  sk_sp<GrDirectContext> context_;
60 
61  bool CreateSkiaGrContext();
62  bool CreateSkiaBackendContext(GrVkBackendContext* context);
63 
64  FML_DISALLOW_COPY_AND_ASSIGN(OffScreenSurface);
65  };
66 
67  CreateVsyncWaiter create_vsync_waiter_;
68 
69  std::shared_ptr<ShellTestVsyncClock> vsync_clock_;
70 
72 
73  std::shared_ptr<ShellTestExternalViewEmbedder>
74  shell_test_external_view_embedder_;
75 
76  // |PlatformView|
77  std::unique_ptr<Surface> CreateRenderingSurface() override;
78 
79  // |PlatformView|
80  std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
81 
82  // |PlatformView|
83  PointerDataDispatcherMaker GetDispatcherMaker() override;
84 
86 };
87 
88 } // namespace testing
89 } // namespace flutter
90 
91 #endif // FLUTTER_SHELL_COMMON_SHELL_TEST_PLATFORM_VIEW_VULKAN_H_
ShellTestPlatformViewVulkan(PlatformView::Delegate &delegate, TaskRunners task_runners, std::shared_ptr< ShellTestVsyncClock > vsync_clock, CreateVsyncWaiter create_vsync_waiter, std::shared_ptr< ShellTestExternalViewEmbedder > shell_test_external_view_embedder)
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
std::function< std::unique_ptr< PointerDataDispatcher >(PointerDataDispatcher::Delegate &)> PointerDataDispatcherMaker
Signature for constructing PointerDataDispatcher.
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
Abstract Base Class that represents where we will be rendering content.
Definition: surface.h:18
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Definition: platform_view.h:51