Flutter Impeller
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 
10 namespace 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 
28  // |RenderTargetAllocator|
29  std::shared_ptr<Texture> CreateTexture(
30  const TextureDescriptor& desc) override;
31 
32  // visible for testing.
33  size_t CachedTextureCount() const;
34 
35  private:
36  struct TextureData {
37  bool used_this_frame;
38  std::shared_ptr<Texture> texture;
39  };
40 
41  std::vector<TextureData> texture_data_;
42 
43  RenderTargetCache(const RenderTargetCache&) = delete;
44 
45  RenderTargetCache& operator=(const RenderTargetCache&) = delete;
46 };
47 
48 } // namespace impeller
49 
50 #endif // FLUTTER_IMPELLER_ENTITY_RENDER_TARGET_CACHE_H_
impeller::RenderTargetCache::CreateTexture
std::shared_ptr< Texture > CreateTexture(const TextureDescriptor &desc) override
Create a new render target texture, or recycle a previously allocated render target texture.
Definition: render_target_cache.cc:34
impeller::RenderTargetCache::End
void End() override
Mark the end of a frame workload.
Definition: render_target_cache.cc:19
impeller::RenderTargetCache::RenderTargetCache
RenderTargetCache(std::shared_ptr< Allocator > allocator)
Definition: render_target_cache.cc:10
impeller::RenderTargetAllocator
a wrapper around the impeller [Allocator] instance that can be used to provide caching of allocated r...
Definition: render_target.h:23
impeller::RenderTargetCache::~RenderTargetCache
~RenderTargetCache()=default
impeller::RenderTargetCache::Start
void Start() override
Mark the beginning of a frame workload.
Definition: render_target_cache.cc:13
impeller::RenderTargetCache
An implementation of the [RenderTargetAllocator] that caches all allocated texture data for one frame...
Definition: render_target_cache.h:16
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
render_target.h
impeller
Definition: aiks_context.cc:10
impeller::RenderTargetCache::CachedTextureCount
size_t CachedTextureCount() const
Definition: render_target_cache.cc:30