forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_list_complexity_gl.h
100 lines (83 loc) · 3.47 KB
/
display_list_complexity_gl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_GL_H_
#define FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_GL_H_
#include "flutter/display_list/display_list_complexity_helper.h"
namespace flutter {
class DisplayListGLComplexityCalculator
: public DisplayListComplexityCalculator {
public:
static DisplayListGLComplexityCalculator* GetInstance();
unsigned int Compute(DisplayList* display_list) override {
GLHelper helper(ceiling_);
display_list->Dispatch(helper);
return helper.ComplexityScore();
}
bool ShouldBeCached(unsigned int complexity_score) override {
// Set cache threshold at 1ms
return complexity_score > 200000u;
}
void SetComplexityCeiling(unsigned int ceiling) override {
ceiling_ = ceiling;
}
private:
class GLHelper : public ComplexityCalculatorHelper {
public:
GLHelper(unsigned int ceiling)
: ComplexityCalculatorHelper(ceiling),
save_layer_count_(0),
draw_text_blob_count_(0) {}
void saveLayer(const SkRect* bounds,
const SaveLayerOptions options) override;
void drawLine(const SkPoint& p0, const SkPoint& p1) override;
void drawRect(const SkRect& rect) override;
void drawOval(const SkRect& bounds) override;
void drawCircle(const SkPoint& center, SkScalar radius) override;
void drawRRect(const SkRRect& rrect) override;
void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
void drawPath(const SkPath& path) override;
void drawArc(const SkRect& oval_bounds,
SkScalar start_degrees,
SkScalar sweep_degrees,
bool use_center) override;
void drawPoints(SkCanvas::PointMode mode,
uint32_t count,
const SkPoint points[]) override;
void drawVertices(const sk_sp<SkVertices> vertices,
DlBlendMode mode) override;
void drawImage(const sk_sp<SkImage> image,
const SkPoint point,
const SkSamplingOptions& sampling,
bool render_with_attributes) override;
void drawImageNine(const sk_sp<SkImage> image,
const SkIRect& center,
const SkRect& dst,
SkFilterMode filter,
bool render_with_attributes) override;
void drawDisplayList(const sk_sp<DisplayList> display_list) override;
void drawTextBlob(const sk_sp<SkTextBlob> blob,
SkScalar x,
SkScalar y) override;
void drawShadow(const SkPath& path,
const SkColor color,
const SkScalar elevation,
bool transparent_occluder,
SkScalar dpr) override;
protected:
void ImageRect(const SkISize& size,
bool texture_backed,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint) override;
unsigned int BatchedComplexity() override;
private:
unsigned int save_layer_count_;
unsigned int draw_text_blob_count_;
};
DisplayListGLComplexityCalculator()
: ceiling_(std::numeric_limits<unsigned int>::max()) {}
static DisplayListGLComplexityCalculator* instance_;
unsigned int ceiling_;
};
} // namespace flutter
#endif // FLUTTER_FLOW_DISPLAY_LIST_COMPLEXITY_GL_H_