|
12 | 12 | #include "third_party/skia/include/core/SkPoint.h" |
13 | 13 | #include "third_party/skia/include/core/SkSurface.h" |
14 | 14 | #include "third_party/skia/include/core/SkTextBlob.h" |
| 15 | +#include "third_party/skia/include/gpu/GrDirectContext.h" |
| 16 | +#include "third_party/skia/include/gpu/GrRecordingContext.h" |
15 | 17 |
|
16 | 18 | namespace flutter { |
17 | 19 | namespace testing { |
@@ -39,6 +41,16 @@ DlPaint GetPaintForRun(unsigned attributes) { |
39 | 41 | return paint; |
40 | 42 | } |
41 | 43 |
|
| 44 | +static void FlushSubmitCpuSync(const sk_sp<SkSurface>& surface) { |
| 45 | + if (!surface) { |
| 46 | + return; |
| 47 | + } |
| 48 | + if (GrDirectContext* dContext = |
| 49 | + GrAsDirectContext(surface->recordingContext())) { |
| 50 | + dContext->flushAndSubmit(surface, /*syncCpu=*/true); |
| 51 | + } |
| 52 | +} |
| 53 | + |
42 | 54 | void AnnotateAttributes(unsigned attributes, |
43 | 55 | benchmark::State& state, |
44 | 56 | const DisplayListAttributeFlags flags) { |
@@ -100,7 +112,7 @@ void BM_DrawLine(benchmark::State& state, |
100 | 112 | // We only want to time the actual rasterization. |
101 | 113 | for ([[maybe_unused]] auto _ : state) { |
102 | 114 | canvas.DrawDisplayList(display_list); |
103 | | - surface->flushAndSubmit(true); |
| 115 | + FlushSubmitCpuSync(surface); |
104 | 116 | } |
105 | 117 |
|
106 | 118 | auto filename = surface_provider->backend_name() + "-DrawLine-" + |
@@ -149,7 +161,7 @@ void BM_DrawRect(benchmark::State& state, |
149 | 161 | // We only want to time the actual rasterization. |
150 | 162 | for ([[maybe_unused]] auto _ : state) { |
151 | 163 | canvas.DrawDisplayList(display_list); |
152 | | - surface->flushAndSubmit(true); |
| 164 | + FlushSubmitCpuSync(surface); |
153 | 165 | } |
154 | 166 |
|
155 | 167 | auto filename = surface_provider->backend_name() + "-DrawRect-" + |
@@ -195,7 +207,7 @@ void BM_DrawOval(benchmark::State& state, |
195 | 207 | // We only want to time the actual rasterization. |
196 | 208 | for ([[maybe_unused]] auto _ : state) { |
197 | 209 | canvas.DrawDisplayList(display_list); |
198 | | - surface->flushAndSubmit(true); |
| 210 | + FlushSubmitCpuSync(surface); |
199 | 211 | } |
200 | 212 |
|
201 | 213 | auto filename = surface_provider->backend_name() + "-DrawOval-" + |
@@ -243,7 +255,7 @@ void BM_DrawCircle(benchmark::State& state, |
243 | 255 | // We only want to time the actual rasterization. |
244 | 256 | for ([[maybe_unused]] auto _ : state) { |
245 | 257 | canvas.DrawDisplayList(display_list); |
246 | | - surface->flushAndSubmit(true); |
| 258 | + FlushSubmitCpuSync(surface); |
247 | 259 | } |
248 | 260 |
|
249 | 261 | auto filename = surface_provider->backend_name() + "-DrawCircle-" + |
@@ -321,7 +333,7 @@ void BM_DrawRRect(benchmark::State& state, |
321 | 333 | // We only want to time the actual rasterization. |
322 | 334 | for ([[maybe_unused]] auto _ : state) { |
323 | 335 | canvas.DrawDisplayList(display_list); |
324 | | - surface->flushAndSubmit(true); |
| 336 | + FlushSubmitCpuSync(surface); |
325 | 337 | } |
326 | 338 |
|
327 | 339 | auto filename = surface_provider->backend_name() + "-DrawRRect-" + |
@@ -403,7 +415,7 @@ void BM_DrawDRRect(benchmark::State& state, |
403 | 415 | // We only want to time the actual rasterization. |
404 | 416 | for ([[maybe_unused]] auto _ : state) { |
405 | 417 | canvas.DrawDisplayList(display_list); |
406 | | - surface->flushAndSubmit(true); |
| 418 | + FlushSubmitCpuSync(surface); |
407 | 419 | } |
408 | 420 |
|
409 | 421 | auto filename = surface_provider->backend_name() + "-DrawDRRect-" + |
@@ -456,7 +468,7 @@ void BM_DrawArc(benchmark::State& state, |
456 | 468 | // We only want to time the actual rasterization. |
457 | 469 | for ([[maybe_unused]] auto _ : state) { |
458 | 470 | canvas.DrawDisplayList(display_list); |
459 | | - surface->flushAndSubmit(true); |
| 471 | + FlushSubmitCpuSync(surface); |
460 | 472 | } |
461 | 473 |
|
462 | 474 | auto filename = surface_provider->backend_name() + "-DrawArc-" + |
@@ -659,7 +671,7 @@ void BM_DrawPath(benchmark::State& state, |
659 | 671 | // We only want to time the actual rasterization. |
660 | 672 | for ([[maybe_unused]] auto _ : state) { |
661 | 673 | canvas.DrawDisplayList(display_list); |
662 | | - surface->flushAndSubmit(true); |
| 674 | + FlushSubmitCpuSync(surface); |
663 | 675 | } |
664 | 676 |
|
665 | 677 | auto filename = surface_provider->backend_name() + "-DrawPath-" + label + |
@@ -805,7 +817,7 @@ void BM_DrawVertices(benchmark::State& state, |
805 | 817 | // We only want to time the actual rasterization. |
806 | 818 | for ([[maybe_unused]] auto _ : state) { |
807 | 819 | canvas.DrawDisplayList(display_list); |
808 | | - surface->flushAndSubmit(true); |
| 820 | + FlushSubmitCpuSync(surface); |
809 | 821 | } |
810 | 822 |
|
811 | 823 | auto filename = surface_provider->backend_name() + "-DrawVertices-" + |
@@ -901,7 +913,7 @@ void BM_DrawPoints(benchmark::State& state, |
901 | 913 |
|
902 | 914 | for ([[maybe_unused]] auto _ : state) { |
903 | 915 | canvas.DrawDisplayList(display_list); |
904 | | - surface->flushAndSubmit(true); |
| 916 | + FlushSubmitCpuSync(surface); |
905 | 917 | } |
906 | 918 |
|
907 | 919 | auto filename = surface_provider->backend_name() + "-DrawPoints-" + |
@@ -979,7 +991,7 @@ void BM_DrawImage(benchmark::State& state, |
979 | 991 |
|
980 | 992 | for ([[maybe_unused]] auto _ : state) { |
981 | 993 | canvas.DrawDisplayList(display_list); |
982 | | - surface->flushAndSubmit(true); |
| 994 | + FlushSubmitCpuSync(surface); |
983 | 995 | } |
984 | 996 |
|
985 | 997 | auto filename = surface_provider->backend_name() + "-DrawImage-" + |
@@ -1065,7 +1077,7 @@ void BM_DrawImageRect(benchmark::State& state, |
1065 | 1077 |
|
1066 | 1078 | for ([[maybe_unused]] auto _ : state) { |
1067 | 1079 | canvas.DrawDisplayList(display_list); |
1068 | | - surface->flushAndSubmit(true); |
| 1080 | + FlushSubmitCpuSync(surface); |
1069 | 1081 | } |
1070 | 1082 |
|
1071 | 1083 | auto filename = surface_provider->backend_name() + "-DrawImageRect-" + |
@@ -1152,7 +1164,7 @@ void BM_DrawImageNine(benchmark::State& state, |
1152 | 1164 |
|
1153 | 1165 | for ([[maybe_unused]] auto _ : state) { |
1154 | 1166 | canvas.DrawDisplayList(display_list); |
1155 | | - surface->flushAndSubmit(true); |
| 1167 | + FlushSubmitCpuSync(surface); |
1156 | 1168 | } |
1157 | 1169 |
|
1158 | 1170 | auto filename = surface_provider->backend_name() + "-DrawImageNine-" + |
@@ -1198,7 +1210,7 @@ void BM_DrawTextBlob(benchmark::State& state, |
1198 | 1210 |
|
1199 | 1211 | for ([[maybe_unused]] auto _ : state) { |
1200 | 1212 | canvas.DrawDisplayList(display_list); |
1201 | | - surface->flushAndSubmit(true); |
| 1213 | + FlushSubmitCpuSync(surface); |
1202 | 1214 | } |
1203 | 1215 |
|
1204 | 1216 | auto filename = surface_provider->backend_name() + "-DrawTextBlob-" + |
@@ -1263,7 +1275,7 @@ void BM_DrawShadow(benchmark::State& state, |
1263 | 1275 | // We only want to time the actual rasterization. |
1264 | 1276 | for ([[maybe_unused]] auto _ : state) { |
1265 | 1277 | canvas.DrawDisplayList(display_list); |
1266 | | - surface->flushAndSubmit(true); |
| 1278 | + FlushSubmitCpuSync(surface); |
1267 | 1279 | } |
1268 | 1280 |
|
1269 | 1281 | auto filename = surface_provider->backend_name() + "-DrawShadow-" + |
@@ -1317,7 +1329,7 @@ void BM_SaveLayer(benchmark::State& state, |
1317 | 1329 | // We only want to time the actual rasterization. |
1318 | 1330 | for ([[maybe_unused]] auto _ : state) { |
1319 | 1331 | canvas.DrawDisplayList(display_list); |
1320 | | - surface->flushAndSubmit(true); |
| 1332 | + FlushSubmitCpuSync(surface); |
1321 | 1333 | } |
1322 | 1334 |
|
1323 | 1335 | auto filename = surface_provider->backend_name() + "-SaveLayer-" + |
|
0 commit comments