xref: /aosp_15_r20/external/skia/tests/graphite/BoundsManagerTest.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 
10 #include "src/gpu/graphite/geom/BoundsManager.h"
11 
12 namespace skgpu::graphite {
13 
DEF_TEST(BoundsManager,r)14 DEF_TEST(BoundsManager, r) {
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 
20     CompressedPaintersOrder order = CompressedPaintersOrder::First();
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
32     order = CompressedPaintersOrder::First();
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
51