Flutter Engine
flutter::EmbedderRenderTargetCache Class Reference

A cache used to reference render targets that are owned by the embedder but needed by th engine to render a frame. More...

#include <embedder_render_target_cache.h>

Public Types

using RenderTargets = std::unordered_map< EmbedderExternalView::ViewIdentifier, std::unique_ptr< EmbedderRenderTarget >, EmbedderExternalView::ViewIdentifier::Hash, EmbedderExternalView::ViewIdentifier::Equal >
 

Public Member Functions

 EmbedderRenderTargetCache ()
 
 ~EmbedderRenderTargetCache ()
 
std::pair< RenderTargets, EmbedderExternalView::ViewIdentifierSetGetExistingTargetsInCache (const EmbedderExternalView::PendingViews &pending_views)
 
std::set< std::unique_ptr< EmbedderRenderTarget > > ClearAllRenderTargetsInCache ()
 
void CacheRenderTarget (EmbedderExternalView::ViewIdentifier view_identifier, std::unique_ptr< EmbedderRenderTarget > target)
 
size_t GetCachedTargetsCount () const
 

Detailed Description

A cache used to reference render targets that are owned by the embedder but needed by th engine to render a frame.

Definition at line 22 of file embedder_render_target_cache.h.

Member Typedef Documentation

◆ RenderTargets

Constructor & Destructor Documentation

◆ EmbedderRenderTargetCache()

flutter::EmbedderRenderTargetCache::EmbedderRenderTargetCache ( )
default

◆ ~EmbedderRenderTargetCache()

flutter::EmbedderRenderTargetCache::~EmbedderRenderTargetCache ( )
default

Member Function Documentation

◆ CacheRenderTarget()

void flutter::EmbedderRenderTargetCache::CacheRenderTarget ( EmbedderExternalView::ViewIdentifier  view_identifier,
std::unique_ptr< EmbedderRenderTarget target 
)

Definition at line 53 of file embedder_render_target_cache.cc.

Referenced by flutter::MakeBackingStoreConfig().

55  {
56  if (target == nullptr) {
57  return;
58  }
59  auto surface = target->GetRenderSurface();
60  auto desc = EmbedderExternalView::RenderTargetDescriptor{
61  view_identifier, SkISize::Make(surface->width(), surface->height())};
62  cached_render_targets_[desc].push(std::move(target));
63 }

◆ ClearAllRenderTargetsInCache()

std::set< std::unique_ptr< EmbedderRenderTarget > > flutter::EmbedderRenderTargetCache::ClearAllRenderTargetsInCache ( )

Definition at line 40 of file embedder_render_target_cache.cc.

Referenced by flutter::MakeBackingStoreConfig().

40  {
41  std::set<std::unique_ptr<EmbedderRenderTarget>> cleared_targets;
42  for (auto& targets : cached_render_targets_) {
43  auto& targets_stack = targets.second;
44  while (!targets_stack.empty()) {
45  cleared_targets.emplace(std::move(targets_stack.top()));
46  targets_stack.pop();
47  }
48  }
49  cached_render_targets_.clear();
50  return cleared_targets;
51 }

◆ GetCachedTargetsCount()

size_t flutter::EmbedderRenderTargetCache::GetCachedTargetsCount ( ) const

Definition at line 65 of file embedder_render_target_cache.cc.

65  {
66  size_t count = 0;
67  for (const auto& targets : cached_render_targets_) {
68  count += targets.second.size();
69  }
70  return count;
71 }

◆ GetExistingTargetsInCache()

std::pair< EmbedderRenderTargetCache::RenderTargets, EmbedderExternalView::ViewIdentifierSet > flutter::EmbedderRenderTargetCache::GetExistingTargetsInCache ( const EmbedderExternalView::PendingViews pending_views)

Definition at line 15 of file embedder_render_target_cache.cc.

Referenced by flutter::MakeBackingStoreConfig().

16  {
17  RenderTargets resolved_render_targets;
18  EmbedderExternalView::ViewIdentifierSet unmatched_identifiers;
19 
20  for (const auto& view : pending_views) {
21  const auto& external_view = view.second;
22  if (!external_view->HasEngineRenderedContents()) {
23  continue;
24  }
25  auto& compatible_targets =
26  cached_render_targets_[external_view->CreateRenderTargetDescriptor()];
27  if (compatible_targets.size() == 0) {
28  unmatched_identifiers.insert(view.first);
29  } else {
30  std::unique_ptr<EmbedderRenderTarget> target =
31  std::move(compatible_targets.top());
32  compatible_targets.pop();
33  resolved_render_targets[view.first] = std::move(target);
34  }
35  }
36  return {std::move(resolved_render_targets), std::move(unmatched_identifiers)};
37 }
std::unordered_map< EmbedderExternalView::ViewIdentifier, std::unique_ptr< EmbedderRenderTarget >, EmbedderExternalView::ViewIdentifier::Hash, EmbedderExternalView::ViewIdentifier::Equal > RenderTargets
std::unordered_set< ViewIdentifier, ViewIdentifier::Hash, ViewIdentifier::Equal > ViewIdentifierSet

The documentation for this class was generated from the following files: