2020-07-01 20:09:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tools/gpu/FlushFinishTracker.h"
|
|
|
|
|
|
|
|
#include "include/gpu/GrDirectContext.h"
|
|
|
|
#include "src/core/SkTraceEvent.h"
|
|
|
|
|
2022-03-28 19:27:44 +00:00
|
|
|
#ifdef SK_GRAPHITE_ENABLED
|
2022-04-08 23:25:39 +00:00
|
|
|
#include "experimental/graphite/include/Context.h"
|
2022-03-28 19:27:44 +00:00
|
|
|
#endif
|
|
|
|
|
2020-07-01 20:09:43 +00:00
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
namespace sk_gpu_test {
|
|
|
|
|
|
|
|
void FlushFinishTracker::waitTillFinished() {
|
|
|
|
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
|
|
|
auto begin = std::chrono::steady_clock::now();
|
|
|
|
auto end = begin;
|
|
|
|
while (!fIsFinished && (end - begin) < std::chrono::seconds(2)) {
|
2022-03-28 19:27:44 +00:00
|
|
|
if (fContext) {
|
|
|
|
fContext->checkAsyncWorkCompletion();
|
|
|
|
} else {
|
|
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
|
|
SkASSERT(fGraphiteContext);
|
|
|
|
fGraphiteContext->checkAsyncWorkCompletion();
|
|
|
|
#else
|
|
|
|
SkDEBUGFAIL("No valid context");
|
|
|
|
#endif
|
|
|
|
}
|
2020-07-01 20:09:43 +00:00
|
|
|
end = std::chrono::steady_clock::now();
|
|
|
|
}
|
|
|
|
if (!fIsFinished) {
|
|
|
|
SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace sk_gpu_test
|