/src/skia/tools/gpu/FlushFinishTracker.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2020 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 | | #include "tools/gpu/FlushFinishTracker.h" |
9 | | |
10 | | #include "include/gpu/GrDirectContext.h" |
11 | | #include "src/core/SkTraceEvent.h" |
12 | | |
13 | | #if defined(SK_GRAPHITE) |
14 | | #include "include/gpu/graphite/Context.h" |
15 | | #endif |
16 | | |
17 | | #include <chrono> |
18 | | |
19 | | namespace sk_gpu_test { |
20 | | |
21 | 0 | void FlushFinishTracker::waitTillFinished(std::function<void()> tick) { |
22 | 0 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
23 | 0 | auto begin = std::chrono::steady_clock::now(); |
24 | 0 | auto end = begin; |
25 | 0 | while (!fIsFinished && (end - begin) < std::chrono::seconds(2)) { |
26 | 0 | if (tick) { |
27 | 0 | tick(); |
28 | 0 | } |
29 | 0 | if (fContext) { |
30 | 0 | fContext->checkAsyncWorkCompletion(); |
31 | 0 | } else { |
32 | 0 | #if defined(SK_GRAPHITE) |
33 | 0 | SkASSERT(fGraphiteContext); |
34 | 0 | fGraphiteContext->checkAsyncWorkCompletion(); |
35 | | #else |
36 | | SkDEBUGFAIL("No valid context"); |
37 | | #endif |
38 | 0 | } |
39 | 0 | end = std::chrono::steady_clock::now(); |
40 | 0 | } |
41 | 0 | if (!fIsFinished) { |
42 | 0 | SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n"); |
43 | 0 | } |
44 | 0 | } Unexecuted instantiation: sk_gpu_test::FlushFinishTracker::waitTillFinished(std::__1::function<void ()>) Unexecuted instantiation: sk_gpu_test::FlushFinishTracker::waitTillFinished(std::__1::function<void ()>) |
45 | | |
46 | | } //namespace sk_gpu_test |