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  private:
51  bool valid_;
53  std::shared_ptr<ShellTestExternalViewEmbedder>
54  shell_test_external_view_embedder_;
55  std::unique_ptr<vulkan::VulkanApplication> application_;
56  std::unique_ptr<vulkan::VulkanDevice> logical_device_;
57  sk_sp<GrDirectContext> context_;
58 
59  bool CreateSkiaGrContext();
60  bool CreateSkiaBackendContext(GrVkBackendContext* context);
61 
62  FML_DISALLOW_COPY_AND_ASSIGN(OffScreenSurface);
63  };
64 
65  CreateVsyncWaiter create_vsync_waiter_;
66 
67  std::shared_ptr<ShellTestVsyncClock> vsync_clock_;
68 
70 
71  std::shared_ptr<ShellTestExternalViewEmbedder>
72  shell_test_external_view_embedder_;
73 
74  // |PlatformView|
75  std::unique_ptr<Surface> CreateRenderingSurface() override;
76 
77  // |PlatformView|
78  std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
79 
80  // |PlatformView|
81  std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
82 
83  // |PlatformView|
84  PointerDataDispatcherMaker GetDispatcherMaker() override;
85 
87 };
88 
89 } // namespace testing
90 } // namespace flutter
91 
92 #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
static bool IsValid(double value)
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:53