Flutter Engine
 
Loading...
Searching...
No Matches
flutter::RasterCacheKeyID Class Reference

#include <raster_cache_key.h>

Public Member Functions

 RasterCacheKeyID (uint64_t unique_id, RasterCacheKeyType type)
 
 RasterCacheKeyID (std::vector< RasterCacheKeyID > child_ids, RasterCacheKeyType type)
 
uint64_t unique_id () const
 
RasterCacheKeyType type () const
 
const std::vector< RasterCacheKeyID > & child_ids () const
 
std::size_t GetHash () const
 
bool operator== (const RasterCacheKeyID &other) const
 

Static Public Member Functions

static std::optional< std::vector< RasterCacheKeyID > > LayerChildrenIds (const Layer *layer)
 

Static Public Attributes

static constexpr uint64_t kDefaultUniqueID = 0
 

Detailed Description

Definition at line 26 of file raster_cache_key.h.

Constructor & Destructor Documentation

◆ RasterCacheKeyID() [1/2]

flutter::RasterCacheKeyID::RasterCacheKeyID ( uint64_t  unique_id,
RasterCacheKeyType  type 
)
inline

Definition at line 30 of file raster_cache_key.h.

31 : unique_id_(unique_id), type_(type) {}
RasterCacheKeyType type() const

◆ RasterCacheKeyID() [2/2]

flutter::RasterCacheKeyID::RasterCacheKeyID ( std::vector< RasterCacheKeyID child_ids,
RasterCacheKeyType  type 
)
inline

Definition at line 33 of file raster_cache_key.h.

35 : unique_id_(kDefaultUniqueID),
36 type_(type),
37 child_ids_(std::move(child_ids)) {}
static constexpr uint64_t kDefaultUniqueID
const std::vector< RasterCacheKeyID > & child_ids() const

Member Function Documentation

◆ child_ids()

const std::vector< RasterCacheKeyID > & flutter::RasterCacheKeyID::child_ids ( ) const
inline

Definition at line 43 of file raster_cache_key.h.

43{ return child_ids_; }

◆ GetHash()

std::size_t flutter::RasterCacheKeyID::GetHash ( ) const
inline

Definition at line 48 of file raster_cache_key.h.

48 {
49 if (cached_hash_) {
50 return cached_hash_.value();
51 }
52 std::size_t seed = fml::HashCombine();
53 fml::HashCombineSeed(seed, unique_id_);
54 fml::HashCombineSeed(seed, type_);
55 for (auto& child_id : child_ids_) {
56 fml::HashCombineSeed(seed, child_id.GetHash());
57 }
58 cached_hash_ = seed;
59 return seed;
60 }
constexpr std::size_t HashCombine()
constexpr void HashCombineSeed(std::size_t &seed, const Type &arg)

References fml::HashCombine(), and fml::HashCombineSeed().

Referenced by operator==(), and flutter::testing::TEST().

◆ LayerChildrenIds()

std::optional< std::vector< RasterCacheKeyID > > flutter::RasterCacheKeyID::LayerChildrenIds ( const Layer layer)
static

Definition at line 15 of file raster_cache_key.cc.

16 {
17 FML_DCHECK(layer->as_container_layer());
18 auto& children_layers = layer->as_container_layer()->layers();
19 auto children_count = children_layers.size();
20 if (children_count == 0) {
21 return std::nullopt;
22 }
23 std::vector<RasterCacheKeyID> ids;
24 std::transform(
25 children_layers.begin(), children_layers.end(), std::back_inserter(ids),
26 [](auto& layer) -> RasterCacheKeyID { return layer->caching_key_id(); });
27 return ids;
28}
#define FML_DCHECK(condition)
Definition logging.h:122

References flutter::Layer::as_container_layer(), FML_DCHECK, and flutter::ContainerLayer::layers().

Referenced by flutter::LayerRasterCacheItem::PrerollFinalize(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ operator==()

bool flutter::RasterCacheKeyID::operator== ( const RasterCacheKeyID other) const
inline

Definition at line 62 of file raster_cache_key.h.

62 {
63 return unique_id_ == other.unique_id_ && type_ == other.type_ &&
64 GetHash() == other.GetHash() && child_ids_ == other.child_ids_;
65 }
std::size_t GetHash() const

References GetHash().

◆ type()

RasterCacheKeyType flutter::RasterCacheKeyID::type ( ) const
inline

Definition at line 41 of file raster_cache_key.h.

41{ return type_; }

Referenced by flutter::RasterCacheKey::kind().

◆ unique_id()

uint64_t flutter::RasterCacheKeyID::unique_id ( ) const
inline

Definition at line 39 of file raster_cache_key.h.

39{ return unique_id_; }

Member Data Documentation

◆ kDefaultUniqueID

constexpr uint64_t flutter::RasterCacheKeyID::kDefaultUniqueID = 0
staticconstexpr

Definition at line 28 of file raster_cache_key.h.

Referenced by flutter::testing::TEST().


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