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(
68 const DlImageFilter* backdrop) {
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::drawRect(
120 unsigned int complexity;
133 unsigned int area =
rect.width() *
rect.height();
137 complexity = area / 225;
143 if (IsAntiAliased()) {
146 complexity =
length * 8 / 13;
150 complexity =
length * 8 / 7;
154 AccumulateComplexity(complexity);
157void DisplayListMetalComplexityCalculator::MetalHelper::drawOval(
169 unsigned int complexity;
177 complexity = area / 80;
179 if (IsAntiAliased()) {
182 complexity = area * 2 / 75;
189 complexity =
length * 5 / 2;
193 AccumulateComplexity(complexity);
196void DisplayListMetalComplexityCalculator::MetalHelper::drawCircle(
203 unsigned int complexity;
209 unsigned int area = radius * radius;
212 complexity = (area + 6500) * 2 / 65;
215 if (!IsAntiAliased()) {
220 if (IsAntiAliased()) {
223 complexity = (radius + 49) * 40 / 7;
227 complexity = (radius + 128) * 5 / 2;
231 AccumulateComplexity(complexity);
234void DisplayListMetalComplexityCalculator::MetalHelper::drawRRect(
250 unsigned int complexity;
259 complexity = (area + 10500) / 175;
264 complexity = (area + 50000) / 625;
267 AccumulateComplexity(complexity);
270void DisplayListMetalComplexityCalculator::MetalHelper::drawDRRect(
287 unsigned int complexity;
296 unsigned int area = outer.
width() * outer.
height();
300 complexity = (area + 1000) / 10;
302 if (IsAntiAliased()) {
305 complexity = (area + 5250) / 35;
309 complexity = (300 + (10 *
length)) / 3;
315 complexity = ((10 *
length) + 1050) / 6;
318 AccumulateComplexity(complexity);
321void DisplayListMetalComplexityCalculator::MetalHelper::drawPath(
332 unsigned int line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost;
334 if (IsAntiAliased()) {
336 quad_verb_cost = 100;
337 conic_verb_cost = 160;
338 cubic_verb_cost = 210;
342 conic_verb_cost = 140;
343 cubic_verb_cost = 210;
347 unsigned int complexity =
348 200000 + CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
349 conic_verb_cost, cubic_verb_cost);
351 AccumulateComplexity(complexity);
354void DisplayListMetalComplexityCalculator::MetalHelper::drawArc(
355 const SkRect& oval_bounds,
366 unsigned int diameter = (oval_bounds.
width() + oval_bounds.
height()) / 2;
367 unsigned int area = oval_bounds.
width() * oval_bounds.
height();
369 unsigned int complexity;
378 if (IsAntiAliased()) {
381 complexity = (area + 136000) * 2 / 765;
385 complexity = (diameter + 180) * 10 / 27;
388 if (IsAntiAliased()) {
391 complexity = (area + 400000) / 900;
395 complexity = (area + 16800) * 2 / 189;
399 AccumulateComplexity(complexity);
402void DisplayListMetalComplexityCalculator::MetalHelper::drawPoints(
409 unsigned int complexity;
413 if (!IsAntiAliased()) {
416 complexity = (
count + 12000) * 25 / 2;
421 complexity = (
count + 1250) * 160;
427 complexity =
count * 400 / 29;
431 complexity = (
count + 1650) * 1000 / 11;
435 AccumulateComplexity(complexity);
438void DisplayListMetalComplexityCalculator::MetalHelper::drawVertices(
439 const DlVertices* vertices,
452 unsigned int complexity = (vertices->vertex_count() + 4000) * 50;
454 AccumulateComplexity(complexity);
457void DisplayListMetalComplexityCalculator::MetalHelper::drawImage(
461 bool render_with_attributes) {
473 unsigned int area = dimensions.
width() * dimensions.
height();
477 unsigned int complexity = (area + 51000) * 4 / 170;
485 float multiplier = area / 35000.0f;
486 complexity = complexity * multiplier + 1200;
489 AccumulateComplexity(complexity);
492void DisplayListMetalComplexityCalculator::MetalHelper::ImageRect(
495 bool render_with_attributes,
496 bool enforce_src_edges) {
504 unsigned int area =
size.width() *
size.height();
509 unsigned int complexity;
510 if (texture_backed) {
514 complexity = (area + 52900) * 2 / 115;
515 if (render_with_attributes && enforce_src_edges && IsAntiAliased()) {
520 if (render_with_attributes && enforce_src_edges && IsAntiAliased()) {
523 complexity = (area + 33550) * 2 / 61;
527 complexity = (area + 36250) * 4 / 145;
531 AccumulateComplexity(complexity);
534void DisplayListMetalComplexityCalculator::MetalHelper::drawImageNine(
539 bool render_with_attributes) {
546 unsigned int area = dimensions.
width() * dimensions.
height();
550 unsigned int complexity = (area + 24000) / 20;
551 AccumulateComplexity(complexity);
554void DisplayListMetalComplexityCalculator::MetalHelper::drawDisplayList(
560 MetalHelper helper(Ceiling() - CurrentComplexityScore());
561 if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
562 auto bounds = display_list->bounds();
565 display_list->Dispatch(helper);
566 AccumulateComplexity(helper.ComplexityScore());
569void DisplayListMetalComplexityCalculator::MetalHelper::drawTextBlob(
582 draw_text_blob_count_++;
585void DisplayListMetalComplexityCalculator::MetalHelper::drawTextFrame(
586 const std::shared_ptr<impeller::TextFrame>& text_frame,
590void DisplayListMetalComplexityCalculator::MetalHelper::drawShadow(
594 bool transparent_occluder,
605 float occluder_penalty = 1.0f;
606 if (transparent_occluder) {
607 occluder_penalty = 1.05f;
618 unsigned int line_verb_cost = 20000;
619 unsigned int quad_verb_cost = 20000;
620 unsigned int conic_verb_cost = 20000;
621 unsigned int cubic_verb_cost = 80000;
623 unsigned int complexity =
624 0 + CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
625 conic_verb_cost, cubic_verb_cost);
627 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
@ kPolygon
draw each pair of overlapping 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