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