1/* 2 * Copyright 2021 Google Inc. 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#ifndef GrMockRenderTask_DEFINED 9#define GrMockRenderTask_DEFINED 10 11#include "src/gpu/GrRenderTask.h" 12 13class GrMockRenderTask : public GrRenderTask { 14public: 15 GrMockRenderTask() : GrRenderTask() { 16 // Mock tasks are never "owned" by a drawmgr in the first place. 17 this->setFlag(kDisowned_Flag); 18 } 19 20 void addTarget(sk_sp<GrSurfaceProxy> proxy) { fTargets.push_back(std::move(proxy)); } 21 void addDependency(GrRenderTask* dep) { fDependencies.push_back(dep); } 22 void addUsed(sk_sp<GrSurfaceProxy> proxy) { fUsed.push_back(std::move(proxy)); } 23 24 // Overrides. 25#ifdef SK_DEBUG 26 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override { return; } 27#endif 28 void gatherProxyIntervals(GrResourceAllocator*) const override {} 29 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override { SkUNREACHABLE; } 30 bool onIsUsed(GrSurfaceProxy* proxy) const override { 31 for (const auto& entry : fUsed) { 32 if (entry.get() == proxy) { 33 return true; 34 } 35 } 36 return false; 37 } 38 bool onExecute(GrOpFlushState*) override { return true; } 39 40#if GR_TEST_UTILS 41 const char* name() const final { return "Mock"; } 42#endif 43 44private: 45 SkTArray<sk_sp<GrSurfaceProxy>> fUsed; 46}; 47 48#endif 49