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