Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
tests
WindowRectanglesTest.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2016 Google Inc.
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 "
include/core/SkRect.h
"
9
#include "
include/core/SkTypes.h
"
10
#include "
src/base/SkRandom.h
"
11
#include "
src/core/SkRectPriv.h
"
12
#include "
src/gpu/ganesh/GrWindowRectangles.h
"
13
#include "
tests/Test.h
"
14
15
#include <cstring>
16
17
static
SkIRect
next_irect
(
SkRandom
& r) {
18
return
{r.
nextS
(), r.
nextS
(), r.
nextS
(), r.
nextS
()};
19
}
20
21
DEF_TEST
(WindowRectangles,
reporter
) {
22
SkRandom
r;
23
24
SkIRect
windowData[
GrWindowRectangles::kMaxWindows
];
25
for
(
int
i = 0; i <
GrWindowRectangles::kMaxWindows
; ++i) {
26
windowData[i] =
next_irect
(r);
27
}
28
29
GrWindowRectangles
wr;
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
42
SkASSERT
(wr.
count
() ==
GrWindowRectangles::kMaxWindows
- 1);
43
{
44
GrWindowRectangles
A
(wr),
B
(wr);
45
REPORTER_ASSERT
(
reporter
,
B
==
A
);
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());
50
REPORTER_ASSERT
(
reporter
,
B
!=
A
);
51
52
B
.addWindow(
SkRectPriv::MakeILarge
());
53
REPORTER_ASSERT
(
reporter
,
B
!=
A
);
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
}
59
REPORTER_ASSERT
(
reporter
,
A
.data()[
GrWindowRectangles::kMaxWindows
- 1]
60
== windowData[
GrWindowRectangles::kMaxWindows
- 1]);
61
REPORTER_ASSERT
(
reporter
,
B
.data()[
GrWindowRectangles::kMaxWindows
- 1]
62
==
SkRectPriv::MakeILarge
());
63
}
64
{
65
GrWindowRectangles
A
(wr),
B
(wr);
66
REPORTER_ASSERT
(
reporter
,
B
==
A
);
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]);
71
REPORTER_ASSERT
(
reporter
,
B
==
A
);
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
reporter
Definition
FontMgrTest.cpp:39
GrWindowRectangles.h
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkRandom.h
SkRectPriv.h
SkRect.h
SkTypes.h
Test.h
DEF_TEST
#define DEF_TEST(name, reporter)
Definition
Test.h:312
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition
Test.h:286
next_irect
static SkIRect next_irect(SkRandom &r)
Definition
WindowRectanglesTest.cpp:17
A
Definition
GrMemoryPoolTest.cpp:24
B
Definition
GrMemoryPoolTest.cpp:72
GrWindowRectangles
Definition
GrWindowRectangles.h:14
GrWindowRectangles::count
int count() const
Definition
GrWindowRectangles.h:25
GrWindowRectangles::data
const SkIRect * data() const
Definition
GrWindowRectangles.h:59
GrWindowRectangles::addWindow
SkIRect & addWindow(const SkIRect &window)
Definition
GrWindowRectangles.h:31
GrWindowRectangles::kMaxWindows
static constexpr int kMaxWindows
Definition
GrWindowRectangles.h:16
SkRandom
Definition
SkRandom.h:27
SkRandom::nextS
int32_t nextS()
Definition
SkRandom.h:50
SkRectPriv::MakeILarge
static SkIRect MakeILarge()
Definition
SkRectPriv.h:22
B
#define B
Definition
kernel_binary_flowgraph.cc:27
SkIRect
Definition
SkRect.h:32
Generated on Fri Apr 26 2024 06:18:06 for Flutter Engine by
1.9.8