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(
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::drawDashedLine(
113void DisplayListGLComplexityCalculator::GLHelper::drawRect(
const SkRect&
rect) {
118 unsigned int complexity;
129 unsigned int area =
rect.width() *
rect.height();
133 complexity = area * 2 / 175;
138 if (IsAntiAliased()) {
141 complexity =
length * 4 / 3;
159 AccumulateComplexity(complexity);
162void DisplayListGLComplexityCalculator::GLHelper::drawOval(
174 unsigned int complexity;
182 complexity = area / 30;
184 if (IsAntiAliased()) {
187 complexity = area / 20;
194 complexity =
length * 8 / 3;
198 AccumulateComplexity(complexity);
201void DisplayListGLComplexityCalculator::GLHelper::drawCircle(
208 unsigned int complexity;
214 unsigned int area = radius * radius;
217 complexity = (area + 26250) * 8 / 105;
220 if (!IsAntiAliased()) {
225 if (IsAntiAliased()) {
228 complexity = (radius + 30) * 40 / 3;
232 complexity = (radius + 200) * 4;
236 AccumulateComplexity(complexity);
239void DisplayListGLComplexityCalculator::GLHelper::drawRRect(
253 unsigned int complexity;
259 ((
rrect.
getType() == SkRRect::Type::kSimple_Type) && IsAntiAliased())) {
263 complexity = (area + 1600) / 80;
270 if (IsAntiAliased()) {
273 complexity = (
length + 25) * 8 / 5;
277 complexity = ((
length * 2) + 75) * 2 / 5;
281 AccumulateComplexity(complexity);
284void DisplayListGLComplexityCalculator::GLHelper::drawDRRect(
300 unsigned int complexity;
309 unsigned int area = outer.
width() * outer.
height();
310 if (outer.
getType() == SkRRect::Type::kComplex_Type) {
313 complexity = (area + 250) / 5;
317 complexity = (area + 3200) / 16;
321 if (IsAntiAliased()) {
324 complexity = (
length + 15) * 20 / 3;
328 complexity = ((
length * 2) + 27) * 50 / 27;
332 AccumulateComplexity(complexity);
345 unsigned int line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost;
346 unsigned int complexity;
348 if (IsAntiAliased()) {
353 line_verb_cost = 235;
354 quad_verb_cost = 365;
355 conic_verb_cost = 365;
356 cubic_verb_cost = 725;
362 line_verb_cost = 135;
363 quad_verb_cost = 150;
364 conic_verb_cost = 200;
365 cubic_verb_cost = 235;
368 complexity += CalculatePathComplexity(
path, line_verb_cost, quad_verb_cost,
369 conic_verb_cost, cubic_verb_cost);
371 AccumulateComplexity(complexity);
374void DisplayListGLComplexityCalculator::GLHelper::drawArc(
375 const SkRect& oval_bounds,
386 unsigned int area = oval_bounds.
width() * oval_bounds.
height();
387 unsigned int complexity;
396 if (IsAntiAliased()) {
399 complexity = (area + 45600) / 171;
401 unsigned int diameter = (oval_bounds.
width() + oval_bounds.
height()) / 2;
408 unsigned int log_diameter = 15 *
log(diameter);
409 complexity = (log_diameter -
std::max(log_diameter, 100u)) * 200 / 9;
412 if (IsAntiAliased()) {
415 complexity = (area + 10000) / 45;
419 complexity = (area + 52000) * 2 / 585;
423 AccumulateComplexity(complexity);
426void DisplayListGLComplexityCalculator::GLHelper::drawPoints(
433 unsigned int complexity;
435 if (IsAntiAliased()) {
441 complexity =
count * 400 / 9;
445 complexity =
count * 400;
451 complexity =
count * 800 / 3;
455 complexity =
count * 400;
461 complexity =
count * 4000 / 7;
465 complexity =
count * 800;
473 complexity = (
count + 4500) * 100 / 9;
478 complexity = (
count + 2125) * 400 / 17;
482 complexity = (
count + 2250) * 200 / 9;
489 complexity = (
count + 1875) * 80 / 3;
493 AccumulateComplexity(complexity);
496void DisplayListGLComplexityCalculator::GLHelper::drawVertices(
497 const DlVertices* vertices,
510 unsigned int complexity = (vertices->vertex_count() + 1600) * 250 / 2;
512 AccumulateComplexity(complexity);
515void DisplayListGLComplexityCalculator::GLHelper::drawImage(
519 bool render_with_attributes) {
532 unsigned int area = dimensions.
width() * dimensions.
height();
536 unsigned int complexity =
length * 400 / 13;
547 if (IsAntiAliased()) {
548 multiplier = area / 60000.0f;
549 complexity = complexity * multiplier + 4000;
551 multiplier = area / 19000.0f;
552 complexity = complexity * multiplier;
556 AccumulateComplexity(complexity);
559void DisplayListGLComplexityCalculator::GLHelper::ImageRect(
562 bool render_with_attributes,
563 bool enforce_src_edges) {
575 unsigned int complexity;
576 if (!texture_backed || (texture_backed && render_with_attributes &&
577 enforce_src_edges && IsAntiAliased())) {
578 unsigned int area =
size.width() *
size.height();
581 complexity = (area + 20000) / 10;
589 complexity =
length * 200 / 11;
592 AccumulateComplexity(complexity);
595void DisplayListGLComplexityCalculator::GLHelper::drawImageNine(
600 bool render_with_attributes) {
606 unsigned int area = dimensions.
width() * dimensions.
height();
610 unsigned int complexity = (area + 10800) / 9;
617 AccumulateComplexity(complexity);
620void DisplayListGLComplexityCalculator::GLHelper::drawDisplayList(
626 GLHelper helper(Ceiling() - CurrentComplexityScore());
627 if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
628 auto bounds = display_list->bounds();
631 display_list->Dispatch(helper);
632 AccumulateComplexity(helper.ComplexityScore());
648 draw_text_blob_count_++;
651void DisplayListGLComplexityCalculator::GLHelper::drawTextFrame(
652 const std::shared_ptr<impeller::TextFrame>& text_frame,
656void DisplayListGLComplexityCalculator::GLHelper::drawShadow(
660 bool transparent_occluder,
671 float occluder_penalty = 1.0f;
672 if (transparent_occluder) {
673 occluder_penalty = 1.20f;
684 unsigned int line_verb_cost = 17000;
685 unsigned int quad_verb_cost = 20000;
686 unsigned int conic_verb_cost = 20000;
687 unsigned int cubic_verb_cost = 120000;
689 unsigned int complexity = CalculatePathComplexity(
690 path, line_verb_cost, quad_verb_cost, conic_verb_cost, cubic_verb_cost);
692 AccumulateComplexity(complexity * occluder_penalty);
static const int points[]
SkISize dimensions() const
virtual bool isTextureBacked() const =0
static DisplayListGLComplexityCalculator * GetInstance()
@ kLines
draw each separate pair of points as a line segment
@ kPoints
draw each point separately
static const SaveLayerOptions kWithAttributes
static float max(float r, float g, float b)
static float min(float r, float g, float b)
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