Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
BoundsManagerTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
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#include "tests/Test.h"
9
11
12namespace skgpu::graphite {
13
15 // 64 grid cells, each 16x16
16 const int n = 8;
17 const int w = 16;
18 std::unique_ptr<BoundsManager> bm = GridBoundsManager::Make({n * w, n * w}, n);
19
21 for (int y = 0; y < n; ++y) {
22 for (int x = 0; x < n; ++x) {
23 order = order.next();
24
25 // Should only modify a single cell
26 Rect b = Rect::XYWH((x + 0.1f) * w, (y + 0.1f) * w, 0.8f * w, 0.8f * w);
27 bm->recordDraw(b, order);
28 }
29 }
30
31 // TODO: repeat these queries using bounds that intersect across levels as well
33 for (int y = 0; y < n; ++y) {
34 for (int x = 0; x < n; ++x) {
35 order = order.next();
36
37 // Should only read a single cell
38 Rect b = Rect::XYWH((x + 0.2f) * w, (y + 0.2f) * w, 0.6f * w, 0.6f * w);
39
40 CompressedPaintersOrder actual = bm->getMostRecentDraw(b);
41 REPORTER_ASSERT(r, actual == order);
42 }
43 }
44
45 // TODO: Then call recordDraw with new values that write to multiple cells
46
47 // TODO: Then test calls where the new value is not larger than the current max
48}
49
50} // namespace skgpu::graphite
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static std::unique_ptr< GridBoundsManager > Make(const SkISize &deviceSize, const SkISize &gridSize)
static AI Rect XYWH(float x, float y, float w, float h)
Definition Rect.h:40
static bool b
double y
double x
SkScalar w