| 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"
12 #include "impeller/renderer/backend/vulkan/vk.h"
13 #include "impeller/renderer/command_buffer.h"
14 #include "impeller/renderer/context.h"
15 #include "impeller/renderer/surface.h"
16
17 #if FML_OS_ANDROID
18 #include "impeller/toolkit/android/native_window.h"
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:
64 SwapchainVK();
65 };
66
67 } // namespace impeller
68
69 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_SWAPCHAIN_VK_H_
impeller::SwapchainVK::GetSurfaceFormat
virtual vk::Format GetSurfaceFormat() const =0
impeller::SwapchainVK::operator=
SwapchainVK & operator=(const SwapchainVK &)=delete
impeller::SwapchainVK::AcquireNextDrawable
virtual std::unique_ptr< Surface > AcquireNextDrawable()=0
impeller::SwapchainVK::IsValid
virtual bool IsValid() const =0
vk.h
surface.h
impeller::TSize
Definition: size.h:25
impeller::SwapchainVK::SwapchainVK
SwapchainVK()
impeller::SwapchainVK::UpdateSurfaceSize
virtual void UpdateSurfaceSize(const ISize &size)=0
Mark the current swapchain configuration as dirty, forcing it to be recreated on the next frame.
impeller::SwapchainVK::AddFinalCommandBuffer
virtual void AddFinalCommandBuffer(std::shared_ptr< CommandBuffer > cmd_buffer) const =0
impeller::SwapchainVK::Create
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:19
native_window.h
command_buffer.h
impeller::SwapchainVK
A swapchain that adapts to the underlying surface going out of date. If the caller cannot acquire the...
Definition: swapchain_vk.h:29
context.h
impeller
Definition: allocation.cc:12
size.h
impeller::SwapchainVK::~SwapchainVK
virtual ~SwapchainVK()