Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp

Issue 2563683003: Enable PaintChunkerTest on windows debug build (Closed)
Patch Set: final Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/paint/PaintChunker.h" 5 #include "platform/graphics/paint/PaintChunker.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using testing::ElementsAre; 11 using testing::ElementsAre;
12 12
13 namespace blink { 13 namespace blink {
14 namespace { 14 namespace {
15 15
16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug
17 // bots.
18 #if defined(NDEBUG) || !OS(WIN)
19
20 PaintChunkProperties rootPaintChunkProperties() { 16 PaintChunkProperties rootPaintChunkProperties() {
21 PaintChunkProperties rootProperties; 17 PaintChunkProperties rootProperties;
22 rootProperties.transform = TransformPaintPropertyNode::root(); 18 rootProperties.transform = TransformPaintPropertyNode::root();
23 rootProperties.clip = ClipPaintPropertyNode::root(); 19 rootProperties.clip = ClipPaintPropertyNode::root();
24 rootProperties.effect = EffectPaintPropertyNode::root(); 20 rootProperties.effect = EffectPaintPropertyNode::root();
25 rootProperties.scroll = ScrollPaintPropertyNode::root(); 21 rootProperties.scroll = ScrollPaintPropertyNode::root();
26 return rootProperties; 22 return rootProperties;
27 } 23 }
28 24
29 class PaintChunkerTest : public testing::Test { 25 class PaintChunkerTest : public testing::Test {
30 protected: 26 protected:
31 void SetUp() override { 27 void SetUp() override {
32 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 28 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
33 } 29 }
34 30
35 void TearDown() override { m_featuresBackup.restore(); } 31 void TearDown() override { m_featuresBackup.restore(); }
36 32
33 protected:
34 class TestDisplayItemClient : public DisplayItemClient {
35 String debugName() const final { return "Test"; }
36 LayoutRect visualRect() const final { return LayoutRect(); }
37 };
38 TestDisplayItemClient m_client;
39
37 private: 40 private:
38 RuntimeEnabledFeatures::Backup m_featuresBackup; 41 RuntimeEnabledFeatures::Backup m_featuresBackup;
39 }; 42 };
40 43
41 class TestDisplayItem : public DisplayItem, public DisplayItemClient { 44 class TestDisplayItem : public DisplayItem {
42 public: 45 public:
43 TestDisplayItem(DisplayItem::Type type) 46 TestDisplayItem(const DisplayItemClient& client, DisplayItem::Type type)
44 : DisplayItem(*this, type, sizeof(*this)) {} 47 : DisplayItem(client, type, sizeof(*this)) {}
45 48
46 void replay(GraphicsContext&) const final { NOTREACHED(); } 49 void replay(GraphicsContext&) const final { NOTREACHED(); }
47 void appendToWebDisplayItemList(const IntRect&, 50 void appendToWebDisplayItemList(const IntRect&,
48 WebDisplayItemList*) const final { 51 WebDisplayItemList*) const final {
49 NOTREACHED(); 52 NOTREACHED();
50 } 53 }
51 String debugName() const final { return "Test"; }
52 LayoutRect visualRect() const final { return LayoutRect(); }
53 }; 54 };
54 55
55 class NormalTestDisplayItem : public TestDisplayItem { 56 class NormalTestDisplayItem : public TestDisplayItem {
56 public: 57 public:
57 NormalTestDisplayItem() : TestDisplayItem(DisplayItem::kDrawingFirst) {} 58 NormalTestDisplayItem(const DisplayItemClient& client)
59 : TestDisplayItem(client, DisplayItem::kDrawingFirst) {}
58 }; 60 };
59 61
60 class TestDisplayItemRequiringSeparateChunk : public TestDisplayItem { 62 class TestDisplayItemRequiringSeparateChunk : public TestDisplayItem {
61 public: 63 public:
62 TestDisplayItemRequiringSeparateChunk() 64 TestDisplayItemRequiringSeparateChunk(const DisplayItemClient& client)
63 : TestDisplayItem(DisplayItem::kForeignLayerPlugin) {} 65 : TestDisplayItem(client, DisplayItem::kForeignLayerPlugin) {}
64 }; 66 };
65 67
66 TEST_F(PaintChunkerTest, Empty) { 68 TEST_F(PaintChunkerTest, Empty) {
67 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); 69 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
68 ASSERT_TRUE(chunks.isEmpty()); 70 ASSERT_TRUE(chunks.isEmpty());
69 } 71 }
70 72
71 TEST_F(PaintChunkerTest, SingleNonEmptyRange) { 73 TEST_F(PaintChunkerTest, SingleNonEmptyRange) {
72 PaintChunker chunker; 74 PaintChunker chunker;
73 chunker.updateCurrentPaintChunkProperties(nullptr, 75 chunker.updateCurrentPaintChunkProperties(nullptr,
74 rootPaintChunkProperties()); 76 rootPaintChunkProperties());
75 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 77 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
76 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 78 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
77 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 79 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
78 80
79 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, 81 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
80 rootPaintChunkProperties()))); 82 rootPaintChunkProperties())));
81 } 83 }
82 84
83 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) { 85 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) {
84 PaintChunker chunker; 86 PaintChunker chunker;
85 chunker.updateCurrentPaintChunkProperties(nullptr, 87 chunker.updateCurrentPaintChunkProperties(nullptr,
86 rootPaintChunkProperties()); 88 rootPaintChunkProperties());
87 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 89 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
88 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 90 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
89 chunker.updateCurrentPaintChunkProperties(nullptr, 91 chunker.updateCurrentPaintChunkProperties(nullptr,
90 rootPaintChunkProperties()); 92 rootPaintChunkProperties());
91 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 93 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
92 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 94 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
93 95
94 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr, 96 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr,
95 rootPaintChunkProperties()))); 97 rootPaintChunkProperties())));
96 } 98 }
97 99
98 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { 100 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
99 PaintChunker chunker; 101 PaintChunker chunker;
100 chunker.updateCurrentPaintChunkProperties(nullptr, 102 chunker.updateCurrentPaintChunkProperties(nullptr,
101 rootPaintChunkProperties()); 103 rootPaintChunkProperties());
102 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 104 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
103 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 105 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
104 chunker.decrementDisplayItemIndex(); 106 chunker.decrementDisplayItemIndex();
105 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 107 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
106 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 108 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
107 109
108 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, 110 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
109 rootPaintChunkProperties()))); 111 rootPaintChunkProperties())));
110 } 112 }
111 113
112 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { 114 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
113 PaintChunker chunker; 115 PaintChunker chunker;
114 chunker.updateCurrentPaintChunkProperties(nullptr, 116 chunker.updateCurrentPaintChunkProperties(nullptr,
115 rootPaintChunkProperties()); 117 rootPaintChunkProperties());
116 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 118 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
117 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 119 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
118 120
119 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 121 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
120 simpleTransform.transform = TransformPaintPropertyNode::create( 122 simpleTransform.transform = TransformPaintPropertyNode::create(
121 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 123 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
122 124
123 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 125 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
124 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 126 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
125 127
126 PaintChunkProperties anotherTransform = rootPaintChunkProperties(); 128 PaintChunkProperties anotherTransform = rootPaintChunkProperties();
127 anotherTransform.transform = TransformPaintPropertyNode::create( 129 anotherTransform.transform = TransformPaintPropertyNode::create(
128 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 130 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
129 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); 131 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
130 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 132 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
131 133
132 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 134 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
133 135
134 EXPECT_THAT(chunks, 136 EXPECT_THAT(chunks,
135 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 137 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
136 PaintChunk(2, 3, nullptr, simpleTransform), 138 PaintChunk(2, 3, nullptr, simpleTransform),
137 PaintChunk(3, 4, nullptr, anotherTransform))); 139 PaintChunk(3, 4, nullptr, anotherTransform)));
138 } 140 }
139 141
140 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { 142 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
141 PaintChunker chunker; 143 PaintChunker chunker;
142 chunker.updateCurrentPaintChunkProperties(nullptr, 144 chunker.updateCurrentPaintChunkProperties(nullptr,
143 rootPaintChunkProperties()); 145 rootPaintChunkProperties());
144 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
145 147
146 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 148 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
147 simpleTransform.transform = TransformPaintPropertyNode::create( 149 simpleTransform.transform = TransformPaintPropertyNode::create(
148 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); 150 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
149 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 151 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
150 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 152 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
151 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
152 154
153 PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties(); 155 PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties();
154 simpleTransformAndEffect.transform = simpleTransform.transform; 156 simpleTransformAndEffect.transform = simpleTransform.transform;
155 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create( 157 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(
156 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 158 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
157 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f); 159 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f);
158 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 160 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
159 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 161 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
160 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 162 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
161 163
162 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform = 164 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
163 rootPaintChunkProperties(); 165 rootPaintChunkProperties();
164 simpleTransformAndEffectWithUpdatedTransform.transform = 166 simpleTransformAndEffectWithUpdatedTransform.transform =
165 TransformPaintPropertyNode::create(nullptr, 167 TransformPaintPropertyNode::create(nullptr,
166 TransformationMatrix(1, 1, 0, 0, 0, 0), 168 TransformationMatrix(1, 1, 0, 0, 0, 0),
167 FloatPoint3D(9, 8, 7)); 169 FloatPoint3D(9, 8, 7));
168 simpleTransformAndEffectWithUpdatedTransform.effect = 170 simpleTransformAndEffectWithUpdatedTransform.effect =
169 EffectPaintPropertyNode::create( 171 EffectPaintPropertyNode::create(
170 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 172 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
171 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 173 ClipPaintPropertyNode::root(), CompositorFilterOperations(),
172 simpleTransformAndEffect.effect->opacity()); 174 simpleTransformAndEffect.effect->opacity());
173 chunker.updateCurrentPaintChunkProperties( 175 chunker.updateCurrentPaintChunkProperties(
174 nullptr, simpleTransformAndEffectWithUpdatedTransform); 176 nullptr, simpleTransformAndEffectWithUpdatedTransform);
175 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 177 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
176 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 178 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
177 179
178 // Test that going back to a previous chunk property still creates a new 180 // Test that going back to a previous chunk property still creates a new
179 // chunk. 181 // chunk.
180 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 182 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
181 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
182 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 184 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
183 185
184 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 186 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
185 187
186 EXPECT_THAT( 188 EXPECT_THAT(
187 chunks, 189 chunks,
188 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 190 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
189 PaintChunk(1, 3, nullptr, simpleTransform), 191 PaintChunk(1, 3, nullptr, simpleTransform),
190 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), 192 PaintChunk(3, 5, nullptr, simpleTransformAndEffect),
191 PaintChunk(5, 7, nullptr, 193 PaintChunk(5, 7, nullptr,
192 simpleTransformAndEffectWithUpdatedTransform), 194 simpleTransformAndEffectWithUpdatedTransform),
193 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); 195 PaintChunk(7, 9, nullptr, simpleTransformAndEffect)));
194 } 196 }
195 197
196 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { 198 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
197 // Test that "nested" transforms linearize using the following 199 // Test that "nested" transforms linearize using the following
198 // sequence of transforms and display items: 200 // sequence of transforms and display items:
199 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, 201 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
200 // </root xform> 202 // </root xform>
201 PaintChunker chunker; 203 PaintChunker chunker;
202 chunker.updateCurrentPaintChunkProperties(nullptr, 204 chunker.updateCurrentPaintChunkProperties(nullptr,
203 rootPaintChunkProperties()); 205 rootPaintChunkProperties());
204 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 206 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
205 207
206 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 208 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
207 simpleTransform.transform = TransformPaintPropertyNode::create( 209 simpleTransform.transform = TransformPaintPropertyNode::create(
208 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 210 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
209 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 211 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
210 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 212 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
211 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 213 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
212 214
213 chunker.updateCurrentPaintChunkProperties(nullptr, 215 chunker.updateCurrentPaintChunkProperties(nullptr,
214 rootPaintChunkProperties()); 216 rootPaintChunkProperties());
215 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 217 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
216 218
217 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 219 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
218 220
219 EXPECT_THAT( 221 EXPECT_THAT(
220 chunks, 222 chunks,
221 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 223 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
222 PaintChunk(1, 3, nullptr, simpleTransform), 224 PaintChunk(1, 3, nullptr, simpleTransform),
223 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); 225 PaintChunk(3, 4, nullptr, rootPaintChunkProperties())));
224 } 226 }
225 227
226 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { 228 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
227 // Test that properties can change without display items being generated. 229 // Test that properties can change without display items being generated.
228 PaintChunker chunker; 230 PaintChunker chunker;
229 chunker.updateCurrentPaintChunkProperties(nullptr, 231 chunker.updateCurrentPaintChunkProperties(nullptr,
230 rootPaintChunkProperties()); 232 rootPaintChunkProperties());
231 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 233 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
232 234
233 PaintChunkProperties firstTransform = rootPaintChunkProperties(); 235 PaintChunkProperties firstTransform = rootPaintChunkProperties();
234 firstTransform.transform = TransformPaintPropertyNode::create( 236 firstTransform.transform = TransformPaintPropertyNode::create(
235 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 237 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
236 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); 238 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
237 239
238 PaintChunkProperties secondTransform = rootPaintChunkProperties(); 240 PaintChunkProperties secondTransform = rootPaintChunkProperties();
239 secondTransform.transform = TransformPaintPropertyNode::create( 241 secondTransform.transform = TransformPaintPropertyNode::create(
240 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); 242 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
241 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); 243 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
242 244
243 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 245 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
244 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 246 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
245 247
246 EXPECT_THAT(chunks, 248 EXPECT_THAT(chunks,
247 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 249 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
248 PaintChunk(1, 2, nullptr, secondTransform))); 250 PaintChunk(1, 2, nullptr, secondTransform)));
249 } 251 }
250 252
251 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { 253 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
252 // Tests that the chunker creates a separate chunks for display items which 254 // Tests that the chunker creates a separate chunks for display items which
253 // require it. 255 // require it.
254 PaintChunker chunker; 256 PaintChunker chunker;
255 TestDisplayItemRequiringSeparateChunk i1, i2, i3, i4, i5, i6; 257 TestDisplayItemRequiringSeparateChunk i1(m_client);
258 TestDisplayItemRequiringSeparateChunk i2(m_client);
259 TestDisplayItemRequiringSeparateChunk i3(m_client);
260 TestDisplayItemRequiringSeparateChunk i4(m_client);
261 TestDisplayItemRequiringSeparateChunk i5(m_client);
262 TestDisplayItemRequiringSeparateChunk i6(m_client);
263
256 chunker.updateCurrentPaintChunkProperties(nullptr, 264 chunker.updateCurrentPaintChunkProperties(nullptr,
257 rootPaintChunkProperties()); 265 rootPaintChunkProperties());
258 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 266 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
259 chunker.incrementDisplayItemIndex(i1); 267 chunker.incrementDisplayItemIndex(i1);
260 chunker.incrementDisplayItemIndex(i2); 268 chunker.incrementDisplayItemIndex(i2);
261 chunker.incrementDisplayItemIndex(i3); 269 chunker.incrementDisplayItemIndex(i3);
262 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 270 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
263 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 271 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
264 chunker.incrementDisplayItemIndex(i4); 272 chunker.incrementDisplayItemIndex(i4);
265 chunker.incrementDisplayItemIndex(i5); 273 chunker.incrementDisplayItemIndex(i5);
266 chunker.decrementDisplayItemIndex(); 274 chunker.decrementDisplayItemIndex();
267 chunker.decrementDisplayItemIndex(); 275 chunker.decrementDisplayItemIndex();
268 chunker.decrementDisplayItemIndex(); 276 chunker.decrementDisplayItemIndex();
269 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 277 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
270 chunker.incrementDisplayItemIndex(i6); 278 chunker.incrementDisplayItemIndex(i6);
271 279
272 DisplayItem::Id id1 = i1.getId(); 280 DisplayItem::Id id1 = i1.getId();
273 DisplayItem::Id id2 = i2.getId(); 281 DisplayItem::Id id2 = i2.getId();
274 DisplayItem::Id id3 = i3.getId(); 282 DisplayItem::Id id3 = i3.getId();
275 DisplayItem::Id id6 = i6.getId(); 283 DisplayItem::Id id6 = i6.getId();
276 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 284 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
277 EXPECT_THAT(chunks, 285 EXPECT_THAT(chunks,
278 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 286 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
279 PaintChunk(1, 2, &id1, rootPaintChunkProperties()), 287 PaintChunk(1, 2, &id1, rootPaintChunkProperties()),
280 PaintChunk(2, 3, &id2, rootPaintChunkProperties()), 288 PaintChunk(2, 3, &id2, rootPaintChunkProperties()),
281 PaintChunk(3, 4, &id3, rootPaintChunkProperties()), 289 PaintChunk(3, 4, &id3, rootPaintChunkProperties()),
282 PaintChunk(4, 6, nullptr, rootPaintChunkProperties()), 290 PaintChunk(4, 6, nullptr, rootPaintChunkProperties()),
283 PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); 291 PaintChunk(6, 7, &id6, rootPaintChunkProperties())));
284 } 292 }
285 293
286 TEST_F(PaintChunkerTest, ChunkIds) { 294 TEST_F(PaintChunkerTest, ChunkIds) {
287 PaintChunker chunker; 295 PaintChunker chunker;
288 TestDisplayItem i1(DisplayItem::kDrawingFirst); 296 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst);
289 DisplayItem::Id id1 = i1.getId(); 297 DisplayItem::Id id1 = i1.getId();
290 TestDisplayItemRequiringSeparateChunk i2; 298 TestDisplayItemRequiringSeparateChunk i2(m_client);
291 DisplayItem::Id id2 = i2.getId(); 299 DisplayItem::Id id2 = i2.getId();
292 300
293 chunker.updateCurrentPaintChunkProperties(nullptr, 301 chunker.updateCurrentPaintChunkProperties(nullptr,
294 rootPaintChunkProperties()); 302 rootPaintChunkProperties());
295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 303 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
297 305
298 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 306 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
299 simpleTransform.transform = TransformPaintPropertyNode::create( 307 simpleTransform.transform = TransformPaintPropertyNode::create(
300 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 308 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
301 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 309 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
302 310
303 chunker.incrementDisplayItemIndex(i1); 311 chunker.incrementDisplayItemIndex(i1);
304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 312 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
305 chunker.incrementDisplayItemIndex(i2); 313 chunker.incrementDisplayItemIndex(i2);
306 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 314 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
307 315
308 chunker.updateCurrentPaintChunkProperties(nullptr, 316 chunker.updateCurrentPaintChunkProperties(nullptr,
309 rootPaintChunkProperties()); 317 rootPaintChunkProperties());
310 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 318 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
311 319
312 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 320 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
313 EXPECT_THAT( 321 EXPECT_THAT(
314 chunks, 322 chunks,
315 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 323 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
316 PaintChunk(2, 4, &id1, simpleTransform), 324 PaintChunk(2, 4, &id1, simpleTransform),
317 PaintChunk(4, 5, &id2, simpleTransform), 325 PaintChunk(4, 5, &id2, simpleTransform),
318 PaintChunk(5, 6, nullptr, simpleTransform), 326 PaintChunk(5, 6, nullptr, simpleTransform),
319 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); 327 PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
320 } 328 }
321 329
322 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { 330 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
323 PaintChunker chunker; 331 PaintChunker chunker;
324 TestDisplayItem i1(DisplayItem::kDrawingFirst); 332 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst);
325 i1.setSkippedCache(); 333 i1.setSkippedCache();
326 DisplayItem::Id id1 = i1.getId(); 334 DisplayItem::Id id1 = i1.getId();
327 TestDisplayItemRequiringSeparateChunk i2; 335 TestDisplayItemRequiringSeparateChunk i2(m_client);
328 i2.setSkippedCache(); 336 i2.setSkippedCache();
329 337
330 chunker.updateCurrentPaintChunkProperties(nullptr, 338 chunker.updateCurrentPaintChunkProperties(nullptr,
331 rootPaintChunkProperties()); 339 rootPaintChunkProperties());
332 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 340 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
333 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
334 342
335 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 343 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
336 simpleTransform.transform = TransformPaintPropertyNode::create( 344 simpleTransform.transform = TransformPaintPropertyNode::create(
337 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 345 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
338 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 346 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
339 347
340 chunker.incrementDisplayItemIndex(i1); 348 chunker.incrementDisplayItemIndex(i1);
341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 349 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
342 chunker.incrementDisplayItemIndex(i2); 350 chunker.incrementDisplayItemIndex(i2);
343 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 351 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
344 352
345 chunker.updateCurrentPaintChunkProperties(nullptr, 353 chunker.updateCurrentPaintChunkProperties(nullptr,
346 rootPaintChunkProperties()); 354 rootPaintChunkProperties());
347 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 355 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
348 356
349 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 357 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
350 EXPECT_THAT( 358 EXPECT_THAT(
351 chunks, 359 chunks,
352 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 360 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
353 PaintChunk(2, 4, nullptr, simpleTransform), 361 PaintChunk(2, 4, nullptr, simpleTransform),
354 PaintChunk(4, 5, nullptr, simpleTransform), 362 PaintChunk(4, 5, nullptr, simpleTransform),
355 PaintChunk(5, 6, nullptr, simpleTransform), 363 PaintChunk(5, 6, nullptr, simpleTransform),
356 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); 364 PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
357 } 365 }
358 366
359 #endif
360
361 } // namespace 367 } // namespace
362 } // namespace blink 368 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698