xref: /aosp_15_r20/external/skia/bench/GpuTools.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GpuTools_DEFINED
9 #define GpuTools_DEFINED
10 
11 #include "include/core/SkSurface.h"
12 
13 #if defined(SK_GANESH)
14 #include "include/gpu/ganesh/SkSurfaceGanesh.h"
15 #endif
16 
17 #if defined(SK_GRAPHITE)
18 #include "src/gpu/graphite/Surface_Graphite.h"
19 #endif
20 
21 namespace skgpu {
22 // Flush any surface, even if we don't know what GPU backend it is for. This keeps the
23 // comparisons between Ganesh and Graphite more fair as the latter can do more batching
24 // unless we explicitly perform flushes.
Flush(SkSurface * surface)25 inline void Flush(SkSurface* surface) {
26 #if defined(SK_GANESH)
27     skgpu::ganesh::Flush(surface);
28 #endif
29 #if defined(SK_GRAPHITE)
30     skgpu::graphite::Flush(surface);
31 #endif
32 }
33 
FlushAndSubmit(SkSurface * surface)34 inline void FlushAndSubmit(SkSurface* surface) {
35 #if defined(SK_GANESH)
36     skgpu::ganesh::FlushAndSubmit(surface);
37 #endif
38 #if defined(SK_GRAPHITE)
39     // Graphite doesn't have a "flush and submit" equivalent
40     skgpu::graphite::Flush(surface);
41 #endif
42 }
43 }
44 
45 #endif
46