1 /* 2 * Copyright 2020 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/gpu/FlushFinishTracker.h" 9 10 #include "include/gpu/GrDirectContext.h" 11 #include "src/core/SkTraceEvent.h" 12 13 #include <chrono> 14 15 namespace sk_gpu_test { 16 waitTillFinished()17void FlushFinishTracker::waitTillFinished() { 18 TRACE_EVENT0("skia.gpu", TRACE_FUNC); 19 auto begin = std::chrono::steady_clock::now(); 20 auto end = begin; 21 while (!fIsFinished && (end - begin) < std::chrono::seconds(2)) { 22 fContext->checkAsyncWorkCompletion(); 23 end = std::chrono::steady_clock::now(); 24 } 25 if (!fIsFinished) { 26 SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n"); 27 } 28 } 29 30 } //namespace sk_gpu_test 31