blob: a3c4f78e7c357b920ae861a029560cf57043ab7d [file] [log] [blame]
* Copyright 2020 Google LLC
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef FlushFinishTracker_DEFINED
#define FlushFinishTracker_DEFINED
#include "include/core/SkRefCnt.h"
#include "include/gpu/GpuTypes.h"
#include <functional>
class GrDirectContext;
#if defined(SK_GRAPHITE)
namespace skgpu::graphite { class Context; }
namespace sk_gpu_test {
class FlushFinishTracker : public SkRefCnt {
static void FlushFinished(void* finishedContext) {
auto tracker = static_cast<FlushFinishTracker*>(finishedContext);
static void FlushFinishedResult(void* finishedContext, skgpu::CallbackResult) {
FlushFinishTracker(GrDirectContext* context) : fContext(context) {}
#if defined(SK_GRAPHITE)
FlushFinishTracker(skgpu::graphite::Context* context) : fGraphiteContext(context) {}
void setFinished() { fIsFinished = true; }
void waitTillFinished(std::function<void()> tick = {});
GrDirectContext* fContext = nullptr;
#if defined(SK_GRAPHITE)
skgpu::graphite::Context* fGraphiteContext = nullptr;
// Currently we don't have the this bool be atomic cause all current uses of this class happen
// on a single thread. In other words we call flush, checkAsyncWorkCompletion, and
// waitTillFinished all on the same thread. If we ever want to support the flushing and waiting
// to happen on different threads then we should make this atomic.
bool fIsFinished = false;
} //namespace sk_gpu_test