OLD | NEW |
---|---|
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 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 | 24 |
25 void TearDown() override | 25 void TearDown() override |
26 { | 26 { |
27 m_featuresBackup.restore(); | 27 m_featuresBackup.restore(); |
28 } | 28 } |
29 | 29 |
30 private: | 30 private: |
31 RuntimeEnabledFeatures::Backup m_featuresBackup; | 31 RuntimeEnabledFeatures::Backup m_featuresBackup; |
32 }; | 32 }; |
33 | 33 |
34 class TestDisplayItem : public DisplayItem, public DisplayItemClient { | |
35 public: | |
36 TestDisplayItem(DisplayItem::Type type) : DisplayItem(*this, type, sizeof(*t his)) { } | |
37 | |
38 void replay(GraphicsContext&) const final { NOTREACHED(); } | |
39 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const f inal { NOTREACHED(); } | |
40 String debugName() const final { return "Test"; } | |
41 LayoutRect visualRect() const final { return LayoutRect(); } | |
42 }; | |
43 | |
44 class NormalTestDisplayItem : public TestDisplayItem { | |
45 public: | |
46 NormalTestDisplayItem() : TestDisplayItem(DisplayItem::DrawingFirst) { } | |
47 }; | |
48 | |
49 class TestDisplayItemRequiringSeparateChunk : public TestDisplayItem { | |
50 public: | |
51 TestDisplayItemRequiringSeparateChunk() : TestDisplayItem(DisplayItem::Forei gnLayerPlugin) { } | |
52 }; | |
53 | |
34 TEST_F(PaintChunkerTest, Empty) | 54 TEST_F(PaintChunkerTest, Empty) |
35 { | 55 { |
36 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); | 56 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); |
37 ASSERT_TRUE(chunks.isEmpty()); | 57 ASSERT_TRUE(chunks.isEmpty()); |
38 } | 58 } |
39 | 59 |
40 TEST_F(PaintChunkerTest, SingleNonEmptyRange) | 60 TEST_F(PaintChunkerTest, SingleNonEmptyRange) |
41 { | 61 { |
42 PaintChunker chunker; | 62 PaintChunker chunker; |
43 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 63 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
44 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 64 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
45 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 65 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
46 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 66 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
47 | 67 |
48 EXPECT_THAT(chunks, ElementsAre( | 68 EXPECT_THAT(chunks, ElementsAre( |
49 PaintChunk(0, 2, rootPaintChunkProperties()))); | 69 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()))); |
50 } | 70 } |
51 | 71 |
52 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) | 72 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) |
53 { | 73 { |
54 PaintChunker chunker; | 74 PaintChunker chunker; |
55 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 75 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
56 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 76 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
57 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 77 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
58 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 78 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
59 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 79 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
60 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 80 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
61 | 81 |
62 EXPECT_THAT(chunks, ElementsAre( | 82 EXPECT_THAT(chunks, ElementsAre( |
63 PaintChunk(0, 3, rootPaintChunkProperties()))); | 83 PaintChunk(0, 3, nullptr, rootPaintChunkProperties()))); |
64 } | 84 } |
65 | 85 |
66 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) | 86 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) |
67 { | 87 { |
68 PaintChunker chunker; | 88 PaintChunker chunker; |
69 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 89 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
70 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 90 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
71 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 91 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
72 chunker.decrementDisplayItemIndex(); | 92 chunker.decrementDisplayItemIndex(); |
73 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 93 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
74 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 94 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
75 | 95 |
76 EXPECT_THAT(chunks, ElementsAre( | 96 EXPECT_THAT(chunks, ElementsAre( |
77 PaintChunk(0, 2, rootPaintChunkProperties()))); | 97 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()))); |
78 } | 98 } |
79 | 99 |
80 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) | 100 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) |
81 { | 101 { |
82 PaintChunker chunker; | 102 PaintChunker chunker; |
83 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 103 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
84 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 104 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
85 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 105 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
86 | 106 |
87 PaintChunkProperties simpleTransform; | 107 PaintChunkProperties simpleTransform; |
88 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 108 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
89 | 109 |
90 chunker.updateCurrentPaintChunkProperties(simpleTransform); | 110 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
91 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 111 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
92 | 112 |
93 PaintChunkProperties anotherTransform; | 113 PaintChunkProperties anotherTransform; |
94 anotherTransform.transform = TransformPaintPropertyNode::create(Transformati onMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 114 anotherTransform.transform = TransformPaintPropertyNode::create(Transformati onMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
95 chunker.updateCurrentPaintChunkProperties(anotherTransform); | 115 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); |
96 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 116 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
97 | 117 |
98 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 118 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
99 | 119 |
100 EXPECT_THAT(chunks, ElementsAre( | 120 EXPECT_THAT(chunks, ElementsAre( |
101 PaintChunk(0, 2, rootPaintChunkProperties()), | 121 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), |
102 PaintChunk(2, 3, simpleTransform), | 122 PaintChunk(2, 3, nullptr, simpleTransform), |
103 PaintChunk(3, 4, anotherTransform))); | 123 PaintChunk(3, 4, nullptr, anotherTransform))); |
104 } | 124 } |
105 | 125 |
106 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) | 126 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) |
107 { | 127 { |
108 PaintChunker chunker; | 128 PaintChunker chunker; |
109 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 129 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
110 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 130 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
111 | 131 |
112 PaintChunkProperties simpleTransform; | 132 PaintChunkProperties simpleTransform; |
113 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 133 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
114 chunker.updateCurrentPaintChunkProperties(simpleTransform); | 134 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
115 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 135 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
116 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 136 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
117 | 137 |
118 PaintChunkProperties simpleTransformAndEffect; | 138 PaintChunkProperties simpleTransformAndEffect; |
119 simpleTransformAndEffect.transform = simpleTransform.transform; | 139 simpleTransformAndEffect.transform = simpleTransform.transform; |
120 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f); | 140 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f); |
121 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect); | 141 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect) ; |
122 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 142 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
123 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 143 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
124 | 144 |
125 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; | 145 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; |
126 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope rtyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 146 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope rtyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
127 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod e::create(simpleTransformAndEffect.effect->opacity()); | 147 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod e::create(simpleTransformAndEffect.effect->opacity()); |
128 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffectWithUpdate dTransform); | 148 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffectW ithUpdatedTransform); |
129 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 149 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
130 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 150 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
131 | 151 |
132 // Test that going back to a previous chunk property still creates a new chu nk. | 152 // Test that going back to a previous chunk property still creates a new chu nk. |
133 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect); | 153 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect) ; |
134 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
135 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
136 | 156 |
137 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 157 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
138 | 158 |
139 EXPECT_THAT(chunks, ElementsAre( | 159 EXPECT_THAT(chunks, ElementsAre( |
140 PaintChunk(0, 1, rootPaintChunkProperties()), | 160 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
141 PaintChunk(1, 3, simpleTransform), | 161 PaintChunk(1, 3, nullptr, simpleTransform), |
142 PaintChunk(3, 5, simpleTransformAndEffect), | 162 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), |
143 PaintChunk(5, 7, simpleTransformAndEffectWithUpdatedTransform), | 163 PaintChunk(5, 7, nullptr, simpleTransformAndEffectWithUpdatedTransform), |
144 PaintChunk(7, 9, simpleTransformAndEffect))); | 164 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); |
145 } | 165 } |
146 | 166 |
147 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) | 167 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) |
148 { | 168 { |
149 // Test that "nested" transforms linearize using the following | 169 // Test that "nested" transforms linearize using the following |
150 // sequence of transforms and display items: | 170 // sequence of transforms and display items: |
151 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </root xform> | 171 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </root xform> |
152 PaintChunker chunker; | 172 PaintChunker chunker; |
153 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 173 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
154 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 174 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
155 | 175 |
156 PaintChunkProperties simpleTransform; | 176 PaintChunkProperties simpleTransform; |
157 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 177 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
158 chunker.updateCurrentPaintChunkProperties(simpleTransform); | 178 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
159 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 179 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
160 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 180 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
161 | 181 |
162 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 182 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
163 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
164 | 184 |
165 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 185 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
166 | 186 |
167 EXPECT_THAT(chunks, ElementsAre( | 187 EXPECT_THAT(chunks, ElementsAre( |
168 PaintChunk(0, 1, rootPaintChunkProperties()), | 188 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
169 PaintChunk(1, 3, simpleTransform), | 189 PaintChunk(1, 3, nullptr, simpleTransform), |
170 PaintChunk(3, 4, rootPaintChunkProperties()))); | 190 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); |
171 } | 191 } |
172 | 192 |
173 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) | 193 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) |
174 { | 194 { |
175 // Test that properties can change without display items being generated. | 195 // Test that properties can change without display items being generated. |
176 PaintChunker chunker; | 196 PaintChunker chunker; |
177 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 197 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
178 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 198 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
179 | 199 |
180 PaintChunkProperties firstTransform; | 200 PaintChunkProperties firstTransform; |
181 firstTransform.transform = TransformPaintPropertyNode::create(Transformation Matrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 201 firstTransform.transform = TransformPaintPropertyNode::create(Transformation Matrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
182 chunker.updateCurrentPaintChunkProperties(firstTransform); | 202 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); |
183 | 203 |
184 PaintChunkProperties secondTransform; | 204 PaintChunkProperties secondTransform; |
185 secondTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); | 205 secondTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); |
186 chunker.updateCurrentPaintChunkProperties(secondTransform); | 206 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); |
187 | 207 |
188 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 208 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
189 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 209 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
190 | 210 |
191 EXPECT_THAT(chunks, ElementsAre( | 211 EXPECT_THAT(chunks, ElementsAre( |
192 PaintChunk(0, 1, rootPaintChunkProperties()), | 212 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
193 PaintChunk(1, 2, secondTransform))); | 213 PaintChunk(1, 2, nullptr, secondTransform))); |
194 } | 214 } |
195 | 215 |
196 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) | 216 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) |
197 { | 217 { |
198 // Tests that the chunker creates a separate chunks for display items which | 218 // Tests that the chunker creates a separate chunks for display items which |
199 // require it. | 219 // require it. |
200 PaintChunker chunker; | 220 PaintChunker chunker; |
201 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); | 221 TestDisplayItemRequiringSeparateChunk i1, i2, i3, i4, i5, i6; |
202 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 222 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); |
203 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 223 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
204 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 224 chunker.incrementDisplayItemIndex(i1); |
205 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 225 chunker.incrementDisplayItemIndex(i2); |
206 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 226 chunker.incrementDisplayItemIndex(i3); |
207 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 227 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
chrishtr
2016/07/19 17:27:52
I think you could make multiple NormalTestDisplayI
Xianzhu
2016/07/19 21:57:48
I think line 227-228 is what you said. The NormalT
chrishtr
2016/07/19 23:42:27
Ah yes. You're right.
| |
208 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 228 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
209 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 229 chunker.incrementDisplayItemIndex(i4); |
230 chunker.incrementDisplayItemIndex(i5); | |
210 chunker.decrementDisplayItemIndex(); | 231 chunker.decrementDisplayItemIndex(); |
211 chunker.decrementDisplayItemIndex(); | 232 chunker.decrementDisplayItemIndex(); |
212 chunker.decrementDisplayItemIndex(); | 233 chunker.decrementDisplayItemIndex(); |
213 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); | 234 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
214 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); | 235 chunker.incrementDisplayItemIndex(i6); |
236 | |
237 DisplayItem::Id id1 = i1.getId(); | |
238 DisplayItem::Id id2 = i2.getId(); | |
239 DisplayItem::Id id3 = i3.getId(); | |
240 DisplayItem::Id id6 = i6.getId(); | |
241 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | |
242 EXPECT_THAT(chunks, ElementsAre( | |
243 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | |
244 PaintChunk(1, 2, &id1, rootPaintChunkProperties()), | |
245 PaintChunk(2, 3, &id2, rootPaintChunkProperties()), | |
246 PaintChunk(3, 4, &id3, rootPaintChunkProperties()), | |
247 PaintChunk(4, 6, nullptr, rootPaintChunkProperties()), | |
248 PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); | |
249 } | |
250 | |
251 TEST_F(PaintChunkerTest, ChunkIds) | |
252 { | |
253 PaintChunker chunker; | |
254 TestDisplayItem i1(DisplayItem::DrawingFirst); | |
255 DisplayItem::Id id1 = i1.getId(); | |
256 TestDisplayItemRequiringSeparateChunk i2; | |
257 DisplayItem::Id id2 = i2.getId(); | |
258 | |
259 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
260 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
261 | |
262 PaintChunkProperties simpleTransform; | |
263 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | |
264 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | |
265 | |
266 chunker.incrementDisplayItemIndex(i1); | |
267 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
268 chunker.incrementDisplayItemIndex(i2); | |
269 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
270 | |
271 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); | |
272 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
215 | 273 |
216 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 274 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
217 EXPECT_THAT(chunks, ElementsAre( | 275 EXPECT_THAT(chunks, ElementsAre( |
218 PaintChunk(0, 1, rootPaintChunkProperties()), | 276 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), |
219 PaintChunk(1, 2, rootPaintChunkProperties()), | 277 PaintChunk(2, 4, &id1, simpleTransform), |
220 PaintChunk(2, 3, rootPaintChunkProperties()), | 278 PaintChunk(4, 5, &id2, simpleTransform), |
221 PaintChunk(3, 4, rootPaintChunkProperties()), | 279 PaintChunk(5, 6, nullptr, simpleTransform), |
222 PaintChunk(4, 6, rootPaintChunkProperties()), | 280 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); |
223 PaintChunk(6, 7, rootPaintChunkProperties()))); | 281 } |
282 | |
283 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) | |
284 { | |
285 PaintChunker chunker; | |
286 TestDisplayItem i1(DisplayItem::DrawingFirst); | |
287 i1.setSkippedCache(); | |
288 DisplayItem::Id id1 = i1.getId(); | |
289 TestDisplayItemRequiringSeparateChunk i2; | |
290 i2.setSkippedCache(); | |
291 | |
292 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
293 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
294 | |
295 PaintChunkProperties simpleTransform; | |
296 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | |
297 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | |
298 | |
299 chunker.incrementDisplayItemIndex(i1); | |
300 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
301 chunker.incrementDisplayItemIndex(i2); | |
302 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
303 | |
304 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); | |
305 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
306 | |
307 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | |
308 EXPECT_THAT(chunks, ElementsAre( | |
309 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | |
310 PaintChunk(2, 4, nullptr, simpleTransform), | |
311 PaintChunk(4, 5, nullptr, simpleTransform), | |
312 PaintChunk(5, 6, nullptr, simpleTransform), | |
313 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | |
314 } | |
315 | |
316 TEST_F(PaintChunkerTest, OldNewChunkSameAddress) | |
chrishtr
2016/07/19 17:27:52
What is the difference between this test and Chunk
Xianzhu
2016/07/19 21:57:48
Removed.
This was copied from ChunkIds for a test
| |
317 { | |
318 PaintChunker chunker; | |
319 TestDisplayItem i1(DisplayItem::DrawingFirst); | |
320 DisplayItem::Id id1 = i1.getId(); | |
321 TestDisplayItemRequiringSeparateChunk i2; | |
322 DisplayItem::Id id2 = i2.getId(); | |
323 | |
324 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
325 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
326 | |
327 PaintChunkProperties simpleTransform; | |
328 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | |
329 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | |
330 | |
331 chunker.incrementDisplayItemIndex(i1); | |
332 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
333 chunker.incrementDisplayItemIndex(i2); | |
334 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
335 | |
336 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties( )); | |
337 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
338 | |
339 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | |
340 EXPECT_THAT(chunks, ElementsAre( | |
341 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | |
342 PaintChunk(2, 4, &id1, simpleTransform), | |
343 PaintChunk(4, 5, &id2, simpleTransform), | |
344 PaintChunk(5, 6, nullptr, simpleTransform), | |
345 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | |
224 } | 346 } |
225 | 347 |
226 } // namespace | 348 } // namespace |
227 } // namespace blink | 349 } // namespace blink |
OLD | NEW |