Update mock render task & cluster test

Switch away from views, and add support for simulating
used-proxies. The latter will be used in an upcoming CL.

Bug: skia:10877
Change-Id: I7897516dc53c075a286cce8f31075d8cc93abccf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360604
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2021-01-27 14:11:23 -05:00 committed by Skia Commit-Bot
parent d8ce784b83
commit 9a77795a56
2 changed files with 19 additions and 8 deletions

View File

@ -17,8 +17,9 @@ public:
this->setFlag(kDisowned_Flag);
}
void addTarget(GrSurfaceProxyView view) { fTargets.push_back(view.detachProxy()); }
void addTarget(sk_sp<GrSurfaceProxy> proxy) { fTargets.push_back(std::move(proxy)); }
void addDependency(GrRenderTask* dep) { fDependencies.push_back(dep); }
void addUsed(sk_sp<GrSurfaceProxy> proxy) { fUsed.push_back(std::move(proxy)); }
// Overrides.
#ifdef SK_DEBUG
@ -27,12 +28,22 @@ public:
void handleInternalAllocationFailure() override {}
void gatherProxyIntervals(GrResourceAllocator*) const override {}
ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override { SkUNREACHABLE; }
bool onIsUsed(GrSurfaceProxy*) const override { return false; }
bool onIsUsed(GrSurfaceProxy* proxy) const override {
for (const auto& entry : fUsed) {
if (entry.get() == proxy) {
return true;
}
}
return false;
}
bool onExecute(GrOpFlushState*) override { return true; }
#if GR_TEST_UTILS
const char* name() const final { return "Mock"; }
#endif
private:
SkTArray<sk_sp<GrSurfaceProxy>> fUsed;
};
#endif

View File

@ -13,11 +13,11 @@
typedef void (*CreateGraphPF)(SkTArray<sk_sp<GrMockRenderTask>>* graph,
SkTArray<sk_sp<GrMockRenderTask>>* expected);
static void make_proxies(int count, SkTArray<GrSurfaceProxyView>* views) {
views->reset(count);
static void make_proxies(int count, SkTArray<sk_sp<GrSurfaceProxy>>* proxies) {
proxies->reset(count);
for (int i = 0; i < count; i++) {
auto name = SkStringPrintf("%c", 'A' + i);
views->at(i) = GrSurfaceProxyView(sk_make_sp<GrMockSurfaceProxy>(std::move(name)));
proxies->at(i) = sk_make_sp<GrMockSurfaceProxy>(std::move(name));
}
}
@ -34,7 +34,7 @@ static void make_tasks(int count, SkTArray<sk_sp<GrMockRenderTask>>* tasks) {
*/
static void create_graph0(SkTArray<sk_sp<GrMockRenderTask>>* graph,
SkTArray<sk_sp<GrMockRenderTask>>* expected) {
SkTArray<GrSurfaceProxyView> proxies;
SkTArray<sk_sp<GrSurfaceProxy>> proxies;
make_proxies(2, &proxies);
make_tasks(3, graph);
@ -54,7 +54,7 @@ static void create_graph0(SkTArray<sk_sp<GrMockRenderTask>>* graph,
*/
static void create_graph1(SkTArray<sk_sp<GrMockRenderTask>>* graph,
SkTArray<sk_sp<GrMockRenderTask>>* expected) {
SkTArray<GrSurfaceProxyView> proxies;
SkTArray<sk_sp<GrSurfaceProxy>> proxies;
make_proxies(3, &proxies);
make_tasks(5, graph);
@ -78,7 +78,7 @@ static void create_graph1(SkTArray<sk_sp<GrMockRenderTask>>* graph,
*/
static void create_graph2(SkTArray<sk_sp<GrMockRenderTask>>* graph,
SkTArray<sk_sp<GrMockRenderTask>>* expected) {
SkTArray<GrSurfaceProxyView> proxies;
SkTArray<sk_sp<GrSurfaceProxy>> proxies;
make_proxies(2, &proxies);
make_tasks(3, graph);