Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dl_complexity.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_COMPLEXITY_H_
6#define FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_COMPLEXITY_H_
7
8#include "flutter/display_list/display_list.h"
9
11
12namespace flutter {
13
15 public:
18
20
21 // Returns a calculated complexity score for a given DisplayList object
22 virtual unsigned int Compute(const DisplayList* display_list) = 0;
23
24 // Returns whether a given complexity score meets the threshold for
25 // cacheability for this particular ComplexityCalculator
26 virtual bool ShouldBeCached(unsigned int complexity_score) = 0;
27
28 // Sets a ceiling for the complexity score being calculated. By default
29 // this is the largest number representable by an unsigned int.
30 //
31 // This setting has no effect on non-accumulator based scorers such as
32 // the Naive calculator.
33 virtual void SetComplexityCeiling(unsigned int ceiling) = 0;
34};
35
38 public:
40
41 unsigned int Compute(const DisplayList* display_list) override {
42 return display_list->op_count(true);
43 }
44
45 bool ShouldBeCached(unsigned int complexity_score) override {
46 return complexity_score > 5u;
47 }
48
49 void SetComplexityCeiling(unsigned int ceiling) override {}
50
51 private:
53 static DisplayListNaiveComplexityCalculator* instance_;
54};
55
56} // namespace flutter
57
58#endif // FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_COMPLEXITY_H_
const char * backend
GrBackendApi
Definition GrTypes.h:95
static DisplayListComplexityCalculator * GetForBackend(GrBackendApi backend)
virtual void SetComplexityCeiling(unsigned int ceiling)=0
static DisplayListComplexityCalculator * GetForSoftware()
virtual ~DisplayListComplexityCalculator()=default
virtual bool ShouldBeCached(unsigned int complexity_score)=0
virtual unsigned int Compute(const DisplayList *display_list)=0
unsigned int Compute(const DisplayList *display_list) override
bool ShouldBeCached(unsigned int complexity_score) override
void SetComplexityCeiling(unsigned int ceiling) override
static DisplayListComplexityCalculator * GetInstance()
uint32_t op_count(bool nested=false) const