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 |
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 bot
s. | 16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug |
| 17 // bots. |
17 #if defined(NDEBUG) || !OS(WIN) | 18 #if defined(NDEBUG) || !OS(WIN) |
18 | 19 |
19 static PaintChunkProperties rootPaintChunkProperties() { | 20 static PaintChunkProperties rootPaintChunkProperties() { |
20 return PaintChunkProperties(); | 21 return PaintChunkProperties(); |
21 } | 22 } |
22 | 23 |
23 class PaintChunkerTest : public testing::Test { | 24 class PaintChunkerTest : public testing::Test { |
24 protected: | 25 protected: |
25 void SetUp() override { | 26 void SetUp() override { |
26 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 27 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 TransformationMatrix(1, 1, 0, 0, 0, 0), | 159 TransformationMatrix(1, 1, 0, 0, 0, 0), |
159 FloatPoint3D(9, 8, 7)); | 160 FloatPoint3D(9, 8, 7)); |
160 simpleTransformAndEffectWithUpdatedTransform.effect = | 161 simpleTransformAndEffectWithUpdatedTransform.effect = |
161 EffectPaintPropertyNode::create( | 162 EffectPaintPropertyNode::create( |
162 nullptr, simpleTransformAndEffect.effect->opacity()); | 163 nullptr, simpleTransformAndEffect.effect->opacity()); |
163 chunker.updateCurrentPaintChunkProperties( | 164 chunker.updateCurrentPaintChunkProperties( |
164 nullptr, simpleTransformAndEffectWithUpdatedTransform); | 165 nullptr, simpleTransformAndEffectWithUpdatedTransform); |
165 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 166 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
166 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 167 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
167 | 168 |
168 // Test that going back to a previous chunk property still creates a new chunk
. | 169 // Test that going back to a previous chunk property still creates a new |
| 170 // chunk. |
169 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); | 171 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); |
170 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 172 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
171 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 173 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
172 | 174 |
173 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 175 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
174 | 176 |
175 EXPECT_THAT( | 177 EXPECT_THAT( |
176 chunks, | 178 chunks, |
177 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 179 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
178 PaintChunk(1, 3, nullptr, simpleTransform), | 180 PaintChunk(1, 3, nullptr, simpleTransform), |
179 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), | 181 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), |
180 PaintChunk(5, 7, nullptr, | 182 PaintChunk(5, 7, nullptr, |
181 simpleTransformAndEffectWithUpdatedTransform), | 183 simpleTransformAndEffectWithUpdatedTransform), |
182 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); | 184 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); |
183 } | 185 } |
184 | 186 |
185 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { | 187 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { |
186 // Test that "nested" transforms linearize using the following | 188 // Test that "nested" transforms linearize using the following |
187 // sequence of transforms and display items: | 189 // sequence of transforms and display items: |
188 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </
root xform> | 190 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, |
| 191 // </root xform> |
189 PaintChunker chunker; | 192 PaintChunker chunker; |
190 chunker.updateCurrentPaintChunkProperties(nullptr, | 193 chunker.updateCurrentPaintChunkProperties(nullptr, |
191 rootPaintChunkProperties()); | 194 rootPaintChunkProperties()); |
192 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 195 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
193 | 196 |
194 PaintChunkProperties simpleTransform; | 197 PaintChunkProperties simpleTransform; |
195 simpleTransform.transform = TransformPaintPropertyNode::create( | 198 simpleTransform.transform = TransformPaintPropertyNode::create( |
196 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 199 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
197 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 200 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
198 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 201 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 PaintChunk(2, 4, nullptr, simpleTransform), | 340 PaintChunk(2, 4, nullptr, simpleTransform), |
338 PaintChunk(4, 5, nullptr, simpleTransform), | 341 PaintChunk(4, 5, nullptr, simpleTransform), |
339 PaintChunk(5, 6, nullptr, simpleTransform), | 342 PaintChunk(5, 6, nullptr, simpleTransform), |
340 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | 343 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); |
341 } | 344 } |
342 | 345 |
343 #endif | 346 #endif |
344 | 347 |
345 } // namespace | 348 } // namespace |
346 } // namespace blink | 349 } // namespace blink |
OLD | NEW |