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

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

Issue 2565903002: [SPv2] Add createOpacityOnlyEffect test helper (Closed)
Patch Set: rebase && git cl format 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
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 "platform/testing/PaintPropertyTestHelpers.h"
8 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 using testing::ElementsAre; 12 using ::blink::testing::createOpacityOnlyEffect;
13 using ::blink::testing::defaultPaintChunkProperties;
14 using ::testing::ElementsAre;
12 15
13 namespace blink { 16 namespace blink {
14 namespace { 17 namespace {
15 18
16 PaintChunkProperties rootPaintChunkProperties() { 19 class PaintChunkerTest : public ::testing::Test {
17 PaintChunkProperties rootProperties;
18 rootProperties.transform = TransformPaintPropertyNode::root();
19 rootProperties.clip = ClipPaintPropertyNode::root();
20 rootProperties.effect = EffectPaintPropertyNode::root();
21 rootProperties.scroll = ScrollPaintPropertyNode::root();
22 return rootProperties;
23 }
24
25 class PaintChunkerTest : public testing::Test {
26 protected: 20 protected:
27 void SetUp() override { 21 void SetUp() override {
28 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 22 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
29 } 23 }
30 24
31 void TearDown() override { m_featuresBackup.restore(); } 25 void TearDown() override { m_featuresBackup.restore(); }
32 26
33 protected: 27 protected:
34 class TestDisplayItemClient : public DisplayItemClient { 28 class TestDisplayItemClient : public DisplayItemClient {
35 String debugName() const final { return "Test"; } 29 String debugName() const final { return "Test"; }
(...skipping 30 matching lines...) Expand all
66 }; 60 };
67 61
68 TEST_F(PaintChunkerTest, Empty) { 62 TEST_F(PaintChunkerTest, Empty) {
69 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); 63 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
70 ASSERT_TRUE(chunks.isEmpty()); 64 ASSERT_TRUE(chunks.isEmpty());
71 } 65 }
72 66
73 TEST_F(PaintChunkerTest, SingleNonEmptyRange) { 67 TEST_F(PaintChunkerTest, SingleNonEmptyRange) {
74 PaintChunker chunker; 68 PaintChunker chunker;
75 chunker.updateCurrentPaintChunkProperties(nullptr, 69 chunker.updateCurrentPaintChunkProperties(nullptr,
76 rootPaintChunkProperties()); 70 defaultPaintChunkProperties());
77 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 71 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
78 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 72 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
79 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 73 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
80 74
81 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, 75 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
82 rootPaintChunkProperties()))); 76 defaultPaintChunkProperties())));
83 } 77 }
84 78
85 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) { 79 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) {
86 PaintChunker chunker; 80 PaintChunker chunker;
87 chunker.updateCurrentPaintChunkProperties(nullptr, 81 chunker.updateCurrentPaintChunkProperties(nullptr,
88 rootPaintChunkProperties()); 82 defaultPaintChunkProperties());
89 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 83 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
90 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 84 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
91 chunker.updateCurrentPaintChunkProperties(nullptr, 85 chunker.updateCurrentPaintChunkProperties(nullptr,
92 rootPaintChunkProperties()); 86 defaultPaintChunkProperties());
93 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 87 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
94 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 88 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
95 89
96 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr, 90 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr,
97 rootPaintChunkProperties()))); 91 defaultPaintChunkProperties())));
98 } 92 }
99 93
100 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { 94 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) {
101 PaintChunker chunker; 95 PaintChunker chunker;
102 chunker.updateCurrentPaintChunkProperties(nullptr, 96 chunker.updateCurrentPaintChunkProperties(nullptr,
103 rootPaintChunkProperties()); 97 defaultPaintChunkProperties());
104 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 98 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
105 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 99 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
106 chunker.decrementDisplayItemIndex(); 100 chunker.decrementDisplayItemIndex();
107 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 101 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
108 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 102 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
109 103
110 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, 104 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
111 rootPaintChunkProperties()))); 105 defaultPaintChunkProperties())));
112 } 106 }
113 107
114 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { 108 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
115 PaintChunker chunker; 109 PaintChunker chunker;
116 chunker.updateCurrentPaintChunkProperties(nullptr, 110 chunker.updateCurrentPaintChunkProperties(nullptr,
117 rootPaintChunkProperties()); 111 defaultPaintChunkProperties());
118 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 112 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
119 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 113 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
120 114
121 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 115 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
122 simpleTransform.transform = TransformPaintPropertyNode::create( 116 simpleTransform.transform = TransformPaintPropertyNode::create(
123 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 117 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
124 118
125 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 119 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
126 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 120 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
127 121
128 PaintChunkProperties anotherTransform = rootPaintChunkProperties(); 122 PaintChunkProperties anotherTransform = defaultPaintChunkProperties();
129 anotherTransform.transform = TransformPaintPropertyNode::create( 123 anotherTransform.transform = TransformPaintPropertyNode::create(
130 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 124 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
131 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); 125 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
132 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 126 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
133 127
134 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 128 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
135 129
136 EXPECT_THAT(chunks, 130 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
137 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 131 defaultPaintChunkProperties()),
138 PaintChunk(2, 3, nullptr, simpleTransform), 132 PaintChunk(2, 3, nullptr, simpleTransform),
139 PaintChunk(3, 4, nullptr, anotherTransform))); 133 PaintChunk(3, 4, nullptr, anotherTransform)));
140 } 134 }
141 135
142 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { 136 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
143 PaintChunker chunker; 137 PaintChunker chunker;
144 chunker.updateCurrentPaintChunkProperties(nullptr, 138 chunker.updateCurrentPaintChunkProperties(nullptr,
145 rootPaintChunkProperties()); 139 defaultPaintChunkProperties());
146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 140 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
147 141
148 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 142 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
149 simpleTransform.transform = TransformPaintPropertyNode::create( 143 simpleTransform.transform = TransformPaintPropertyNode::create(
150 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); 144 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
151 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 145 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
152 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 147 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
154 148
155 PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties(); 149 PaintChunkProperties simpleTransformAndEffect = defaultPaintChunkProperties();
156 simpleTransformAndEffect.transform = simpleTransform.transform; 150 simpleTransformAndEffect.transform = simpleTransform.transform;
157 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create( 151 simpleTransformAndEffect.effect =
158 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 152 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f);
159 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f);
160 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 153 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
161 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
162 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
163 156
164 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform = 157 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
165 rootPaintChunkProperties(); 158 defaultPaintChunkProperties();
166 simpleTransformAndEffectWithUpdatedTransform.transform = 159 simpleTransformAndEffectWithUpdatedTransform.transform =
167 TransformPaintPropertyNode::create(nullptr, 160 TransformPaintPropertyNode::create(nullptr,
168 TransformationMatrix(1, 1, 0, 0, 0, 0), 161 TransformationMatrix(1, 1, 0, 0, 0, 0),
169 FloatPoint3D(9, 8, 7)); 162 FloatPoint3D(9, 8, 7));
170 simpleTransformAndEffectWithUpdatedTransform.effect = 163 simpleTransformAndEffectWithUpdatedTransform.effect =
171 EffectPaintPropertyNode::create( 164 createOpacityOnlyEffect(EffectPaintPropertyNode::root(),
172 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 165 simpleTransformAndEffect.effect->opacity());
173 ClipPaintPropertyNode::root(), CompositorFilterOperations(),
174 simpleTransformAndEffect.effect->opacity());
175 chunker.updateCurrentPaintChunkProperties( 166 chunker.updateCurrentPaintChunkProperties(
176 nullptr, simpleTransformAndEffectWithUpdatedTransform); 167 nullptr, simpleTransformAndEffectWithUpdatedTransform);
177 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 168 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
178 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 169 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
179 170
180 // Test that going back to a previous chunk property still creates a new 171 // Test that going back to a previous chunk property still creates a new
181 // chunk. 172 // chunk.
182 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 173 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 174 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
184 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 175 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
185 176
186 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 177 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
187 178
188 EXPECT_THAT( 179 EXPECT_THAT(
189 chunks, 180 chunks,
190 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 181 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
191 PaintChunk(1, 3, nullptr, simpleTransform), 182 PaintChunk(1, 3, nullptr, simpleTransform),
192 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), 183 PaintChunk(3, 5, nullptr, simpleTransformAndEffect),
193 PaintChunk(5, 7, nullptr, 184 PaintChunk(5, 7, nullptr,
194 simpleTransformAndEffectWithUpdatedTransform), 185 simpleTransformAndEffectWithUpdatedTransform),
195 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); 186 PaintChunk(7, 9, nullptr, simpleTransformAndEffect)));
196 } 187 }
197 188
198 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { 189 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
199 // Test that "nested" transforms linearize using the following 190 // Test that "nested" transforms linearize using the following
200 // sequence of transforms and display items: 191 // sequence of transforms and display items:
201 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, 192 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
202 // </root xform> 193 // </root xform>
203 PaintChunker chunker; 194 PaintChunker chunker;
204 chunker.updateCurrentPaintChunkProperties(nullptr, 195 chunker.updateCurrentPaintChunkProperties(nullptr,
205 rootPaintChunkProperties()); 196 defaultPaintChunkProperties());
206 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 197 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
207 198
208 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 199 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
209 simpleTransform.transform = TransformPaintPropertyNode::create( 200 simpleTransform.transform = TransformPaintPropertyNode::create(
210 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 201 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
211 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 202 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
212 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 203 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
213 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 204 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
214 205
215 chunker.updateCurrentPaintChunkProperties(nullptr, 206 chunker.updateCurrentPaintChunkProperties(nullptr,
216 rootPaintChunkProperties()); 207 defaultPaintChunkProperties());
217 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 208 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
218 209
219 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 210 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
220 211
221 EXPECT_THAT( 212 EXPECT_THAT(
222 chunks, 213 chunks,
223 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 214 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
224 PaintChunk(1, 3, nullptr, simpleTransform), 215 PaintChunk(1, 3, nullptr, simpleTransform),
225 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); 216 PaintChunk(3, 4, nullptr, defaultPaintChunkProperties())));
226 } 217 }
227 218
228 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { 219 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
229 // Test that properties can change without display items being generated. 220 // Test that properties can change without display items being generated.
230 PaintChunker chunker; 221 PaintChunker chunker;
231 chunker.updateCurrentPaintChunkProperties(nullptr, 222 chunker.updateCurrentPaintChunkProperties(nullptr,
232 rootPaintChunkProperties()); 223 defaultPaintChunkProperties());
233 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 224 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
234 225
235 PaintChunkProperties firstTransform = rootPaintChunkProperties(); 226 PaintChunkProperties firstTransform = defaultPaintChunkProperties();
236 firstTransform.transform = TransformPaintPropertyNode::create( 227 firstTransform.transform = TransformPaintPropertyNode::create(
237 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 228 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
238 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); 229 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
239 230
240 PaintChunkProperties secondTransform = rootPaintChunkProperties(); 231 PaintChunkProperties secondTransform = defaultPaintChunkProperties();
241 secondTransform.transform = TransformPaintPropertyNode::create( 232 secondTransform.transform = TransformPaintPropertyNode::create(
242 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); 233 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
243 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); 234 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
244 235
245 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 236 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
246 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 237 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
247 238
248 EXPECT_THAT(chunks, 239 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr,
249 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 240 defaultPaintChunkProperties()),
250 PaintChunk(1, 2, nullptr, secondTransform))); 241 PaintChunk(1, 2, nullptr, secondTransform)));
251 } 242 }
252 243
253 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { 244 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) {
254 // Tests that the chunker creates a separate chunks for display items which 245 // Tests that the chunker creates a separate chunks for display items which
255 // require it. 246 // require it.
256 PaintChunker chunker; 247 PaintChunker chunker;
257 TestDisplayItemRequiringSeparateChunk i1(m_client); 248 TestDisplayItemRequiringSeparateChunk i1(m_client);
258 TestDisplayItemRequiringSeparateChunk i2(m_client); 249 TestDisplayItemRequiringSeparateChunk i2(m_client);
259 TestDisplayItemRequiringSeparateChunk i3(m_client); 250 TestDisplayItemRequiringSeparateChunk i3(m_client);
260 TestDisplayItemRequiringSeparateChunk i4(m_client); 251 TestDisplayItemRequiringSeparateChunk i4(m_client);
261 TestDisplayItemRequiringSeparateChunk i5(m_client); 252 TestDisplayItemRequiringSeparateChunk i5(m_client);
262 TestDisplayItemRequiringSeparateChunk i6(m_client); 253 TestDisplayItemRequiringSeparateChunk i6(m_client);
263 254
264 chunker.updateCurrentPaintChunkProperties(nullptr, 255 chunker.updateCurrentPaintChunkProperties(nullptr,
265 rootPaintChunkProperties()); 256 defaultPaintChunkProperties());
266 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 257 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
267 chunker.incrementDisplayItemIndex(i1); 258 chunker.incrementDisplayItemIndex(i1);
268 chunker.incrementDisplayItemIndex(i2); 259 chunker.incrementDisplayItemIndex(i2);
269 chunker.incrementDisplayItemIndex(i3); 260 chunker.incrementDisplayItemIndex(i3);
270 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 261 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
271 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 262 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
272 chunker.incrementDisplayItemIndex(i4); 263 chunker.incrementDisplayItemIndex(i4);
273 chunker.incrementDisplayItemIndex(i5); 264 chunker.incrementDisplayItemIndex(i5);
274 chunker.decrementDisplayItemIndex(); 265 chunker.decrementDisplayItemIndex();
275 chunker.decrementDisplayItemIndex(); 266 chunker.decrementDisplayItemIndex();
276 chunker.decrementDisplayItemIndex(); 267 chunker.decrementDisplayItemIndex();
277 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 268 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
278 chunker.incrementDisplayItemIndex(i6); 269 chunker.incrementDisplayItemIndex(i6);
279 270
280 DisplayItem::Id id1 = i1.getId(); 271 DisplayItem::Id id1 = i1.getId();
281 DisplayItem::Id id2 = i2.getId(); 272 DisplayItem::Id id2 = i2.getId();
282 DisplayItem::Id id3 = i3.getId(); 273 DisplayItem::Id id3 = i3.getId();
283 DisplayItem::Id id6 = i6.getId(); 274 DisplayItem::Id id6 = i6.getId();
284 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 275 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
285 EXPECT_THAT(chunks, 276 EXPECT_THAT(
286 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 277 chunks,
287 PaintChunk(1, 2, &id1, rootPaintChunkProperties()), 278 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
288 PaintChunk(2, 3, &id2, rootPaintChunkProperties()), 279 PaintChunk(1, 2, &id1, defaultPaintChunkProperties()),
289 PaintChunk(3, 4, &id3, rootPaintChunkProperties()), 280 PaintChunk(2, 3, &id2, defaultPaintChunkProperties()),
290 PaintChunk(4, 6, nullptr, rootPaintChunkProperties()), 281 PaintChunk(3, 4, &id3, defaultPaintChunkProperties()),
291 PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); 282 PaintChunk(4, 6, nullptr, defaultPaintChunkProperties()),
283 PaintChunk(6, 7, &id6, defaultPaintChunkProperties())));
292 } 284 }
293 285
294 TEST_F(PaintChunkerTest, ChunkIds) { 286 TEST_F(PaintChunkerTest, ChunkIds) {
295 PaintChunker chunker; 287 PaintChunker chunker;
296 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst); 288 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst);
297 DisplayItem::Id id1 = i1.getId(); 289 DisplayItem::Id id1 = i1.getId();
298 TestDisplayItemRequiringSeparateChunk i2(m_client); 290 TestDisplayItemRequiringSeparateChunk i2(m_client);
299 DisplayItem::Id id2 = i2.getId(); 291 DisplayItem::Id id2 = i2.getId();
300 292
301 chunker.updateCurrentPaintChunkProperties(nullptr, 293 chunker.updateCurrentPaintChunkProperties(nullptr,
302 rootPaintChunkProperties()); 294 defaultPaintChunkProperties());
303 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
305 297
306 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 298 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
307 simpleTransform.transform = TransformPaintPropertyNode::create( 299 simpleTransform.transform = TransformPaintPropertyNode::create(
308 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 300 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
309 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 301 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
310 302
311 chunker.incrementDisplayItemIndex(i1); 303 chunker.incrementDisplayItemIndex(i1);
312 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
313 chunker.incrementDisplayItemIndex(i2); 305 chunker.incrementDisplayItemIndex(i2);
314 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 306 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
315 307
316 chunker.updateCurrentPaintChunkProperties(nullptr, 308 chunker.updateCurrentPaintChunkProperties(nullptr,
317 rootPaintChunkProperties()); 309 defaultPaintChunkProperties());
318 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 310 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
319 311
320 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 312 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
321 EXPECT_THAT( 313 EXPECT_THAT(
322 chunks, 314 chunks,
323 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 315 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
324 PaintChunk(2, 4, &id1, simpleTransform), 316 PaintChunk(2, 4, &id1, simpleTransform),
325 PaintChunk(4, 5, &id2, simpleTransform), 317 PaintChunk(4, 5, &id2, simpleTransform),
326 PaintChunk(5, 6, nullptr, simpleTransform), 318 PaintChunk(5, 6, nullptr, simpleTransform),
327 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); 319 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
328 } 320 }
329 321
330 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { 322 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
331 PaintChunker chunker; 323 PaintChunker chunker;
332 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst); 324 TestDisplayItem i1(m_client, DisplayItem::kDrawingFirst);
333 i1.setSkippedCache(); 325 i1.setSkippedCache();
334 DisplayItem::Id id1 = i1.getId(); 326 DisplayItem::Id id1 = i1.getId();
335 TestDisplayItemRequiringSeparateChunk i2(m_client); 327 TestDisplayItemRequiringSeparateChunk i2(m_client);
336 i2.setSkippedCache(); 328 i2.setSkippedCache();
337 329
338 chunker.updateCurrentPaintChunkProperties(nullptr, 330 chunker.updateCurrentPaintChunkProperties(nullptr,
339 rootPaintChunkProperties()); 331 defaultPaintChunkProperties());
340 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 332 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 333 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
342 334
343 PaintChunkProperties simpleTransform = rootPaintChunkProperties(); 335 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
344 simpleTransform.transform = TransformPaintPropertyNode::create( 336 simpleTransform.transform = TransformPaintPropertyNode::create(
345 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 337 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
346 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 338 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
347 339
348 chunker.incrementDisplayItemIndex(i1); 340 chunker.incrementDisplayItemIndex(i1);
349 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
350 chunker.incrementDisplayItemIndex(i2); 342 chunker.incrementDisplayItemIndex(i2);
351 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 343 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
352 344
353 chunker.updateCurrentPaintChunkProperties(nullptr, 345 chunker.updateCurrentPaintChunkProperties(nullptr,
354 rootPaintChunkProperties()); 346 defaultPaintChunkProperties());
355 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 347 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
356 348
357 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 349 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
358 EXPECT_THAT( 350 EXPECT_THAT(
359 chunks, 351 chunks,
360 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 352 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
361 PaintChunk(2, 4, nullptr, simpleTransform), 353 PaintChunk(2, 4, nullptr, simpleTransform),
362 PaintChunk(4, 5, nullptr, simpleTransform), 354 PaintChunk(4, 5, nullptr, simpleTransform),
363 PaintChunk(5, 6, nullptr, simpleTransform), 355 PaintChunk(5, 6, nullptr, simpleTransform),
364 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); 356 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
365 } 357 }
366 358
367 } // namespace 359 } // namespace
368 } // namespace blink 360 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698