Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0a4e7c0

Browse files
committed
re-using the 'is_complex' flag
1 parent c5bfc8b commit 0a4e7c0

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

flow/layers/display_list_layer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ void DisplayListLayer::Preroll(PrerollContext* context,
9999
if (auto* cache = context->raster_cache) {
100100
TRACE_EVENT0("flutter", "DisplayListLayer::RasterCache (Preroll)");
101101
if (context->cull_rect.intersects(bounds)) {
102-
if (cache->Prepare(context, disp_list, is_complex_, will_change_, matrix,
103-
offset_)) {
102+
if (cache->Prepare(context, disp_list, /*for_testing=*/false,
103+
will_change_, matrix, offset_, is_complex_)) {
104104
context->subtree_can_inherit_opacity = true;
105105
}
106106
} else {

flow/layers/picture_layer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
117117
if (auto* cache = context->raster_cache) {
118118
TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)");
119119
if (context->cull_rect.intersects(bounds)) {
120-
if (cache->Prepare(context, sk_picture, is_complex_, will_change_, matrix,
121-
offset_)) {
120+
if (cache->Prepare(context, sk_picture, /*for_testing=*/false,
121+
will_change_, matrix, offset_, is_complex_)) {
122122
context->subtree_can_inherit_opacity = true;
123123
}
124124
} else {

flow/raster_cache.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static bool CanRasterizeRect(const SkRect& cull_rect) {
6363
static bool IsPictureWorthRasterizing(SkPicture* picture,
6464
bool will_change,
6565
bool is_complex,
66-
bool is_high_priority) {
66+
bool for_testing) {
6767
if (will_change) {
6868
// If the picture is going to change in the future, there is no point in
6969
// doing to extra work to rasterize.
@@ -76,7 +76,7 @@ static bool IsPictureWorthRasterizing(SkPicture* picture,
7676
return false;
7777
}
7878

79-
if (is_complex || is_high_priority) {
79+
if (is_complex || for_testing) {
8080
// The caller seems to have extra information about the picture and thinks
8181
// the picture is always worth rasterizing.
8282
return true;
@@ -91,7 +91,7 @@ static bool IsDisplayListWorthRasterizing(
9191
DisplayList* display_list,
9292
bool will_change,
9393
bool is_complex,
94-
bool is_high_priority,
94+
bool for_testing,
9595
DisplayListComplexityCalculator* complexity_calculator) {
9696
if (will_change) {
9797
// If the display list is going to change in the future, there is no point
@@ -105,7 +105,7 @@ static bool IsDisplayListWorthRasterizing(
105105
return false;
106106
}
107107

108-
if (is_complex || is_high_priority) {
108+
if (is_complex || for_testing) {
109109
// The caller seems to have extra information about the display list and
110110
// thinks the display list is always worth rasterizing.
111111
return true;
@@ -222,17 +222,17 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizeLayer(
222222

223223
bool RasterCache::Prepare(PrerollContext* context,
224224
SkPicture* picture,
225-
bool is_complex,
225+
bool for_testing,
226226
bool will_change,
227227
const SkMatrix& untranslated_matrix,
228228
const SkPoint& offset,
229-
bool is_high_priority) {
229+
bool is_complex) {
230230
if (!GenerateNewCacheInThisFrame()) {
231231
return false;
232232
}
233233

234234
if (!IsPictureWorthRasterizing(picture, will_change, is_complex,
235-
is_high_priority)) {
235+
for_testing)) {
236236
// We only deal with pictures that are worthy of rasterization.
237237
return false;
238238
}
@@ -250,8 +250,8 @@ bool RasterCache::Prepare(PrerollContext* context,
250250

251251
// Creates an entry, if not present prior.
252252
Entry& entry = cache_[cache_key];
253-
entry.is_high_priority = is_high_priority;
254-
if (!is_high_priority && entry.access_count < access_threshold_) {
253+
entry.is_complex = is_complex;
254+
if (!is_complex && entry.access_count < access_threshold_) {
255255
// Frame threshold has not yet been reached.
256256
return false;
257257
}
@@ -273,11 +273,11 @@ bool RasterCache::Prepare(PrerollContext* context,
273273

274274
bool RasterCache::Prepare(PrerollContext* context,
275275
DisplayList* display_list,
276-
bool is_complex,
276+
bool for_testing,
277277
bool will_change,
278278
const SkMatrix& untranslated_matrix,
279279
const SkPoint& offset,
280-
bool is_high_priority) {
280+
bool is_complex) {
281281
if (!GenerateNewCacheInThisFrame()) {
282282
return false;
283283
}
@@ -288,7 +288,7 @@ bool RasterCache::Prepare(PrerollContext* context,
288288
: DisplayListComplexityCalculator::GetForSoftware();
289289

290290
if (!IsDisplayListWorthRasterizing(display_list, will_change, is_complex,
291-
is_high_priority, complexity_calculator)) {
291+
for_testing, complexity_calculator)) {
292292
// We only deal with display lists that are worthy of rasterization.
293293
return false;
294294
}
@@ -307,8 +307,8 @@ bool RasterCache::Prepare(PrerollContext* context,
307307

308308
// Creates an entry, if not present prior.
309309
Entry& entry = cache_[cache_key];
310-
entry.is_high_priority = is_high_priority;
311-
if (!is_high_priority && entry.access_count < access_threshold_) {
310+
entry.is_complex = is_complex;
311+
if (!is_complex && entry.access_count < access_threshold_) {
312312
// Frame threshold has not yet been reached.
313313
return false;
314314
}

flow/raster_cache.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,18 @@ class RasterCache {
196196
// 4. The picture is accessed too few times
197197
bool Prepare(PrerollContext* context,
198198
SkPicture* picture,
199-
bool is_complex,
199+
bool for_testing,
200200
bool will_change,
201201
const SkMatrix& untranslated_matrix,
202202
const SkPoint& offset = SkPoint(),
203-
bool is_high_priority = false);
203+
bool is_complex = false);
204204
bool Prepare(PrerollContext* context,
205205
DisplayList* display_list,
206-
bool is_complex,
206+
bool for_testing,
207207
bool will_change,
208208
const SkMatrix& untranslated_matrix,
209209
const SkPoint& offset = SkPoint(),
210-
bool is_high_priority = false);
210+
bool is_complex = false);
211211

212212
// If there is cache entry for this picture, display list or layer, mark it as
213213
// used for this frame in order to not get evicted. This is needed during
@@ -303,14 +303,14 @@ class RasterCache {
303303
struct Entry {
304304
// If the entry is high priority, it will always cache on first usage and
305305
// survive 3 frames without usage.
306-
bool is_high_priority = false;
306+
bool is_complex = false;
307307
bool used_this_frame = false;
308308
size_t access_count = 0;
309309
size_t unused_count = 0;
310310
std::unique_ptr<RasterCacheResult> image;
311311
// Return the number of frames the entry survives if it is not used. If the
312312
// number is 0, then it will be evicted when not in use.
313-
size_t unused_threshold() const { return is_high_priority ? 3 : 0; }
313+
size_t unused_threshold() const { return is_complex ? 3 : 0; }
314314
};
315315

316316
void Touch(const RasterCacheKey& cache_key);

0 commit comments

Comments
 (0)