Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GraphiteTestContext.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 skiatest_graphite_GraphiteTestContext_DEFINED
9#define skiatest_graphite_GraphiteTestContext_DEFINED
10
13
14namespace skgpu {
15enum class BackendApi : unsigned;
16enum class ContextType;
17}
18namespace skgpu::graphite {
19class Context;
20struct ContextOptions;
21class Recording;
22}
23
24namespace sk_gpu_test { class FlushFinishTracker; }
25
26namespace skiatest::graphite {
27
28struct TestOptions;
29
30/**
31 * An offscreen 3D context. This class is intended for Skia's internal testing needs and not
32 * for general use.
33 */
35public:
38
39 virtual ~GraphiteTestContext();
40
42
44
45 virtual std::unique_ptr<skgpu::graphite::Context> makeContext(const TestOptions&) = 0;
46
47 bool getMaxGpuFrameLag(int *maxFrameLag) const {
48 *maxFrameLag = kMaxFrameLag;
49 return true;
50 }
51
52 /**
53 * This will insert a Recording and submit work to the GPU. Additionally, we will add a finished
54 * callback to our insert recording call. We allow ourselves to have kMaxFrameLag number of
55 * unfinished flushes active on the GPU at a time. If we have 2 outstanding flushes then we will
56 * wait on the CPU until one has finished.
57 */
59
60 /**
61 * Allow the GPU API to make or detect forward progress on submitted work. For most APIs this is
62 * a no-op as the API can do this on another thread.
63 */
64 virtual void tick() {}
65
66 /**
67 * If the context supports CPU/GPU sync'ing this calls submit with skgpu::SyncToCpu::kYes.
68 * Otherwise it calls it with kNo in a busy loop.
69 */
71
72protected:
73 static constexpr int kMaxFrameLag = 3;
74
77
79};
80
81
82} // namespace skiatest::graphite
83
84#endif // skiatest_graphite_GraphiteTestContext_DEFINED
sk_sp< sk_gpu_test::FlushFinishTracker > fFinishTrackers[kMaxFrameLag - 1]
void submitRecordingAndWaitOnSync(skgpu::graphite::Context *, skgpu::graphite::Recording *)
GraphiteTestContext & operator=(const GraphiteTestContext &)=delete
virtual std::unique_ptr< skgpu::graphite::Context > makeContext(const TestOptions &)=0
GraphiteTestContext(const GraphiteTestContext &)=delete
void syncedSubmit(skgpu::graphite::Context *)
virtual skgpu::BackendApi backend()=0
virtual skgpu::ContextType contextType()=0
bool getMaxGpuFrameLag(int *maxFrameLag) const
BackendApi
Definition GpuTypes.h:22