-
Notifications
You must be signed in to change notification settings - Fork 6k
Defer decisions about RasterCache actions until after Preroll is complete #31892
Changes from 1 commit
9f44aad
bb6a4cc
51ae333
bb86e3a
98b4ad6
2a0fbc3
9a71e09
0f60777
d53733e
4600cd6
7626d11
d88aff2
45b28cf
57a8d16
e4eb2a0
7e5af26
879ee10
2c038e9
829e9f4
91cf4e9
ba5694e
45448d4
dc089ad
2f1eb2f
473288b
a80a037
fd82489
d3883c6
3e1ed6c
a25e920
fd3bc8e
cdc123d
d8d373a
9e0e52b
9b68847
7c7fc4c
91f7278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,26 @@ | |
| #include "include/core/SkColor.h" | ||
| #include "include/core/SkMatrix.h" | ||
| #include "include/core/SkPoint.h" | ||
| #include "include/core/SkRect.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class Cacheable { | ||
| public: | ||
| Cacheable() = default; | ||
|
|
||
| void InitialCacheableLayerItem(Layer*); | ||
|
|
||
| void InitialCacheableDisplayListItem(DisplayList*, | ||
| SkRect bounds, | ||
| bool is_complex, | ||
| bool will_change); | ||
|
|
||
| void InitialCacheableSkPictureItem(SkPicture*, | ||
| SkRect bounds, | ||
| bool is_complex, | ||
| bool will_change); | ||
|
|
||
| class AutoCache { | ||
| public: | ||
| static AutoCache Create(Cacheable* cacheable, | ||
|
|
@@ -35,41 +48,65 @@ class Cacheable { | |
| const SkMatrix& matrix, | ||
| SkRect bounds); | ||
|
|
||
| ~AutoCache() { | ||
| if (!cacheable_entry_) { | ||
| return; | ||
| } | ||
| cacheable_entry_->num_child_entries = | ||
| context_->raster_cached_entries.size() - current_index_; | ||
| cacheable_->TryToCache(context_, cacheable_entry_, matrix_); | ||
| cacheable_entry_->has_platform_view = context_->has_platform_view; | ||
| cacheable_entry_->has_texture_layer = context_->has_texture_layer; | ||
| } | ||
| ~AutoCache(); | ||
|
|
||
| private: | ||
| AutoCache(Cacheable* cacheable, | ||
| RasterCacheableEntry* cacheable_entry, | ||
| PrerollContext* context, | ||
| const SkMatrix& matrix) | ||
| : cacheable_(cacheable), context_(context), matrix_(matrix) { | ||
| cacheable_entry_ = cacheable_entry; | ||
| current_index_ = context_->raster_cached_entries.size(); | ||
| const SkMatrix& matrix, | ||
| bool skip = false) | ||
| : cacheable_(cacheable), | ||
| context_(context), | ||
| matrix_(matrix), | ||
| skip_(skip) { | ||
| if (context_ && context_->raster_cache) { | ||
| current_index_ = context_->raster_cached_entries->size(); | ||
| } | ||
| } | ||
|
|
||
| int current_index_; | ||
| RasterCacheableEntry* cacheable_entry_ = nullptr; | ||
| Cacheable* cacheable_ = nullptr; | ||
| PrerollContext* context_ = nullptr; | ||
| const SkMatrix& matrix_; | ||
| bool skip_ = false; | ||
| }; | ||
|
|
||
| virtual Layer* asLayer() = 0; | ||
|
|
||
| virtual void TryToCache(PrerollContext* context, | ||
| RasterCacheableEntry* entry, | ||
| const SkMatrix& ctm) = 0; | ||
| virtual void TryToCache(PrerollContext* context, const SkMatrix& ctm) = 0; | ||
|
|
||
| virtual ~Cacheable() = default; | ||
|
|
||
| LayerCacheableItem* GetCacheableLayer() { | ||
|
||
| return cacheable_item_.get()->asLayerCacheableItem(); | ||
| } | ||
flar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const LayerCacheableItem* GetCacheableLayer() const { | ||
| return cacheable_item_.get()->asLayerCacheableItem(); | ||
| } | ||
|
|
||
| DisplayListCacheableItem* GetCacheableDisplayListItem() { | ||
| return cacheable_item_.get()->asDisplayCacheableItem(); | ||
| } | ||
|
|
||
| const DisplayListCacheableItem* GetCacheableDisplayListItem() const { | ||
| return cacheable_item_.get()->asDisplayCacheableItem(); | ||
| } | ||
|
|
||
| SkPictureCacheableItem* GetCacheableSkPictureItem() { | ||
| return cacheable_item_.get()->asSkPictureCacheableItem(); | ||
| } | ||
|
|
||
| const SkPictureCacheableItem* GetCacheableSkPictureItem() const { | ||
| return cacheable_item_.get()->asSkPictureCacheableItem(); | ||
| } | ||
|
|
||
| protected: | ||
| const CacheableItem* GetCacheableItem() const { | ||
| return cacheable_item_.get(); | ||
| } | ||
|
|
||
| std::unique_ptr<CacheableItem> cacheable_item_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way this class is mixed in here, it just becomes a dispatcher for 3 other classes that encapsulate the concepts for each of the 3 types of cacheable.
Just instantiate the type of CacheableItem in the constructor of the layers and declare a type-specific field in those classes and this entire class goes away.
AutoCache can be a simple class that takes the base CacheableItem type and calls methods on it and doesn't need 3 different type of Create methods.