Flutter Engine
The Flutter Engine
khr_swapchain_impl_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_KHR_KHR_SWAPCHAIN_IMPL_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_KHR_KHR_SWAPCHAIN_IMPL_VK_H_
7
8#include <cstdint>
9#include <memory>
10#include <variant>
11
15
16namespace impeller {
17
18class Context;
19class KHRSwapchainImageVK;
20class Surface;
21struct KHRFrameSynchronizerVK;
22
23//------------------------------------------------------------------------------
24/// @brief An instance of a swapchain that does NOT adapt to going out of
25/// date with the underlying surface. Errors will be indicated when
26/// the next drawable is acquired from this implementation of the
27/// swapchain. If the error is due the swapchain going out of date,
28/// the caller must recreate another instance by optionally
29/// stealing this implementations guts.
30///
32 : public std::enable_shared_from_this<KHRSwapchainImplVK> {
33 public:
34 static std::shared_ptr<KHRSwapchainImplVK> Create(
35 const std::shared_ptr<Context>& context,
36 vk::UniqueSurfaceKHR surface,
37 const ISize& size,
38 bool enable_msaa = true,
39 vk::SwapchainKHR old_swapchain = VK_NULL_HANDLE);
40
42
43 bool IsValid() const;
44
46 std::unique_ptr<Surface> surface;
47 bool out_of_date = false;
48
49 explicit AcquireResult(bool p_out_of_date = false)
50 : out_of_date(p_out_of_date) {}
51
52 explicit AcquireResult(std::unique_ptr<Surface> p_surface)
53 : surface(std::move(p_surface)) {}
54 };
55
56 AcquireResult AcquireNextDrawable();
57
59
60 std::shared_ptr<Context> GetContext() const;
61
62 std::pair<vk::UniqueSurfaceKHR, vk::UniqueSwapchainKHR> DestroySwapchain();
63
64 const ISize& GetSize() const;
65
66 private:
67 std::weak_ptr<Context> context_;
68 vk::UniqueSurfaceKHR surface_;
69 vk::Format surface_format_ = vk::Format::eUndefined;
70 vk::UniqueSwapchainKHR swapchain_;
71 std::shared_ptr<SwapchainTransientsVK> transients_;
72 std::vector<std::shared_ptr<KHRSwapchainImageVK>> images_;
73 std::vector<std::unique_ptr<KHRFrameSynchronizerVK>> synchronizers_;
74 size_t current_frame_ = 0u;
75 ISize size_;
76 bool enable_msaa_ = true;
77 bool is_valid_ = false;
78
79 KHRSwapchainImplVK(const std::shared_ptr<Context>& context,
80 vk::UniqueSurfaceKHR surface,
81 const ISize& size,
82 bool enable_msaa,
83 vk::SwapchainKHR old_swapchain);
84
85 bool Present(const std::shared_ptr<KHRSwapchainImageVK>& image,
86 uint32_t index);
87
88 void WaitIdle() const;
89
91
92 KHRSwapchainImplVK& operator=(const KHRSwapchainImplVK&) = delete;
93};
94
95} // namespace impeller
96
97#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SWAPCHAIN_KHR_KHR_SWAPCHAIN_IMPL_VK_H_
An instance of a swapchain that does NOT adapt to going out of date with the underlying surface....
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< KHRSwapchainImplVK > Create(const std::shared_ptr< Context > &context, vk::UniqueSurfaceKHR surface, const ISize &size, bool enable_msaa=true, vk::SwapchainKHR old_swapchain=VK_NULL_HANDLE)
std::pair< vk::UniqueSurfaceKHR, vk::UniqueSwapchainKHR > DestroySwapchain()
VkSurfaceKHR surface
Definition: main.cc:49
sk_sp< const SkImage > image
Definition: SkRecords.h:269
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
def Format(template, **parameters)
Definition: emitter.py:13
Definition: ref_ptr.h:256
AcquireResult(std::unique_ptr< Surface > p_surface)
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46