Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
WindowRectanglesTest.cpp File Reference
#include "include/core/SkRect.h"
#include "include/core/SkTypes.h"
#include "src/base/SkRandom.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/ganesh/GrWindowRectangles.h"
#include "tests/Test.h"
#include <cstring>

Go to the source code of this file.

Functions

static SkIRect next_irect (SkRandom &r)
 
 DEF_TEST (WindowRectangles, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( WindowRectangles  ,
reporter   
)

Definition at line 21 of file WindowRectanglesTest.cpp.

21 {
22 SkRandom r;
23
25 for (int i = 0; i < GrWindowRectangles::kMaxWindows; ++i) {
26 windowData[i] = next_irect(r);
27 }
28
30 for (int i = 0; i < GrWindowRectangles::kMaxWindows - 1; ++i) {
31 REPORTER_ASSERT(reporter, wr.count() == i);
32 REPORTER_ASSERT(reporter, !memcmp(wr.data(), windowData, i * sizeof(SkIRect)));
33
34 GrWindowRectangles wr2(wr);
35 REPORTER_ASSERT(reporter, wr2 == wr);
36 REPORTER_ASSERT(reporter, wr2.count() == wr.count());
37 REPORTER_ASSERT(reporter, !memcmp(wr2.data(), wr.data(), i * sizeof(SkIRect)));
38
39 wr.addWindow(windowData[i]);
40 }
41
43 {
44 GrWindowRectangles A(wr), B(wr);
46 REPORTER_ASSERT(reporter, B.data() == A.data()); // Should use copy-on-write.
47
48 A.addWindow(windowData[GrWindowRectangles::kMaxWindows - 1]);
49 REPORTER_ASSERT(reporter, B.data() != A.data());
51
52 B.addWindow(SkRectPriv::MakeILarge());
54
55 for (int i = 0; i < GrWindowRectangles::kMaxWindows - 1; i++) {
56 REPORTER_ASSERT(reporter, A.data()[i] == windowData[i]);
57 REPORTER_ASSERT(reporter, B.data()[i] == windowData[i]);
58 }
60 == windowData[GrWindowRectangles::kMaxWindows - 1]);
63 }
64 {
65 GrWindowRectangles A(wr), B(wr);
67 REPORTER_ASSERT(reporter, B.data() == A.data()); // Should use copy-on-write.
68
69 A.addWindow(windowData[GrWindowRectangles::kMaxWindows - 1]);
70 B.addWindow(windowData[GrWindowRectangles::kMaxWindows - 1]);
72 REPORTER_ASSERT(reporter, B.data() != A.data());
73
74 for (int i = 0; i < GrWindowRectangles::kMaxWindows; i++) {
75 REPORTER_ASSERT(reporter, B.data()[i] == A.data()[i]);
76 REPORTER_ASSERT(reporter, A.data()[i] == windowData[i]);
77 }
78 }
79}
reporter
#define SkASSERT(cond)
Definition SkAssert.h:116
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static SkIRect next_irect(SkRandom &r)
const SkIRect * data() const
SkIRect & addWindow(const SkIRect &window)
static constexpr int kMaxWindows
static SkIRect MakeILarge()
Definition SkRectPriv.h:22
#define B

◆ next_irect()

static SkIRect next_irect ( SkRandom r)
static

Definition at line 17 of file WindowRectanglesTest.cpp.

17 {
18 return {r.nextS(), r.nextS(), r.nextS(), r.nextS()};
19}
int32_t nextS()
Definition SkRandom.h:50