0a2464f51f
Bug: skia:10118 Change-Id: Ieb7c0eece56d3d9df56ecb52e00e76c01f038de8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289888 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
|
|
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "tools/gpu/TestContext.h"
|
|
|
|
#include "include/gpu/GrContext.h"
|
|
#include "src/core/SkTraceEvent.h"
|
|
#include "src/gpu/GrContextPriv.h"
|
|
#include "tools/gpu/FlushFinishTracker.h"
|
|
#include "tools/gpu/GpuTimer.h"
|
|
|
|
namespace sk_gpu_test {
|
|
TestContext::TestContext() : fGpuTimer(nullptr) {}
|
|
|
|
TestContext::~TestContext() {
|
|
// Subclass should call teardown.
|
|
SkASSERT(!fGpuTimer);
|
|
}
|
|
|
|
sk_sp<GrContext> TestContext::makeGrContext(const GrContextOptions&) {
|
|
return nullptr;
|
|
}
|
|
|
|
void TestContext::makeNotCurrent() const { this->onPlatformMakeNotCurrent(); }
|
|
void TestContext::makeCurrent() const { this->onPlatformMakeCurrent(); }
|
|
|
|
SkScopeExit TestContext::makeCurrentAndAutoRestore() const {
|
|
auto asr = SkScopeExit(this->onPlatformGetAutoContextRestore());
|
|
this->makeCurrent();
|
|
return asr;
|
|
}
|
|
|
|
void TestContext::flushAndWaitOnSync(GrContext* context) {
|
|
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
|
SkASSERT(context);
|
|
|
|
if (fFinishTrackers[fCurrentFlushIdx]) {
|
|
fFinishTrackers[fCurrentFlushIdx]->waitTillFinished();
|
|
}
|
|
|
|
fFinishTrackers[fCurrentFlushIdx].reset(new FlushFinishTracker(context));
|
|
|
|
// We add an additional ref to the current flush tracker here. This ref is owned by the finish
|
|
// callback on the flush call. The finish callback will unref the tracker when called.
|
|
fFinishTrackers[fCurrentFlushIdx]->ref();
|
|
|
|
GrFlushInfo flushInfo;
|
|
flushInfo.fFinishedProc = FlushFinishTracker::FlushFinished;
|
|
flushInfo.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
|
|
|
|
context->flush(flushInfo);
|
|
context->submit();
|
|
|
|
fCurrentFlushIdx = (fCurrentFlushIdx + 1) % SK_ARRAY_COUNT(fFinishTrackers);
|
|
}
|
|
|
|
void TestContext::testAbandon() {
|
|
}
|
|
|
|
void TestContext::teardown() {
|
|
fGpuTimer.reset();
|
|
}
|
|
|
|
}
|