Flutter Engine
The Flutter Engine
vulkan_swapchain.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_VULKAN_VULKAN_SWAPCHAIN_H_
6#define FLUTTER_VULKAN_VULKAN_SWAPCHAIN_H_
7
8#include <memory>
9#include <utility>
10#include <vector>
11
12#include "flutter/fml/compiler_specific.h"
13#include "flutter/fml/macros.h"
14#include "flutter/vulkan/procs/vulkan_handle.h"
17
18namespace vulkan {
19
20class VulkanProcTable;
21class VulkanDevice;
22class VulkanSurface;
23class VulkanBackbuffer;
24class VulkanImage;
25
27 public:
29 const VulkanDevice& device,
31 GrDirectContext* skia_context,
32 std::unique_ptr<VulkanSwapchain> old_swapchain,
33 uint32_t queue_family_index);
34
36
37 bool IsValid() const;
38
39 enum class AcquireStatus {
40 /// A valid SkSurface was acquired successfully from the swapchain.
41 Success,
42 /// The underlying surface of the swapchain was permanently lost. This is an
43 /// unrecoverable error. The entire surface must be recreated along with the
44 /// swapchain.
45 ErrorSurfaceLost,
46 /// The swapchain surface is out-of-date with the underlying surface. The
47 /// swapchain must be recreated.
48 ErrorSurfaceOutOfDate,
49 };
50 using AcquireResult = std::pair<AcquireStatus, sk_sp<SkSurface>>;
51
52 /// Acquire an SkSurface from the swapchain for the caller to render into for
53 /// later submission via |Submit|. There must not be consecutive calls to
54 /// |AcquireFrame| without and interleaving |Submit|.
56
57 /// Submit a previously acquired. There must not be consecutive calls to
58 /// |Submit| without and interleaving |AcquireFrame|.
59 [[nodiscard]] bool Submit();
60
61 SkISize GetSize() const;
62
63#if FML_OS_ANDROID
64 private:
65 const VulkanProcTable& vk;
66 const VulkanDevice& device_;
67 VkSurfaceCapabilitiesKHR capabilities_;
68 VkSurfaceFormatKHR surface_format_;
70 std::vector<std::unique_ptr<VulkanBackbuffer>> backbuffers_;
71 std::vector<std::unique_ptr<VulkanImage>> images_;
72 std::vector<sk_sp<SkSurface>> surfaces_;
73 VkPipelineStageFlagBits current_pipeline_stage_;
74 size_t current_backbuffer_index_;
75 size_t current_image_index_;
76 bool valid_;
77
78 std::vector<VkImage> GetImages() const;
79
80 bool CreateSwapchainImages(GrDirectContext* skia_context,
82 const sk_sp<SkColorSpace>& color_space,
83 VkImageUsageFlags usage_flags);
84
85 sk_sp<SkSurface> CreateSkiaSurface(GrDirectContext* skia_context,
86 VkImage image,
87 VkImageUsageFlags usage_flags,
88 const SkISize& size,
90 sk_sp<SkColorSpace> color_space) const;
91
92 VulkanBackbuffer* GetNextBackbuffer();
93#endif // FML_OS_ANDROID
94
96};
97
98} // namespace vulkan
99
100#endif // FLUTTER_VULKAN_VULKAN_SWAPCHAIN_H_
SkColorType
Definition: SkColorType.h:19
AcquireResult AcquireSurface()
std::pair< AcquireStatus, sk_sp< SkSurface > > AcquireResult
FML_DISALLOW_COPY_AND_ASSIGN(VulkanSwapchain)
VulkanSwapchain(const VulkanProcTable &vk, const VulkanDevice &device, const VulkanSurface &surface, GrDirectContext *skia_context, std::unique_ptr< VulkanSwapchain > old_swapchain, uint32_t queue_family_index)
VkDevice device
Definition: main.cc:53
uint32_t queue_family_index
Definition: main.cc:54
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
vk
Definition: malisc.py:42
uint32_t color_type
Definition: SkSize.h:16
VkFlags VkImageUsageFlags
Definition: vulkan_core.h:2382
VkPipelineStageFlagBits
Definition: vulkan_core.h:2434