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 13 class GrMockRenderTask : public GrRenderTask { 14 public: GrMockRenderTask()15 GrMockRenderTask() : GrRenderTask() { 16 // Mock tasks are never "owned" by a drawmgr in the first place. 17 this->setFlag(kDisowned_Flag); 18 } 19 addTarget(sk_sp<GrSurfaceProxy> proxy)20 void addTarget(sk_sp<GrSurfaceProxy> proxy) { fTargets.push_back(std::move(proxy)); } addDependency(GrRenderTask * dep)21 void addDependency(GrRenderTask* dep) { fDependencies.push_back(dep); } addUsed(sk_sp<GrSurfaceProxy> proxy)22 void addUsed(sk_sp<GrSurfaceProxy> proxy) { fUsed.push_back(std::move(proxy)); } 23 24 // Overrides. 25 #ifdef SK_DEBUG visitProxies_debugOnly(const GrVisitProxyFunc &)26 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override { return; } 27 #endif gatherProxyIntervals(GrResourceAllocator *)28 void gatherProxyIntervals(GrResourceAllocator*) const override {} onMakeClosed(GrRecordingContext *,SkIRect *)29 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override { SkUNREACHABLE; } onIsUsed(GrSurfaceProxy * proxy)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 } onExecute(GrOpFlushState *)38 bool onExecute(GrOpFlushState*) override { return true; } 39 40 #if GR_TEST_UTILS name()41 const char* name() const final { return "Mock"; } 42 #endif 43 44 private: 45 SkTArray<sk_sp<GrSurfaceProxy>> fUsed; 46 }; 47 48 #endif 49