Flutter Impeller
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_SWAPCHAIN_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_SWAPCHAIN_VK_H_
7 
8 #include <memory>
9 
10 #include "flutter/fml/build_config.h"
11 #include "impeller/geometry/size.h"
16 
17 #if FML_OS_ANDROID
20 #endif // FML_OS_ANDROID
21 
22 namespace impeller {
23 
24 #if FML_OS_ANDROID
25 using CreateTransactionCB = std::function<android::SurfaceTransaction()>;
26 #endif // FML_OS_ANDROID
27 
28 //------------------------------------------------------------------------------
29 /// @brief A swapchain that adapts to the underlying surface going out of
30 /// date. If the caller cannot acquire the next drawable, it is due
31 /// to an unrecoverable error and the swapchain must be recreated
32 /// with a new surface.
33 ///
34 class SwapchainVK {
35  public:
36  static std::shared_ptr<SwapchainVK> Create(
37  const std::shared_ptr<Context>& context,
38  vk::UniqueSurfaceKHR surface,
39  const ISize& size,
40  bool enable_msaa = true);
41 
42 #if FML_OS_ANDROID
43  static std::shared_ptr<SwapchainVK> Create(
44  const std::shared_ptr<Context>& context,
45  ANativeWindow* window,
46  const CreateTransactionCB& cb,
47  bool enable_msaa = true);
48 #endif // FML_OS_ANDROID
49 
50  virtual ~SwapchainVK();
51 
52  SwapchainVK(const SwapchainVK&) = delete;
53 
54  SwapchainVK& operator=(const SwapchainVK&) = delete;
55 
56  virtual bool IsValid() const = 0;
57 
58  virtual std::unique_ptr<Surface> AcquireNextDrawable() = 0;
59 
60  virtual vk::Format GetSurfaceFormat() const = 0;
61 
62  virtual void AddFinalCommandBuffer(
63  std::shared_ptr<CommandBuffer> cmd_buffer) const = 0;
64 
65  /// @brief Mark the current swapchain configuration as dirty, forcing it to be
66  /// recreated on the next frame.
67  virtual void UpdateSurfaceSize(const ISize& size) = 0;
68 
69  protected:
71 };
72 
73 } // namespace impeller
74 
75 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_SWAPCHAIN_VK_H_
A swapchain that adapts to the underlying surface going out of date. If the caller cannot acquire the...
Definition: swapchain_vk.h:34
virtual bool IsValid() const =0
virtual void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer) const =0
SwapchainVK & operator=(const SwapchainVK &)=delete
virtual std::unique_ptr< Surface > AcquireNextDrawable()=0
virtual void UpdateSurfaceSize(const ISize &size)=0
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
SwapchainVK(const SwapchainVK &)=delete
virtual vk::Format GetSurfaceFormat() const =0
static std::shared_ptr< SwapchainVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true)
Definition: swapchain_vk.cc:18
std::function< android::SurfaceTransaction()> CreateTransactionCB