1 /* 2 * Copyright 2021 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "tools/graphite/GraphiteTestContext.h" 9 10 #include "include/gpu/graphite/Context.h" 11 #include "include/gpu/graphite/GraphiteTypes.h" 12 #include "include/gpu/graphite/Recording.h" 13 #include "src/core/SkTraceEvent.h" 14 #include "tools/gpu/FlushFinishTracker.h" 15 16 namespace skiatest::graphite { 17 GraphiteTestContext()18GraphiteTestContext::GraphiteTestContext() {} 19 ~GraphiteTestContext()20GraphiteTestContext::~GraphiteTestContext() {} 21 submitRecordingAndWaitOnSync(skgpu::graphite::Context * context,skgpu::graphite::Recording * recording)22void GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context* context, 23 skgpu::graphite::Recording* recording) { 24 TRACE_EVENT0("skia.gpu", TRACE_FUNC); 25 SkASSERT(context); 26 SkASSERT(recording); 27 28 if (fFinishTrackers[fCurrentFlushIdx]) { 29 fFinishTrackers[fCurrentFlushIdx]->waitTillFinished(); 30 } 31 32 fFinishTrackers[fCurrentFlushIdx].reset(new sk_gpu_test::FlushFinishTracker(context)); 33 34 // We add an additional ref to the current flush tracker here. This ref is owned by the finish 35 // callback on the flush call. The finish callback will unref the tracker when called. 36 fFinishTrackers[fCurrentFlushIdx]->ref(); 37 38 skgpu::graphite::InsertRecordingInfo info; 39 info.fRecording = recording; 40 info.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get(); 41 info.fFinishedProc = sk_gpu_test::FlushFinishTracker::FlushFinishedResult; 42 context->insertRecording(info); 43 44 context->submit(skgpu::graphite::SyncToCpu::kNo); 45 46 fCurrentFlushIdx = (fCurrentFlushIdx + 1) % std::size(fFinishTrackers); 47 } 48 49 } // namespace skiatest::graphite 50