Flutter Impeller
ahb_swapchain_vk.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_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_VK_H_
7 
13 
14 namespace impeller {
15 
16 using CreateTransactionCB = std::function<android::SurfaceTransaction()>;
17 
18 //------------------------------------------------------------------------------
19 /// @brief The implementation of a swapchain that uses hardware buffers
20 /// presented to a given surface control on Android.
21 ///
22 /// @warning This swapchain implementation is not available on all Android
23 /// versions supported by Flutter. Perform the
24 /// `IsAvailableOnPlatform` check and fallback to KHR swapchains if
25 /// this type of swapchain cannot be created. The available building
26 /// blocks for these kinds of swapchains are only available on
27 /// Android API levels >= 29.
28 ///
29 class AHBSwapchainVK final : public SwapchainVK {
30  public:
31  static bool IsAvailableOnPlatform();
32 
33  // |SwapchainVK|
34  ~AHBSwapchainVK() override;
35 
36  AHBSwapchainVK(const AHBSwapchainVK&) = delete;
37 
39 
40  // |SwapchainVK|
41  bool IsValid() const override;
42 
43  // |SwapchainVK|
44  std::unique_ptr<Surface> AcquireNextDrawable() override;
45 
46  // |SwapchainVK|
47  vk::Format GetSurfaceFormat() const override;
48 
49  // |SwapchainVK|
50  void UpdateSurfaceSize(const ISize& size) override;
51 
52  // |SwapchainVK|
54  std::shared_ptr<CommandBuffer> cmd_buffer) const override;
55 
56  private:
57  friend class SwapchainVK;
58 
59  std::weak_ptr<Context> context_;
60  std::shared_ptr<android::SurfaceControl> surface_control_;
61  const bool enable_msaa_;
63  std::shared_ptr<AHBSwapchainImplVK> impl_;
64 
65  explicit AHBSwapchainVK(const std::shared_ptr<Context>& context,
66  ANativeWindow* window,
67  const CreateTransactionCB& cb,
68  const ISize& size,
69  bool enable_msaa);
70 };
71 
72 } // namespace impeller
73 
74 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_VK_H_
The implementation of a swapchain that uses hardware buffers presented to a given surface control on ...
static bool IsAvailableOnPlatform()
void UpdateSurfaceSize(const ISize &size) override
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
AHBSwapchainVK & operator=(const AHBSwapchainVK &)=delete
bool IsValid() const override
void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer) const override
vk::Format GetSurfaceFormat() const override
std::unique_ptr< Surface > AcquireNextDrawable() override
AHBSwapchainVK(const AHBSwapchainVK &)=delete
A swapchain that adapts to the underlying surface going out of date. If the caller cannot acquire the...
Definition: swapchain_vk.h:34
std::function< android::SurfaceTransaction()> CreateTransactionCB