Flutter Engine
The Flutter Engine
render_target_cache.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_ENTITY_RENDER_TARGET_CACHE_H_
6#define FLUTTER_IMPELLER_ENTITY_RENDER_TARGET_CACHE_H_
7
9
10namespace impeller {
11
12/// @brief An implementation of the [RenderTargetAllocator] that caches all
13/// allocated texture data for one frame.
14///
15/// Any textures unused after a frame are immediately discarded.
17 public:
18 explicit RenderTargetCache(std::shared_ptr<Allocator> allocator);
19
20 ~RenderTargetCache() = default;
21
22 // |RenderTargetAllocator|
23 void Start() override;
24
25 // |RenderTargetAllocator|
26 void End() override;
27
29 const Context& context,
30 ISize size,
31 int mip_count,
32 const std::string& label = "Offscreen",
33 RenderTarget::AttachmentConfig color_attachment_config =
35 std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
37 const std::shared_ptr<Texture>& existing_color_texture = nullptr,
38 const std::shared_ptr<Texture>& existing_depth_stencil_texture =
39 nullptr) override;
40
42 const Context& context,
43 ISize size,
44 int mip_count,
45 const std::string& label = "Offscreen MSAA",
46 RenderTarget::AttachmentConfigMSAA color_attachment_config =
48 std::optional<RenderTarget::AttachmentConfig> stencil_attachment_config =
50 const std::shared_ptr<Texture>& existing_color_msaa_texture = nullptr,
51 const std::shared_ptr<Texture>& existing_color_resolve_texture = nullptr,
52 const std::shared_ptr<Texture>& existing_depth_stencil_texture =
53 nullptr) override;
54
55 // visible for testing.
56 size_t CachedTextureCount() const;
57
58 private:
59 struct RenderTargetData {
60 bool used_this_frame;
61 RenderTargetConfig config;
62 RenderTarget render_target;
63 };
64
65 std::vector<RenderTargetData> render_target_data_;
66
67 RenderTargetCache(const RenderTargetCache&) = delete;
68
69 RenderTargetCache& operator=(const RenderTargetCache&) = delete;
70
71 public:
72 /// Visible for testing.
73 std::vector<RenderTargetData>::const_iterator GetRenderTargetDataBegin()
74 const {
75 return render_target_data_.begin();
76 }
77
78 /// Visible for testing.
79 std::vector<RenderTargetData>::const_iterator GetRenderTargetDataEnd() const {
80 return render_target_data_.end();
81 }
82};
83
84} // namespace impeller
85
86#endif // FLUTTER_IMPELLER_ENTITY_RENDER_TARGET_CACHE_H_
To do anything rendering related with Impeller, you need a context.
Definition: context.h:45
a wrapper around the impeller [Allocator] instance that can be used to provide caching of allocated r...
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for one frame...
RenderTargetCache(std::shared_ptr< Allocator > allocator)
RenderTarget CreateOffscreen(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen", RenderTarget::AttachmentConfig color_attachment_config=RenderTarget::kDefaultColorAttachmentConfig, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr) override
RenderTarget CreateOffscreenMSAA(const Context &context, ISize size, int mip_count, const std::string &label="Offscreen MSAA", RenderTarget::AttachmentConfigMSAA color_attachment_config=RenderTarget::kDefaultColorAttachmentConfigMSAA, std::optional< RenderTarget::AttachmentConfig > stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &existing_color_msaa_texture=nullptr, const std::shared_ptr< Texture > &existing_color_resolve_texture=nullptr, const std::shared_ptr< Texture > &existing_depth_stencil_texture=nullptr) override
std::vector< RenderTargetData >::const_iterator GetRenderTargetDataBegin() const
Visible for testing.
void End() override
Mark the end of a frame workload.
void Start() override
Mark the beginning of a frame workload.
std::vector< RenderTargetData >::const_iterator GetRenderTargetDataEnd() const
Visible for testing.
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
Definition: render_target.h:55
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
Definition: render_target.h:61
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig
Definition: render_target.h:68
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