f4f8011aef
In order to stage the transition from GrContext to GrDirectContext, both of them will have to have the factories for a while. This CL also removes all internal uses of the old (GrContext) factories. Change-Id: Ibe1edd0818ea23a0d54257c55f35f12526047ef3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302263 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Adlai Holler <adlai@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
69 lines
1.9 KiB
C++
69 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/GrDirectContext.h"
|
|
#include "src/core/SkTraceEvent.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<GrDirectContext> TestContext::makeContext(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(GrDirectContext* 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();
|
|
}
|
|
|
|
}
|