Flutter Engine
The Flutter Engine
Typedefs | Functions
GrRenderTaskClusterTest.cpp File Reference
#include "include/core/SkRefCnt.h"
#include "include/core/SkSpan.h"
#include "include/core/SkString.h"
#include "include/private/base/SkTArray.h"
#include "src/base/SkTInternalLList.h"
#include "src/gpu/ganesh/GrRenderTask.h"
#include "src/gpu/ganesh/GrRenderTaskCluster.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/mock/GrMockRenderTask.h"
#include "src/gpu/ganesh/mock/GrMockSurfaceProxy.h"
#include "tests/Test.h"
#include <array>
#include <cstddef>
#include <utility>

Go to the source code of this file.

Typedefs

typedef void(* CreateGraphPF) (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
 

Functions

static void make_proxies (int count, TArray< sk_sp< GrSurfaceProxy > > *proxies)
 
static void make_tasks (int count, TArray< sk_sp< GrMockRenderTask > > *tasks)
 
static void create_graph0 (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
 
static void create_graph1 (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
 
static void create_graph2 (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
 
static void create_graph3 (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
 
 DEF_TEST (GrRenderTaskCluster, reporter)
 

Typedef Documentation

◆ CreateGraphPF

typedef void(* CreateGraphPF) (TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)

Definition at line 26 of file GrRenderTaskClusterTest.cpp.

Function Documentation

◆ create_graph0()

static void create_graph0 ( TArray< sk_sp< GrMockRenderTask > > *  graph,
TArray< sk_sp< GrMockRenderTask > > *  expected 
)
static

Definition at line 49 of file GrRenderTaskClusterTest.cpp.

50 {
52 make_proxies(2, &proxies);
53 make_tasks(3, graph);
54
55 graph->at(0)->addTarget(proxies[0]);
56 graph->at(1)->addTarget(proxies[1]);
57 graph->at(2)->addTarget(proxies[0]);
58 graph->at(2)->addDependency(graph->at(1).get());
59
60 expected->push_back(graph->at(1));
61 expected->push_back(graph->at(0));
62 expected->push_back(graph->at(2));
63}
static void make_proxies(int count, TArray< sk_sp< GrSurfaceProxy > > *proxies)
static void make_tasks(int count, TArray< sk_sp< GrMockRenderTask > > *tasks)

◆ create_graph1()

static void create_graph1 ( TArray< sk_sp< GrMockRenderTask > > *  graph,
TArray< sk_sp< GrMockRenderTask > > *  expected 
)
static

Definition at line 69 of file GrRenderTaskClusterTest.cpp.

70 {
72 make_proxies(3, &proxies);
73 make_tasks(5, graph);
74
75 graph->at(0)->addTarget(proxies[0]);
76 graph->at(1)->addTarget(proxies[1]);
77 graph->at(2)->addTarget(proxies[0]);
78 graph->at(3)->addTarget(proxies[2]);
79 graph->at(4)->addTarget(proxies[0]);
80
81 expected->push_back(graph->at(1));
82 expected->push_back(graph->at(3));
83 expected->push_back(graph->at(0));
84 expected->push_back(graph->at(2));
85 expected->push_back(graph->at(4));
86}

◆ create_graph2()

static void create_graph2 ( TArray< sk_sp< GrMockRenderTask > > *  graph,
TArray< sk_sp< GrMockRenderTask > > *  expected 
)
static

Definition at line 93 of file GrRenderTaskClusterTest.cpp.

94 {
96 make_proxies(2, &proxies);
97 make_tasks(3, graph);
98
99 graph->at(0)->addTarget(proxies[0]);
100 graph->at(1)->addTarget(proxies[1]);
101 graph->at(2)->addTarget(proxies[0]);
102
103 graph->at(1)->addDependency(graph->at(0).get());
104 graph->at(2)->addDependency(graph->at(1).get());
105
106 // expected is empty. Can't reorder.
107}

◆ create_graph3()

static void create_graph3 ( TArray< sk_sp< GrMockRenderTask > > *  graph,
TArray< sk_sp< GrMockRenderTask > > *  expected 
)
static

Definition at line 116 of file GrRenderTaskClusterTest.cpp.

117 {
119 make_proxies(2, &proxies);
120 make_tasks(4, graph);
121
122 graph->at(0)->addTarget(proxies[0]);
123 graph->at(1)->addTarget(proxies[1]);
124 graph->at(2)->addTarget(proxies[0]);
125 graph->at(3)->addTarget(proxies[1]);
126
127 graph->at(1)->addDependency(graph->at(0).get());
128 graph->at(3)->addDependency(graph->at(2).get());
129
130 graph->at(1)->addUsed(proxies[0]);
131 graph->at(3)->addUsed(proxies[0]);
132
133 // expected is empty. Can't reorder.
134}

◆ DEF_TEST()

DEF_TEST ( GrRenderTaskCluster  ,
reporter   
)

Definition at line 136 of file GrRenderTaskClusterTest.cpp.

136 {
137 CreateGraphPF tests[] = {
142 };
143
144 for (size_t i = 0; i < std::size(tests); ++i) {
146 TArray<sk_sp<GrMockRenderTask>> expectedOutput;
147
148 (tests[i])(&graph, &expectedOutput);
149
151 // TODO: Why does Span not want to convert from sk_sp<GrMockRenderTask> to
152 // `const sk_sp<GrRenderTask>`?
154 reinterpret_cast<sk_sp<GrRenderTask>*>(graph.data()), graph.size());
155 bool actualResult = GrClusterRenderTasks(graphSpan, &llist);
156
157 if (expectedOutput.empty()) {
158 REPORTER_ASSERT(reporter, !actualResult);
159 size_t newCount = 0;
160 for (const GrRenderTask* t : llist) {
161 REPORTER_ASSERT(reporter, newCount < graphSpan.size() &&
162 t == graph[newCount].get());
163 ++newCount;
164 }
165 REPORTER_ASSERT(reporter, newCount == graphSpan.size());
166 } else {
167 REPORTER_ASSERT(reporter, actualResult);
168 // SkTInternalLList::countEntries is debug-only and these tests run in release.
169 int newCount = 0;
170 for ([[maybe_unused]] GrRenderTask* t : llist) {
171 newCount++;
172 }
173 REPORTER_ASSERT(reporter, newCount == expectedOutput.size());
174
175 int j = 0;
176 for (GrRenderTask* n : llist) {
177 REPORTER_ASSERT(reporter, n == expectedOutput[j++].get());
178 }
179 }
180
181 //SkDEBUGCODE(print(graph);)
182 }
183}
static BlurTest tests[]
Definition: BlurTest.cpp:84
reporter
Definition: FontMgrTest.cpp:39
static void create_graph3(TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
void(* CreateGraphPF)(TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
static void create_graph0(TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
static void create_graph2(TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
static void create_graph1(TArray< sk_sp< GrMockRenderTask > > *graph, TArray< sk_sp< GrMockRenderTask > > *expected)
bool GrClusterRenderTasks(SkSpan< const sk_sp< GrRenderTask > > input, SkTInternalLList< GrRenderTask > *llist)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
bool empty() const
Definition: SkTArray.h:199
int size() const
Definition: SkTArray.h:421
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
const myers::Point & get(const myers::Segment &)

◆ make_proxies()

static void make_proxies ( int  count,
TArray< sk_sp< GrSurfaceProxy > > *  proxies 
)
static

Definition at line 29 of file GrRenderTaskClusterTest.cpp.

29 {
30 proxies->reset(count);
31 for (int i = 0; i < count; i++) {
32 auto name = SkStringPrintf("%c", 'A' + i);
33 proxies->at(i) = sk_make_sp<GrMockSurfaceProxy>(std::move(name),
34 /*label=*/"RenderTaskClusterTest");
35 }
36}
int count
Definition: FontMgrTest.cpp:50
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
void reset(int n)
Definition: SkTArray.h:144
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ make_tasks()

static void make_tasks ( int  count,
TArray< sk_sp< GrMockRenderTask > > *  tasks 
)
static

Definition at line 38 of file GrRenderTaskClusterTest.cpp.

38 {
39 tasks->reset(count);
40 for (int i = 0; i < count; i++) {
41 tasks->at(i) = sk_make_sp<GrMockRenderTask>();
42 }
43}