/src/skia/tools/gpu/TestContext.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | /* |
3 | | * Copyright 2016 Google Inc. |
4 | | * |
5 | | * Use of this source code is governed by a BSD-style license that can be |
6 | | * found in the LICENSE file. |
7 | | */ |
8 | | |
9 | | #include "tools/gpu/TestContext.h" |
10 | | |
11 | | #include "include/gpu/GrDirectContext.h" |
12 | | #include "src/core/SkTraceEvent.h" |
13 | | #include "tools/gpu/FlushFinishTracker.h" |
14 | | #include "tools/gpu/GpuTimer.h" |
15 | | |
16 | | namespace sk_gpu_test { |
17 | 2.58k | TestContext::TestContext() : fGpuTimer(nullptr) {} |
18 | | |
19 | 2.58k | TestContext::~TestContext() { |
20 | | // Subclass should call teardown. |
21 | 2.58k | SkASSERT(!fGpuTimer); |
22 | 2.58k | } |
23 | | |
24 | 0 | sk_sp<GrDirectContext> TestContext::makeContext(const GrContextOptions&) { |
25 | 0 | return nullptr; |
26 | 0 | } |
27 | | |
28 | 0 | void TestContext::makeNotCurrent() const { this->onPlatformMakeNotCurrent(); } |
29 | 7.74k | void TestContext::makeCurrent() const { this->onPlatformMakeCurrent(); } |
30 | | |
31 | 5.16k | SkScopeExit TestContext::makeCurrentAndAutoRestore() const { |
32 | 5.16k | auto asr = SkScopeExit(this->onPlatformGetAutoContextRestore()); |
33 | 5.16k | this->makeCurrent(); |
34 | 5.16k | return asr; |
35 | 5.16k | } |
36 | | |
37 | 0 | void TestContext::flushAndWaitOnSync(GrDirectContext* context) { |
38 | 0 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
39 | 0 | SkASSERT(context); |
40 | |
|
41 | 0 | if (fFinishTrackers[fCurrentFlushIdx]) { |
42 | 0 | fFinishTrackers[fCurrentFlushIdx]->waitTillFinished(); |
43 | 0 | } |
44 | |
|
45 | 0 | fFinishTrackers[fCurrentFlushIdx].reset(new FlushFinishTracker(context)); |
46 | | |
47 | | // We add an additional ref to the current flush tracker here. This ref is owned by the finish |
48 | | // callback on the flush call. The finish callback will unref the tracker when called. |
49 | 0 | fFinishTrackers[fCurrentFlushIdx]->ref(); |
50 | |
|
51 | 0 | GrFlushInfo flushInfo; |
52 | 0 | flushInfo.fFinishedProc = FlushFinishTracker::FlushFinished; |
53 | 0 | flushInfo.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get(); |
54 | |
|
55 | 0 | context->flush(flushInfo); |
56 | 0 | context->submit(); |
57 | |
|
58 | 0 | fCurrentFlushIdx = (fCurrentFlushIdx + 1) % std::size(fFinishTrackers); |
59 | 0 | } Unexecuted instantiation: sk_gpu_test::TestContext::flushAndWaitOnSync(GrDirectContext*) Unexecuted instantiation: sk_gpu_test::TestContext::flushAndWaitOnSync(GrDirectContext*) |
60 | | |
61 | 0 | void TestContext::flushAndSyncCpu(GrDirectContext* context) { |
62 | 0 | SkASSERT(context); |
63 | 0 | context->flush(); |
64 | 0 | context->submit(GrSyncCpu::kYes); |
65 | 0 | } Unexecuted instantiation: sk_gpu_test::TestContext::flushAndSyncCpu(GrDirectContext*) Unexecuted instantiation: sk_gpu_test::TestContext::flushAndSyncCpu(GrDirectContext*) |
66 | | |
67 | 0 | void TestContext::testAbandon() { |
68 | 0 | } |
69 | | |
70 | 0 | void TestContext::teardown() { |
71 | 0 | fGpuTimer.reset(); |
72 | 0 | } |
73 | | |
74 | | } // namespace sk_gpu_test |