Flutter Engine
The Flutter Engine
vulkan_surface_pool.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_SHELL_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_POOL_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_POOL_H_
7
8#include <fuchsia/ui/composition/cpp/fidl.h>
9
10#include <unordered_map>
11#include <vector>
12
13#include "flutter/fml/macros.h"
14#include "vulkan_surface.h"
15
16namespace flutter_runner {
17
18class VulkanSurfacePool final {
19 public:
20 // Only keep 12 surfaces at a time. This value was based on how many
21 // surfaces got cached in the old, exact-match-only caching logic.
22 static constexpr int kMaxSurfaces = 12;
23 // If a surface doesn't get used for 3 or more generations, we discard it.
24 static constexpr int kMaxSurfaceAge = 3;
25
28
30
31 std::unique_ptr<VulkanSurface> CreateSurface(const SkISize& size);
32 std::unique_ptr<VulkanSurface> AcquireSurface(const SkISize& size);
33
34 void SubmitSurface(std::unique_ptr<SurfaceProducerSurface> surface);
35
37
38 // Shrink all oversized |VulkanSurfaces| in |available_surfaces_| to as
39 // small as they can be.
40 void ShrinkToFit();
41
42 private:
43 vulkan::VulkanProvider& vulkan_provider_;
45 fuchsia::sysmem::AllocatorSyncPtr sysmem_allocator_;
46 fuchsia::ui::composition::AllocatorPtr flatland_allocator_;
47 std::vector<std::unique_ptr<VulkanSurface>> available_surfaces_;
48 std::unordered_map<uintptr_t, std::unique_ptr<VulkanSurface>>
49 pending_surfaces_;
50
51 size_t trace_surfaces_created_ = 0;
52 size_t trace_surfaces_reused_ = 0;
53
54 std::unique_ptr<VulkanSurface> GetCachedOrCreateSurface(const SkISize& size);
55
56 void RecycleSurface(std::unique_ptr<VulkanSurface> surface);
57
58 void RecyclePendingSurface(uintptr_t surface_key);
59
60 void TraceStats();
61
62 FML_DISALLOW_COPY_AND_ASSIGN(VulkanSurfacePool);
63};
64
65} // namespace flutter_runner
66
67#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_VULKAN_SURFACE_POOL_H_
std::unique_ptr< VulkanSurface > CreateSurface(const SkISize &size)
void SubmitSurface(std::unique_ptr< SurfaceProducerSurface > surface)
VulkanSurfacePool(vulkan::VulkanProvider &vulkan_provider, sk_sp< GrDirectContext > context)
std::unique_ptr< VulkanSurface > AcquireSurface(const SkISize &size)
VkSurfaceKHR surface
Definition: main.cc:49
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
Definition: SkSize.h:16