5#include "flutter/display_list/benchmarking/dl_complexity_metal.h"
17DisplayListMetalComplexityCalculator*
18 DisplayListMetalComplexityCalculator::instance_ =
nullptr;
20DisplayListMetalComplexityCalculator*
22 if (instance_ ==
nullptr) {
29DisplayListMetalComplexityCalculator::MetalHelper::BatchedComplexity() {
31 unsigned int save_layer_complexity;
32 if (save_layer_count_ == 0) {
33 save_layer_complexity = 0;
50 save_layer_complexity = (save_layer_count_ + 2) * 100000;
53 unsigned int draw_text_blob_complexity;
54 if (draw_text_blob_count_ == 0) {
55 draw_text_blob_complexity = 0;
59 draw_text_blob_complexity = (draw_text_blob_count_ + 180) * 2500 / 3;
62 return save_layer_complexity + draw_text_blob_complexity;
65void DisplayListMetalComplexityCalculator::MetalHelper::saveLayer(
76 AccumulateComplexity(Ceiling());
81void DisplayListMetalComplexityCalculator::MetalHelper::drawLine(
91 float non_hairline_penalty = 1.0f;
92 float aa_penalty = 1.0f;
95 non_hairline_penalty = 1.15f;
97 if (IsAntiAliased()) {
108 unsigned int complexity =
109 ((
distance + 225) * 4 / 9) * non_hairline_penalty * aa_penalty;
111 AccumulateComplexity(complexity);
114void DisplayListMetalComplexityCalculator::MetalHelper::drawDashedLine(
124void DisplayListMetalComplexityCalculator::MetalHelper::drawRect(
130 unsigned int complexity;
143 unsigned int area =
rect.width() *
rect.height();
147 complexity = area / 225;
153 if (IsAntiAliased()) {
156 complexity =
length * 8 / 13;
160 complexity =
length * 8 / 7;
164 AccumulateComplexity(complexity);
167void DisplayListMetalComplexityCalculator::MetalHelper::drawOval(
179 unsigned int complexity;
187 complexity = area / 80;
189 if (IsAntiAliased()) {
192 complexity = area * 2 / 75;
199 complexity =
length * 5 / 2;
203 AccumulateComplexity(complexity);
206void DisplayListMetalComplexityCalculator::MetalHelper::drawCircle(
213 unsigned int complexity;
219 unsigned int area = radius * radius;
222 complexity = (area + 6500) * 2 / 65;
225 if (!IsAntiAliased()) {
230 if (IsAntiAliased()) {
233 complexity = (radius + 49) * 40 / 7;
237 complexity = (radius + 128) * 5 / 2;
241 AccumulateComplexity(complexity);
244void DisplayListMetalComplexityCalculator::MetalHelper::drawRRect(
258 ((
rrect.
getType() == SkRRect::Type::kSimple_Type) && IsAntiAliased());
260 unsigned int complexity;
269 complexity = (area + 10500) / 175;
274 complexity = (area + 50000) / 625;
277 AccumulateComplexity(complexity);
280void DisplayListMetalComplexityCalculator::MetalHelper::drawDRRect(
297 unsigned int complexity;
306 unsigned int area = outer.
width() * outer.
height();
307 if (outer.
getType() == SkRRect::Type::kComplex_Type) {
310 complexity = (area + 1000) / 10;
312 if (IsAntiAliased()) {
315 complexity = (area + 5250) / 35;
319 complexity = (300 + (10 *
length)) / 3;
325 complexity = ((10 *
length) + 1050) / 6;
328 AccumulateComplexity(complexity);
342 unsigned int line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost;
344 if (IsAntiAliased()) {
346 quad_verb_cost = 100;
347 conic_verb_cost = 160;
348 cubic_verb_cost = 210;
352 conic_verb_cost = 140;
353 cubic_verb_cost = 210;
357 unsigned int complexity =
358 200000 + CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
359 conic_verb_cost, cubic_verb_cost);
361 AccumulateComplexity(complexity);
364void DisplayListMetalComplexityCalculator::MetalHelper::drawArc(
365 const SkRect& oval_bounds,
376 unsigned int diameter = (oval_bounds.
width() + oval_bounds.
height()) / 2;
377 unsigned int area = oval_bounds.
width() * oval_bounds.
height();
379 unsigned int complexity;
388 if (IsAntiAliased()) {
391 complexity = (area + 136000) * 2 / 765;
395 complexity = (diameter + 180) * 10 / 27;
398 if (IsAntiAliased()) {
401 complexity = (area + 400000) / 900;
405 complexity = (area + 16800) * 2 / 189;
409 AccumulateComplexity(complexity);
412void DisplayListMetalComplexityCalculator::MetalHelper::drawPoints(
419 unsigned int complexity;
423 if (!IsAntiAliased()) {
426 complexity = (
count + 12000) * 25 / 2;
431 complexity = (
count + 1250) * 160;
437 complexity =
count * 400 / 29;
441 complexity = (
count + 1650) * 1000 / 11;
445 AccumulateComplexity(complexity);
448void DisplayListMetalComplexityCalculator::MetalHelper::drawVertices(
449 const DlVertices* vertices,
462 unsigned int complexity = (vertices->vertex_count() + 4000) * 50;
464 AccumulateComplexity(complexity);
467void DisplayListMetalComplexityCalculator::MetalHelper::drawImage(
471 bool render_with_attributes) {
483 unsigned int area = dimensions.
width() * dimensions.
height();
487 unsigned int complexity = (area + 51000) * 4 / 170;
495 float multiplier = area / 35000.0f;
496 complexity = complexity * multiplier + 1200;
499 AccumulateComplexity(complexity);
502void DisplayListMetalComplexityCalculator::MetalHelper::ImageRect(
505 bool render_with_attributes,
506 bool enforce_src_edges) {
514 unsigned int area =
size.width() *
size.height();
519 unsigned int complexity;
520 if (texture_backed) {
524 complexity = (area + 52900) * 2 / 115;
525 if (render_with_attributes && enforce_src_edges && IsAntiAliased()) {
530 if (render_with_attributes && enforce_src_edges && IsAntiAliased()) {
533 complexity = (area + 33550) * 2 / 61;
537 complexity = (area + 36250) * 4 / 145;
541 AccumulateComplexity(complexity);
544void DisplayListMetalComplexityCalculator::MetalHelper::drawImageNine(
549 bool render_with_attributes) {
556 unsigned int area = dimensions.
width() * dimensions.
height();
560 unsigned int complexity = (area + 24000) / 20;
561 AccumulateComplexity(complexity);
564void DisplayListMetalComplexityCalculator::MetalHelper::drawDisplayList(
570 MetalHelper helper(Ceiling() - CurrentComplexityScore());
571 if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
572 auto bounds = display_list->bounds();
575 display_list->Dispatch(helper);
576 AccumulateComplexity(helper.ComplexityScore());
592 draw_text_blob_count_++;
595void DisplayListMetalComplexityCalculator::MetalHelper::drawTextFrame(
596 const std::shared_ptr<impeller::TextFrame>& text_frame,
600void DisplayListMetalComplexityCalculator::MetalHelper::drawShadow(
604 bool transparent_occluder,
615 float occluder_penalty = 1.0f;
616 if (transparent_occluder) {
617 occluder_penalty = 1.05f;
628 unsigned int line_verb_cost = 20000;
629 unsigned int quad_verb_cost = 20000;
630 unsigned int conic_verb_cost = 20000;
631 unsigned int cubic_verb_cost = 80000;
633 unsigned int complexity =
634 0 + CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
635 conic_verb_cost, cubic_verb_cost);
637 AccumulateComplexity(complexity * occluder_penalty);
static const int points[]
SkISize dimensions() const
virtual bool isTextureBacked() const =0
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately
static const SaveLayerOptions kWithAttributes
static void drawPath(SkPath &path, SkCanvas *canvas, SkColor color, const SkRect &clip, SkPaint::Cap cap, SkPaint::Join join, SkPaint::Style style, SkPathFillType fill, SkScalar strokeWidth)
drawTextBlob(r.blob.get(), r.x, r.y, r.paint)) DRAW(DrawSlug
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< const SkImageFilter > backdrop
sk_sp< SkBlender > blender SkRect rect
SkSamplingOptions sampling
impeller::Scalar DlScalar
const SkPoint & ToSkPoint(const DlPoint &point)
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)
flutter::SaveLayerOptions SaveLayerOptions
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