skia2/tools/gpu/FlushFinishTracker.h
Robert Phillips 00f78de600 Update additional tools to take a GrDirectContext
GM was updated in:
https://skia-review.googlesource.com/c/skia/+/300172 (Make GM::onGpuSetup take a GrDirectContext)

This CL updates: skpbench, nanobench, and some testing infrastructure.

Only minor changes were made to the unit tests as they will be updated
en masse in a follow up cl.

Change-Id: Ieffc98865d4c9fc73e292d3c807ed4ae2081745a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300220
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-07-01 20:42:25 +00:00

44 lines
1.1 KiB
C++

/*
* 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"
class GrDirectContext;
namespace sk_gpu_test {
class FlushFinishTracker : public SkRefCnt {
public:
static void FlushFinished(void* finishedContext) {
auto tracker = static_cast<FlushFinishTracker*>(finishedContext);
tracker->setFinished();
tracker->unref();
}
FlushFinishTracker(GrDirectContext* context) : fContext(context) {}
void setFinished() { fIsFinished = true; }
void waitTillFinished();
private:
GrDirectContext* fContext;
// 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
#endif