Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TestContext.cpp
Go to the documentation of this file.
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
10
14#include "tools/gpu/GpuTimer.h"
15
16namespace sk_gpu_test {
17TestContext::TestContext() : fGpuTimer(nullptr) {}
18
20 // Subclass should call teardown.
22}
23
27
30
33 this->makeCurrent();
34 return asr;
35}
36
38 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
39 SkASSERT(context);
40
41 if (fFinishTrackers[fCurrentFlushIdx]) {
42 fFinishTrackers[fCurrentFlushIdx]->waitTillFinished();
43 }
44
45 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 fFinishTrackers[fCurrentFlushIdx]->ref();
50
51 GrFlushInfo flushInfo;
53 flushInfo.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
54
55 context->flush(flushInfo);
56 context->submit();
57
58 fCurrentFlushIdx = (fCurrentFlushIdx + 1) % std::size(fFinishTrackers);
59}
60
62 SkASSERT(context);
63 context->flush();
64 context->submit(GrSyncCpu::kYes);
65}
66
69
71 fGpuTimer.reset();
72}
73
74} // namespace sk_gpu_test
#define SkASSERT(cond)
Definition SkAssert.h:116
#define TRACE_FUNC
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
static void FlushFinished(void *finishedContext)
virtual sk_sp< GrDirectContext > makeContext(const GrContextOptions &)
std::unique_ptr< GpuTimer > fGpuTimer
Definition TestContext.h:89
void flushAndWaitOnSync(GrDirectContext *context)
virtual std::function< void()> onPlatformGetAutoContextRestore() const =0
virtual void onPlatformMakeNotCurrent() const =0
void flushAndSyncCpu(GrDirectContext *)
virtual void testAbandon()
virtual void onPlatformMakeCurrent() const =0
SkScopeExit makeCurrentAndAutoRestore() const
GrGpuFinishedContext fFinishedContext
Definition GrTypes.h:220
GrGpuFinishedProc fFinishedProc
Definition GrTypes.h:219
#define TRACE_EVENT0(category_group, name)