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 
12 
13 namespace impeller {
14 
15 //------------------------------------------------------------------------------
16 /// @brief The implementation of a swapchain that uses hardware buffers
17 /// presented to a given surface control on Android.
18 ///
19 /// @warning This swapchain implementation is not available on all Android
20 /// versions supported by Flutter. Perform the
21 /// `IsAvailableOnPlatform` check and fallback to KHR swapchains if
22 /// this type of swapchain cannot be created. The available building
23 /// blocks for these kinds of swapchains are only available on
24 /// Android API levels >= 29.
25 ///
26 class AHBSwapchainVK final : public SwapchainVK {
27  public:
28  static bool IsAvailableOnPlatform();
29 
30  // |SwapchainVK|
31  ~AHBSwapchainVK() override;
32 
33  AHBSwapchainVK(const AHBSwapchainVK&) = delete;
34 
36 
37  // |SwapchainVK|
38  bool IsValid() const override;
39 
40  // |SwapchainVK|
41  std::unique_ptr<Surface> AcquireNextDrawable() override;
42 
43  // |SwapchainVK|
44  vk::Format GetSurfaceFormat() const override;
45 
46  // |SwapchainVK|
47  void UpdateSurfaceSize(const ISize& size) override;
48 
49  // |SwapchainVK|
51  std::shared_ptr<CommandBuffer> cmd_buffer) const override;
52 
53  private:
54  friend class SwapchainVK;
55 
56  std::weak_ptr<Context> context_;
57  std::shared_ptr<android::SurfaceControl> surface_control_;
58  const bool enable_msaa_;
59  size_t swapchain_image_count_ = 3u;
60  std::shared_ptr<AHBSwapchainImplVK> impl_;
61 
62  explicit AHBSwapchainVK(const std::shared_ptr<Context>& context,
63  ANativeWindow* window,
64  const vk::UniqueSurfaceKHR& surface,
65  const ISize& size,
66  bool enable_msaa);
67 };
68 
69 } // namespace impeller
70 
71 #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:29