5#include "flutter/display_list/benchmarking/dl_complexity_gl.h"
17DisplayListGLComplexityCalculator*
18 DisplayListGLComplexityCalculator::instance_ =
nullptr;
20DisplayListGLComplexityCalculator*
22 if (instance_ ==
nullptr) {
28unsigned int DisplayListGLComplexityCalculator::GLHelper::BatchedComplexity() {
30 unsigned int save_layer_complexity;
31 if (save_layer_count_ == 0) {
32 save_layer_complexity = 0;
36 save_layer_complexity = (save_layer_count_ + 50) * 40000;
39 unsigned int draw_text_blob_complexity;
40 if (draw_text_blob_count_ == 0) {
41 draw_text_blob_complexity = 0;
45 draw_text_blob_complexity = (draw_text_blob_count_ + 60) * 2500 / 3;
48 return save_layer_complexity + draw_text_blob_complexity;
51void DisplayListGLComplexityCalculator::GLHelper::saveLayer(
54 const DlImageFilter* backdrop) {
62 AccumulateComplexity(Ceiling());
67void DisplayListGLComplexityCalculator::GLHelper::drawLine(
const SkPoint& p0,
79 float non_hairline_penalty = 1.0f;
80 unsigned int aa_penalty = 1;
83 if (!IsHairline() && !IsAntiAliased()) {
84 non_hairline_penalty = 1.15f;
86 if (IsAntiAliased()) {
97 unsigned int complexity =
98 ((
distance + 520) / 2) * non_hairline_penalty * aa_penalty;
100 AccumulateComplexity(complexity);
103void DisplayListGLComplexityCalculator::GLHelper::drawRect(
const SkRect& rect) {
108 unsigned int complexity;
119 unsigned int area =
rect.width() *
rect.height();
123 complexity = area * 2 / 175;
128 if (IsAntiAliased()) {
131 complexity =
length * 4 / 3;
145 complexity = std::min(
length, 1000u) * 2;
149 AccumulateComplexity(complexity);
152void DisplayListGLComplexityCalculator::GLHelper::drawOval(
164 unsigned int complexity;
172 complexity = area / 30;
174 if (IsAntiAliased()) {
177 complexity = area / 20;
184 complexity =
length * 8 / 3;
188 AccumulateComplexity(complexity);
191void DisplayListGLComplexityCalculator::GLHelper::drawCircle(
198 unsigned int complexity;
204 unsigned int area = radius * radius;
207 complexity = (area + 26250) * 8 / 105;
210 if (!IsAntiAliased()) {
215 if (IsAntiAliased()) {
218 complexity = (radius + 30) * 40 / 3;
222 complexity = (radius + 200) * 4;
226 AccumulateComplexity(complexity);
229void DisplayListGLComplexityCalculator::GLHelper::drawRRect(
243 unsigned int complexity;
253 complexity = (area + 1600) / 80;
260 if (IsAntiAliased()) {
263 complexity = (
length + 25) * 8 / 5;
267 complexity = ((
length * 2) + 75) * 2 / 5;
271 AccumulateComplexity(complexity);
274void DisplayListGLComplexityCalculator::GLHelper::drawDRRect(
290 unsigned int complexity;
299 unsigned int area = outer.
width() * outer.
height();
303 complexity = (area + 250) / 5;
307 complexity = (area + 3200) / 16;
311 if (IsAntiAliased()) {
314 complexity = (
length + 15) * 20 / 3;
318 complexity = ((
length * 2) + 27) * 50 / 27;
322 AccumulateComplexity(complexity);
325void DisplayListGLComplexityCalculator::GLHelper::drawPath(
const SkPath&
path) {
335 unsigned int line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost;
336 unsigned int complexity;
338 if (IsAntiAliased()) {
343 line_verb_cost = 235;
344 quad_verb_cost = 365;
345 conic_verb_cost = 365;
346 cubic_verb_cost = 725;
352 line_verb_cost = 135;
353 quad_verb_cost = 150;
354 conic_verb_cost = 200;
355 cubic_verb_cost = 235;
358 complexity += CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
359 conic_verb_cost, cubic_verb_cost);
361 AccumulateComplexity(complexity);
364void DisplayListGLComplexityCalculator::GLHelper::drawArc(
365 const SkRect& oval_bounds,
376 unsigned int area = oval_bounds.
width() * oval_bounds.
height();
377 unsigned int complexity;
386 if (IsAntiAliased()) {
389 complexity = (area + 45600) / 171;
391 unsigned int diameter = (oval_bounds.
width() + oval_bounds.
height()) / 2;
398 unsigned int log_diameter = 15 *
log(diameter);
399 complexity = (log_diameter - std::max(log_diameter, 100u)) * 200 / 9;
402 if (IsAntiAliased()) {
405 complexity = (area + 10000) / 45;
409 complexity = (area + 52000) * 2 / 585;
413 AccumulateComplexity(complexity);
416void DisplayListGLComplexityCalculator::GLHelper::drawPoints(
423 unsigned int complexity;
425 if (IsAntiAliased()) {
431 complexity =
count * 400 / 9;
435 complexity =
count * 400;
441 complexity =
count * 800 / 3;
445 complexity =
count * 400;
451 complexity =
count * 4000 / 7;
455 complexity =
count * 800;
463 complexity = (
count + 4500) * 100 / 9;
468 complexity = (
count + 2125) * 400 / 17;
472 complexity = (
count + 2250) * 200 / 9;
479 complexity = (
count + 1875) * 80 / 3;
483 AccumulateComplexity(complexity);
486void DisplayListGLComplexityCalculator::GLHelper::drawVertices(
487 const DlVertices* vertices,
500 unsigned int complexity = (vertices->vertex_count() + 1600) * 250 / 2;
502 AccumulateComplexity(complexity);
505void DisplayListGLComplexityCalculator::GLHelper::drawImage(
509 bool render_with_attributes) {
522 unsigned int area = dimensions.
width() * dimensions.
height();
526 unsigned int complexity =
length * 400 / 13;
537 if (IsAntiAliased()) {
538 multiplier = area / 60000.0f;
539 complexity = complexity * multiplier + 4000;
541 multiplier = area / 19000.0f;
542 complexity = complexity * multiplier;
546 AccumulateComplexity(complexity);
549void DisplayListGLComplexityCalculator::GLHelper::ImageRect(
552 bool render_with_attributes,
553 bool enforce_src_edges) {
565 unsigned int complexity;
566 if (!texture_backed || (texture_backed && render_with_attributes &&
567 enforce_src_edges && IsAntiAliased())) {
568 unsigned int area =
size.width() *
size.height();
571 complexity = (area + 20000) / 10;
579 complexity =
length * 200 / 11;
582 AccumulateComplexity(complexity);
585void DisplayListGLComplexityCalculator::GLHelper::drawImageNine(
590 bool render_with_attributes) {
596 unsigned int area = dimensions.
width() * dimensions.
height();
600 unsigned int complexity = (area + 10800) / 9;
607 AccumulateComplexity(complexity);
610void DisplayListGLComplexityCalculator::GLHelper::drawDisplayList(
616 GLHelper helper(Ceiling() - CurrentComplexityScore());
617 if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
618 auto bounds = display_list->bounds();
621 display_list->Dispatch(helper);
622 AccumulateComplexity(helper.ComplexityScore());
625void DisplayListGLComplexityCalculator::GLHelper::drawTextBlob(
638 draw_text_blob_count_++;
641void DisplayListGLComplexityCalculator::GLHelper::drawTextFrame(
642 const std::shared_ptr<impeller::TextFrame>& text_frame,
646void DisplayListGLComplexityCalculator::GLHelper::drawShadow(
650 bool transparent_occluder,
661 float occluder_penalty = 1.0f;
662 if (transparent_occluder) {
663 occluder_penalty = 1.20f;
674 unsigned int line_verb_cost = 17000;
675 unsigned int quad_verb_cost = 20000;
676 unsigned int conic_verb_cost = 20000;
677 unsigned int cubic_verb_cost = 120000;
679 unsigned int complexity = CalculatePathComplexity(
680 path, line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost);
682 AccumulateComplexity(complexity * occluder_penalty);
static const int points[]
static SkScalar center(float pos0, float pos1)
SkISize dimensions() const
virtual bool isTextureBacked() const =0
@ kSimple_Type
non-zero width and height with equal radii
@ kComplex_Type
non-zero width and height with arbitrary radii
static DisplayListGLComplexityCalculator * GetInstance()
@ kLines
draw each separate pair of points as a line segment
@ kPoints
draw each point separately
static const SaveLayerOptions kWithAttributes
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SIN Vec< N, float > abs(const Vec< N, float > &x)
constexpr int32_t width() const
constexpr int32_t height() const
constexpr float y() const
constexpr float x() const
constexpr float height() const
constexpr float width() const