blob: 2eb7a25cda5e4be1e9df72a4e53c869b6bc0da39 [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
Robert Phillips294723d2021-06-17 09:23:58 -040026 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override { return; }
Adlai Holler08f53112021-01-20 17:44:15 -050027#endif
Adlai Holler08f53112021-01-20 17:44:15 -050028 void gatherProxyIntervals(GrResourceAllocator*) const override {}
Chris Daltonaa938ce2021-06-23 18:13:59 -060029 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override { SkUNREACHABLE; }
Adlai Holler9a777952021-01-27 14:11:23 -050030 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 }
Adlai Holler08f53112021-01-20 17:44:15 -050038 bool onExecute(GrOpFlushState*) override { return true; }
39
40#if GR_TEST_UTILS
41 const char* name() const final { return "Mock"; }
42#endif
Adlai Holler9a777952021-01-27 14:11:23 -050043
44private:
45 SkTArray<sk_sp<GrSurfaceProxy>> fUsed;
Adlai Holler08f53112021-01-20 17:44:15 -050046};
47
48#endif