Flutter Engine
The Flutter Engine
dl_complexity_metal.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_METAL_H_
6#define FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_COMPLEXITY_METAL_H_
7
8#include "flutter/display_list/benchmarking/dl_complexity_helper.h"
9
10namespace flutter {
11
14 public:
16
17 unsigned int Compute(const DisplayList* display_list) override {
18 MetalHelper helper(ceiling_);
19 display_list->Dispatch(helper);
20 return helper.ComplexityScore();
21 }
22
23 bool ShouldBeCached(unsigned int complexity_score) override {
24 // Set cache threshold at 1ms
25 return complexity_score > 200000u;
26 }
27
28 void SetComplexityCeiling(unsigned int ceiling) override {
29 ceiling_ = ceiling;
30 }
31
32 private:
33 class MetalHelper : public ComplexityCalculatorHelper {
34 public:
35 explicit MetalHelper(unsigned int ceiling)
36 : ComplexityCalculatorHelper(ceiling) {}
37
38 void saveLayer(const SkRect& bounds,
40 const DlImageFilter* backdrop) override;
41
42 void drawLine(const SkPoint& p0, const SkPoint& p1) override;
43 void drawDashedLine(const DlPoint& p0,
44 const DlPoint& p1,
45 DlScalar on_length,
46 DlScalar off_length) override;
47 void drawRect(const SkRect& rect) override;
48 void drawOval(const SkRect& bounds) override;
49 void drawCircle(const SkPoint& center, SkScalar radius) override;
50 void drawRRect(const SkRRect& rrect) override;
51 void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
52 void drawPath(const SkPath& path) override;
53 void drawArc(const SkRect& oval_bounds,
54 SkScalar start_degrees,
55 SkScalar sweep_degrees,
56 bool use_center) override;
57 void drawPoints(DlCanvas::PointMode mode,
58 uint32_t count,
59 const SkPoint points[]) override;
60 void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
61 void drawImage(const sk_sp<DlImage> image,
62 const SkPoint point,
64 bool render_with_attributes) override;
65 void drawImageNine(const sk_sp<DlImage> image,
66 const SkIRect& center,
67 const SkRect& dst,
68 DlFilterMode filter,
69 bool render_with_attributes) override;
70 void drawDisplayList(const sk_sp<DisplayList> display_list,
71 SkScalar opacity) override;
72 void drawTextBlob(const sk_sp<SkTextBlob> blob,
73 SkScalar x,
74 SkScalar y) override;
75 void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
76 SkScalar x,
77 SkScalar y) override;
78 void drawShadow(const SkPath& path,
79 const DlColor color,
80 const SkScalar elevation,
81 bool transparent_occluder,
82 SkScalar dpr) override;
83
84 protected:
85 void ImageRect(const SkISize& size,
86 bool texture_backed,
87 bool render_with_attributes,
88 bool enforce_src_edges) override;
89
90 unsigned int BatchedComplexity() override;
91
92 private:
93 unsigned int save_layer_count_ = 0;
94 unsigned int draw_text_blob_count_ = 0;
95 };
96
97 DisplayListMetalComplexityCalculator()
98 : ceiling_(std::numeric_limits<unsigned int>::max()) {}
99 static DisplayListMetalComplexityCalculator* instance_;
100
101 unsigned int ceiling_;
102};
103
104} // namespace flutter
105
106#endif // FLUTTER_DISPLAY_LIST_BENCHMARKING_DL_COMPLEXITY_METAL_H_
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
Definition: SkPath.h:59
bool ShouldBeCached(unsigned int complexity_score) override
static DisplayListMetalComplexityCalculator * GetInstance()
unsigned int Compute(const DisplayList *display_list) override
void SetComplexityCeiling(unsigned int ceiling) override
void Dispatch(DlOpReceiver &ctx) const
DlColor color
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49
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)
Definition: linepaths.cpp:22
double y
double x
drawTextBlob(r.blob.get(), r.x, r.y, r.paint)) DRAW(DrawSlug
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SkSamplingOptions sampling
Definition: SkRecords.h:337
impeller::Scalar DlScalar
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
Definition: switches.h:57
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
Definition: switches.h:228
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
Definition: switches.h:259
impeller::Point DlPoint
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
flutter::DlColor DlColor
flutter::SaveLayerOptions SaveLayerOptions
Definition: SkRect.h:32
Definition: SkSize.h:16