skia2/tools/graphite/GraphiteTestContext.cpp
Jim Van Verth 42f710f3fa Reland "[graphite] Move Graphite into Skia base directories."
This is a reland of commit ae5e846047

Original change's description:
> [graphite] Move Graphite into Skia base directories.
>
> Change-Id: Ie0fb74f3766a8b33387c145bd1151344c25808cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528708
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

Change-Id: Ia575fd49206ad0b665a6a9153317e738bb321446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529059
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-04-11 18:37:20 +00:00

50 lines
1.7 KiB
C++

/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tools/graphite/GraphiteTestContext.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/GraphiteTypes.h"
#include "include/gpu/graphite/Recording.h"
#include "src/core/SkTraceEvent.h"
#include "tools/gpu/FlushFinishTracker.h"
namespace skiatest::graphite {
GraphiteTestContext::GraphiteTestContext() {}
GraphiteTestContext::~GraphiteTestContext() {}
void GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context* context,
skgpu::graphite::Recording* recording) {
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
SkASSERT(context);
SkASSERT(recording);
if (fFinishTrackers[fCurrentFlushIdx]) {
fFinishTrackers[fCurrentFlushIdx]->waitTillFinished();
}
fFinishTrackers[fCurrentFlushIdx].reset(new sk_gpu_test::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();
skgpu::graphite::InsertRecordingInfo info;
info.fRecording = recording;
info.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
info.fFinishedProc = sk_gpu_test::FlushFinishTracker::FlushFinishedResult;
context->insertRecording(info);
context->submit(skgpu::graphite::SyncToCpu::kNo);
fCurrentFlushIdx = (fCurrentFlushIdx + 1) % SK_ARRAY_COUNT(fFinishTrackers);
}
} // namespace skiatest::graphite