| 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
8 #include "impeller/renderer/backend/vulkan/swapchain/ahb/ahb_swapchain_impl_vk.h"
9 #include "impeller/renderer/backend/vulkan/swapchain/swapchain_vk.h"
10 #include "impeller/toolkit/android/native_window.h"
11 #include "impeller/toolkit/android/surface_control.h"
12 #include "impeller/toolkit/android/surface_transaction.h"
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
38 AHBSwapchainVK& operator=(const AHBSwapchainVK&) = delete;
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|
53 void AddFinalCommandBuffer(
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_;
62 size_t swapchain_image_count_ = 3u;
63 CreateTransactionCB cb_;
64 std::shared_ptr<AHBSwapchainImplVK> impl_;
65
66 explicit AHBSwapchainVK(const std::shared_ptr<Context>& context,
67 ANativeWindow* window,
68 const CreateTransactionCB& cb,
69 const vk::UniqueSurfaceKHR& surface,
70 const ISize& size,
71 bool enable_msaa);
72 };
73
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_AHB_AHB_SWAPCHAIN_VK_H_
ahb_swapchain_impl_vk.h
impeller::AHBSwapchainVK
The implementation of a swapchain that uses hardware buffers presented to a given surface control on ...
Definition: ahb_swapchain_vk.h:29
impeller::AHBSwapchainVK::IsAvailableOnPlatform
static bool IsAvailableOnPlatform()
Definition: ahb_swapchain_vk.cc:15
impeller::AHBSwapchainVK::UpdateSurfaceSize
void UpdateSurfaceSize(const ISize &size) override
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
Definition: ahb_swapchain_vk.cc:78
impeller::AHBSwapchainVK::operator=
AHBSwapchainVK & operator=(const AHBSwapchainVK &)=delete
impeller::AHBSwapchainVK::IsValid
bool IsValid() const override
Definition: ahb_swapchain_vk.cc:50
impeller::AHBSwapchainVK::AddFinalCommandBuffer
void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer) const override
Definition: ahb_swapchain_vk.cc:72
impeller::AHBSwapchainVK::GetSurfaceFormat
vk::Format GetSurfaceFormat() const override
Definition: ahb_swapchain_vk.cc:65
impeller::AHBSwapchainVK::~AHBSwapchainVK
~AHBSwapchainVK() override
impeller::AHBSwapchainVK::AcquireNextDrawable
std::unique_ptr< Surface > AcquireNextDrawable() override
Definition: ahb_swapchain_vk.cc:55
impeller::AHBSwapchainVK::AHBSwapchainVK
AHBSwapchainVK(const AHBSwapchainVK &)=delete
impeller::SwapchainVK
A swapchain that adapts to the underlying surface going out of date. If the caller cannot acquire the...
Definition: swapchain_vk.h:34
impeller
Definition: allocation.cc:12
impeller::CreateTransactionCB
std::function< android::SurfaceTransaction()> CreateTransactionCB
Definition: ahb_swapchain_impl_vk.h:24
native_window.h
swapchain_vk.h
impeller::TSize
Definition: size.h:25
surface_control.h
surface_transaction.h