5#include "flutter/benchmarking/benchmarking.h"
6#include "flutter/display_list/testing/dl_test_snippets.h"
16static std::vector<testing::DisplayListInvocationGroup> allRenderingOps =
19enum class DisplayListBuilderBenchmarkType {
26static void InvokeAllRenderingOps(DisplayListBuilder&
builder) {
28 for (
auto&
group : allRenderingOps) {
29 for (
size_t i = 0;
i <
group.variants.size();
i++) {
30 auto& invocation =
group.variants[
i];
31 invocation.Invoke(receiver);
36static void Complete(DisplayListBuilder&
builder,
37 DisplayListBuilderBenchmarkType
type) {
38 auto display_list =
builder.Build();
40 case DisplayListBuilderBenchmarkType::kBounds:
41 display_list->bounds();
43 case DisplayListBuilderBenchmarkType::kRtree:
44 display_list->rtree();
46 case DisplayListBuilderBenchmarkType::kBoundsAndRtree:
47 display_list->bounds();
48 display_list->rtree();
55bool NeedPrepareRTree(DisplayListBuilderBenchmarkType
type) {
56 return type == DisplayListBuilderBenchmarkType::kRtree ||
57 type == DisplayListBuilderBenchmarkType::kBoundsAndRtree;
63 DisplayListBuilderBenchmarkType
type) {
64 bool prepare_rtree = NeedPrepareRTree(
type);
65 while (
state.KeepRunning()) {
74 DisplayListBuilderBenchmarkType
type) {
75 bool prepare_rtree = NeedPrepareRTree(
type);
76 while (
state.KeepRunning()) {
87 DisplayListBuilderBenchmarkType
type) {
88 bool prepare_rtree = NeedPrepareRTree(
type);
89 while (
state.KeepRunning()) {
91 builder.TransformFullPerspective(0, 1, 0, 12, 1, 0, 0, 33, 3, 2, 5, 29, 0,
100 DisplayListBuilderBenchmarkType
type) {
102 bool prepare_rtree = NeedPrepareRTree(
type);
103 while (
state.KeepRunning()) {
106 InvokeAllRenderingOps(
builder);
113 DisplayListBuilderBenchmarkType
type) {
114 bool prepare_rtree = NeedPrepareRTree(
type);
115 while (
state.KeepRunning()) {
119 builder.SaveLayer(
nullptr,
nullptr);
122 for (
auto&
group : allRenderingOps) {
123 for (
size_t i = 0;
i <
group.variants.size();
i++) {
124 auto& invocation =
group.variants[
i];
125 invocation.Invoke(receiver);
135 DisplayListBuilderBenchmarkType
type) {
136 bool prepare_rtree = NeedPrepareRTree(
type);
137 while (
state.KeepRunning()) {
140 for (
auto&
group : allRenderingOps) {
141 for (
size_t i = 0;
i <
group.variants.size();
i++) {
142 auto& invocation =
group.variants[
i];
143 builder.SaveLayer(
nullptr,
nullptr);
144 invocation.Invoke(receiver);
154 DisplayListBuilderBenchmarkType
type) {
158 bool prepare_rtree = NeedPrepareRTree(
type);
159 while (
state.KeepRunning()) {
162 for (
auto&
group : allRenderingOps) {
163 for (
size_t i = 0;
i <
group.variants.size();
i++) {
164 auto& invocation =
group.variants[
i];
165 builder.SaveLayer(&layer_bounds, &layer_paint);
166 invocation.Invoke(receiver);
177 ->Unit(benchmark::kMicrosecond);
180 DisplayListBuilderBenchmarkType::kBounds)
181 ->Unit(benchmark::kMicrosecond);
184 DisplayListBuilderBenchmarkType::kRtree)
185 ->Unit(benchmark::kMicrosecond);
188 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
189 ->Unit(benchmark::kMicrosecond);
194 ->Unit(benchmark::kMicrosecond);
197 DisplayListBuilderBenchmarkType::kBounds)
198 ->Unit(benchmark::kMicrosecond);
201 DisplayListBuilderBenchmarkType::kRtree)
202 ->Unit(benchmark::kMicrosecond);
205 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
206 ->Unit(benchmark::kMicrosecond);
211 ->Unit(benchmark::kMicrosecond);
214 DisplayListBuilderBenchmarkType::kBounds)
215 ->Unit(benchmark::kMicrosecond);
218 DisplayListBuilderBenchmarkType::kRtree)
219 ->Unit(benchmark::kMicrosecond);
222 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
223 ->Unit(benchmark::kMicrosecond);
228 ->Unit(benchmark::kMicrosecond);
231 DisplayListBuilderBenchmarkType::kBounds)
232 ->Unit(benchmark::kMicrosecond);
235 DisplayListBuilderBenchmarkType::kRtree)
236 ->Unit(benchmark::kMicrosecond);
239 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
240 ->Unit(benchmark::kMicrosecond);
245 ->Unit(benchmark::kMicrosecond);
248 DisplayListBuilderBenchmarkType::kBounds)
249 ->Unit(benchmark::kMicrosecond);
252 DisplayListBuilderBenchmarkType::kRtree)
253 ->Unit(benchmark::kMicrosecond);
256 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
257 ->Unit(benchmark::kMicrosecond);
262 ->Unit(benchmark::kMicrosecond);
265 DisplayListBuilderBenchmarkType::kBounds)
266 ->Unit(benchmark::kMicrosecond);
269 DisplayListBuilderBenchmarkType::kRtree)
270 ->Unit(benchmark::kMicrosecond);
273 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
274 ->Unit(benchmark::kMicrosecond);
279 ->Unit(benchmark::kMicrosecond);
282 DisplayListBuilderBenchmarkType::kBounds)
283 ->Unit(benchmark::kMicrosecond);
286 DisplayListBuilderBenchmarkType::kRtree)
287 ->Unit(benchmark::kMicrosecond);
290 DisplayListBuilderBenchmarkType::kBoundsAndRtree)
291 ->Unit(benchmark::kMicrosecond);
Internal API for rendering recorded display lists to backends.
DlPaint & setImageFilter(const std::shared_ptr< const DlImageFilter > &filter)
std::vector< DisplayListInvocationGroup > CreateAllRenderingOps()
static const DlBlurImageFilter kTestBlurImageFilter1(5.0, 5.0, DlTileMode::kClamp)
static void BM_DisplayListBuilderWithScaleAndTranslate(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static void BM_DisplayListBuilderWithSaveLayer(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static void BM_DisplayListBuilderDefault(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static void BM_DisplayListBuilderWithClipRect(benchmark::State &state, DisplayListBuilderBenchmarkType type)
BENCHMARK_CAPTURE(BM_DisplayListBuilderDefault, kDefault, DisplayListBuilderBenchmarkType::kDefault) -> Unit(benchmark::kMicrosecond)
DlOpReceiver & DisplayListBuilderBenchmarkAccessor(DisplayListBuilder &builder)
static void BM_DisplayListBuilderWithSaveLayerAndImageFilter(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static void BM_DisplayListBuilderWithGlobalSaveLayer(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static void BM_DisplayListBuilderWithPerspective(benchmark::State &state, DisplayListBuilderBenchmarkType type)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)