blob: 8564bb656c0365627fdfebf4f73c2dc87dd3e36c [file] [log] [blame]
Adlai Holler08f53112021-01-20 17:44:15 -05001/*
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
Adlai Holler9a777952021-01-27 14:11:23 -050020 void addTarget(sk_sp<GrSurfaceProxy> proxy) { fTargets.push_back(std::move(proxy)); }
Adlai Holler08f53112021-01-20 17:44:15 -050021 void addDependency(GrRenderTask* dep) { fDependencies.push_back(dep); }
Adlai Holler9a777952021-01-27 14:11:23 -050022 void addUsed(sk_sp<GrSurfaceProxy> proxy) { fUsed.push_back(std::move(proxy)); }
Adlai Holler08f53112021-01-20 17:44:15 -050023
24 // Overrides.
25#ifdef SK_DEBUG
26 void visitProxies_debugOnly(const GrOp::VisitProxyFunc&) const override { return; }
27#endif
28 void handleInternalAllocationFailure() override {}
29 void gatherProxyIntervals(GrResourceAllocator*) const override {}
30 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override { SkUNREACHABLE; }
Adlai Holler9a777952021-01-27 14:11:23 -050031 bool onIsUsed(GrSurfaceProxy* proxy) const override {
32 for (const auto& entry : fUsed) {
33 if (entry.get() == proxy) {
34 return true;
35 }
36 }
37 return false;
38 }
Adlai Holler08f53112021-01-20 17:44:15 -050039 bool onExecute(GrOpFlushState*) override { return true; }
40
41#if GR_TEST_UTILS
42 const char* name() const final { return "Mock"; }
43#endif
Adlai Holler9a777952021-01-27 14:11:23 -050044
45private:
46 SkTArray<sk_sp<GrSurfaceProxy>> fUsed;
Adlai Holler08f53112021-01-20 17:44:15 -050047};
48
49#endif