From 0a4e7c02486a68af8bf660790d858fcd6e391288 Mon Sep 17 00:00:00 2001 From: ColdPaleLight Date: Wed, 23 Mar 2022 18:02:23 +0800 Subject: [PATCH] re-using the 'is_complex' flag --- flow/layers/display_list_layer.cc | 4 ++-- flow/layers/picture_layer.cc | 4 ++-- flow/raster_cache.cc | 28 ++++++++++++++-------------- flow/raster_cache.h | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/flow/layers/display_list_layer.cc b/flow/layers/display_list_layer.cc index f360602cf8376..c6cc038082b1b 100644 --- a/flow/layers/display_list_layer.cc +++ b/flow/layers/display_list_layer.cc @@ -99,8 +99,8 @@ void DisplayListLayer::Preroll(PrerollContext* context, if (auto* cache = context->raster_cache) { TRACE_EVENT0("flutter", "DisplayListLayer::RasterCache (Preroll)"); if (context->cull_rect.intersects(bounds)) { - if (cache->Prepare(context, disp_list, is_complex_, will_change_, matrix, - offset_)) { + if (cache->Prepare(context, disp_list, /*for_testing=*/false, + will_change_, matrix, offset_, is_complex_)) { context->subtree_can_inherit_opacity = true; } } else { diff --git a/flow/layers/picture_layer.cc b/flow/layers/picture_layer.cc index f93437d993bdf..ba3f7c9dc9d51 100644 --- a/flow/layers/picture_layer.cc +++ b/flow/layers/picture_layer.cc @@ -117,8 +117,8 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { if (auto* cache = context->raster_cache) { TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)"); if (context->cull_rect.intersects(bounds)) { - if (cache->Prepare(context, sk_picture, is_complex_, will_change_, matrix, - offset_)) { + if (cache->Prepare(context, sk_picture, /*for_testing=*/false, + will_change_, matrix, offset_, is_complex_)) { context->subtree_can_inherit_opacity = true; } } else { diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index 101a83180e847..47f87e3455cc3 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -63,7 +63,7 @@ static bool CanRasterizeRect(const SkRect& cull_rect) { static bool IsPictureWorthRasterizing(SkPicture* picture, bool will_change, bool is_complex, - bool is_high_priority) { + bool for_testing) { if (will_change) { // If the picture is going to change in the future, there is no point in // doing to extra work to rasterize. @@ -76,7 +76,7 @@ static bool IsPictureWorthRasterizing(SkPicture* picture, return false; } - if (is_complex || is_high_priority) { + if (is_complex || for_testing) { // The caller seems to have extra information about the picture and thinks // the picture is always worth rasterizing. return true; @@ -91,7 +91,7 @@ static bool IsDisplayListWorthRasterizing( DisplayList* display_list, bool will_change, bool is_complex, - bool is_high_priority, + bool for_testing, DisplayListComplexityCalculator* complexity_calculator) { if (will_change) { // If the display list is going to change in the future, there is no point @@ -105,7 +105,7 @@ static bool IsDisplayListWorthRasterizing( return false; } - if (is_complex || is_high_priority) { + if (is_complex || for_testing) { // The caller seems to have extra information about the display list and // thinks the display list is always worth rasterizing. return true; @@ -222,17 +222,17 @@ std::unique_ptr RasterCache::RasterizeLayer( bool RasterCache::Prepare(PrerollContext* context, SkPicture* picture, - bool is_complex, + bool for_testing, bool will_change, const SkMatrix& untranslated_matrix, const SkPoint& offset, - bool is_high_priority) { + bool is_complex) { if (!GenerateNewCacheInThisFrame()) { return false; } if (!IsPictureWorthRasterizing(picture, will_change, is_complex, - is_high_priority)) { + for_testing)) { // We only deal with pictures that are worthy of rasterization. return false; } @@ -250,8 +250,8 @@ bool RasterCache::Prepare(PrerollContext* context, // Creates an entry, if not present prior. Entry& entry = cache_[cache_key]; - entry.is_high_priority = is_high_priority; - if (!is_high_priority && entry.access_count < access_threshold_) { + entry.is_complex = is_complex; + if (!is_complex && entry.access_count < access_threshold_) { // Frame threshold has not yet been reached. return false; } @@ -273,11 +273,11 @@ bool RasterCache::Prepare(PrerollContext* context, bool RasterCache::Prepare(PrerollContext* context, DisplayList* display_list, - bool is_complex, + bool for_testing, bool will_change, const SkMatrix& untranslated_matrix, const SkPoint& offset, - bool is_high_priority) { + bool is_complex) { if (!GenerateNewCacheInThisFrame()) { return false; } @@ -288,7 +288,7 @@ bool RasterCache::Prepare(PrerollContext* context, : DisplayListComplexityCalculator::GetForSoftware(); if (!IsDisplayListWorthRasterizing(display_list, will_change, is_complex, - is_high_priority, complexity_calculator)) { + for_testing, complexity_calculator)) { // We only deal with display lists that are worthy of rasterization. return false; } @@ -307,8 +307,8 @@ bool RasterCache::Prepare(PrerollContext* context, // Creates an entry, if not present prior. Entry& entry = cache_[cache_key]; - entry.is_high_priority = is_high_priority; - if (!is_high_priority && entry.access_count < access_threshold_) { + entry.is_complex = is_complex; + if (!is_complex && entry.access_count < access_threshold_) { // Frame threshold has not yet been reached. return false; } diff --git a/flow/raster_cache.h b/flow/raster_cache.h index f1331d638ebfe..a1a84dea04dcd 100644 --- a/flow/raster_cache.h +++ b/flow/raster_cache.h @@ -196,18 +196,18 @@ class RasterCache { // 4. The picture is accessed too few times bool Prepare(PrerollContext* context, SkPicture* picture, - bool is_complex, + bool for_testing, bool will_change, const SkMatrix& untranslated_matrix, const SkPoint& offset = SkPoint(), - bool is_high_priority = false); + bool is_complex = false); bool Prepare(PrerollContext* context, DisplayList* display_list, - bool is_complex, + bool for_testing, bool will_change, const SkMatrix& untranslated_matrix, const SkPoint& offset = SkPoint(), - bool is_high_priority = false); + bool is_complex = false); // If there is cache entry for this picture, display list or layer, mark it as // used for this frame in order to not get evicted. This is needed during @@ -303,14 +303,14 @@ class RasterCache { struct Entry { // If the entry is high priority, it will always cache on first usage and // survive 3 frames without usage. - bool is_high_priority = false; + bool is_complex = false; bool used_this_frame = false; size_t access_count = 0; size_t unused_count = 0; std::unique_ptr image; // Return the number of frames the entry survives if it is not used. If the // number is 0, then it will be evicted when not in use. - size_t unused_threshold() const { return is_high_priority ? 3 : 0; } + size_t unused_threshold() const { return is_complex ? 3 : 0; } }; void Touch(const RasterCacheKey& cache_key);