| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) | 103 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) |
| 104 { | 104 { |
| 105 PaintChunker chunker; | 105 PaintChunker chunker; |
| 106 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 106 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 107 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 107 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 108 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 108 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 109 | 109 |
| 110 PaintChunkProperties simpleTransform; | 110 PaintChunkProperties simpleTransform; |
| 111 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 111 simpleTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 112 | 112 |
| 113 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 113 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
| 114 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 114 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 115 | 115 |
| 116 PaintChunkProperties anotherTransform; | 116 PaintChunkProperties anotherTransform; |
| 117 anotherTransform.transform = TransformPaintPropertyNode::create(Transformati
onMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 117 anotherTransform.transform = TransformPaintPropertyNode::create(nullptr, Tra
nsformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 118 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); | 118 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); |
| 119 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 119 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 120 | 120 |
| 121 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 121 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 122 | 122 |
| 123 EXPECT_THAT(chunks, ElementsAre( | 123 EXPECT_THAT(chunks, ElementsAre( |
| 124 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | 124 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), |
| 125 PaintChunk(2, 3, nullptr, simpleTransform), | 125 PaintChunk(2, 3, nullptr, simpleTransform), |
| 126 PaintChunk(3, 4, nullptr, anotherTransform))); | 126 PaintChunk(3, 4, nullptr, anotherTransform))); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) | 129 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) |
| 130 { | 130 { |
| 131 PaintChunker chunker; | 131 PaintChunker chunker; |
| 132 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 132 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 133 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 133 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 134 | 134 |
| 135 PaintChunkProperties simpleTransform; | 135 PaintChunkProperties simpleTransform; |
| 136 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 136 simpleTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
| 137 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 137 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
| 138 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 138 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 139 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 139 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 140 | 140 |
| 141 PaintChunkProperties simpleTransformAndEffect; | 141 PaintChunkProperties simpleTransformAndEffect; |
| 142 simpleTransformAndEffect.transform = simpleTransform.transform; | 142 simpleTransformAndEffect.transform = simpleTransform.transform; |
| 143 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f); | 143 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(nullptr, 0
.5f); |
| 144 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; | 144 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; |
| 145 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 145 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 147 | 147 |
| 148 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; | 148 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; |
| 149 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope
rtyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 149 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope
rtyNode::create(nullptr, TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9,
8, 7)); |
| 150 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod
e::create(simpleTransformAndEffect.effect->opacity()); | 150 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod
e::create(nullptr, simpleTransformAndEffect.effect->opacity()); |
| 151 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffectW
ithUpdatedTransform); | 151 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffectW
ithUpdatedTransform); |
| 152 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 152 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 154 | 154 |
| 155 // Test that going back to a previous chunk property still creates a new chu
nk. | 155 // Test that going back to a previous chunk property still creates a new chu
nk. |
| 156 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; | 156 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; |
| 157 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 157 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 158 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 158 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 159 | 159 |
| 160 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 160 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 161 | 161 |
| 162 EXPECT_THAT(chunks, ElementsAre( | 162 EXPECT_THAT(chunks, ElementsAre( |
| 163 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 163 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
| 164 PaintChunk(1, 3, nullptr, simpleTransform), | 164 PaintChunk(1, 3, nullptr, simpleTransform), |
| 165 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), | 165 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), |
| 166 PaintChunk(5, 7, nullptr, simpleTransformAndEffectWithUpdatedTransform), | 166 PaintChunk(5, 7, nullptr, simpleTransformAndEffectWithUpdatedTransform), |
| 167 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); | 167 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); |
| 168 } | 168 } |
| 169 | 169 |
| 170 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) | 170 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) |
| 171 { | 171 { |
| 172 // Test that "nested" transforms linearize using the following | 172 // Test that "nested" transforms linearize using the following |
| 173 // sequence of transforms and display items: | 173 // sequence of transforms and display items: |
| 174 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
</root xform> | 174 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
</root xform> |
| 175 PaintChunker chunker; | 175 PaintChunker chunker; |
| 176 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 176 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 177 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 177 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 178 | 178 |
| 179 PaintChunkProperties simpleTransform; | 179 PaintChunkProperties simpleTransform; |
| 180 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 180 simpleTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 181 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 181 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
| 182 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 182 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 184 | 184 |
| 185 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 185 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 186 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 186 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 187 | 187 |
| 188 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 188 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 189 | 189 |
| 190 EXPECT_THAT(chunks, ElementsAre( | 190 EXPECT_THAT(chunks, ElementsAre( |
| 191 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 191 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
| 192 PaintChunk(1, 3, nullptr, simpleTransform), | 192 PaintChunk(1, 3, nullptr, simpleTransform), |
| 193 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); | 193 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) | 196 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) |
| 197 { | 197 { |
| 198 // Test that properties can change without display items being generated. | 198 // Test that properties can change without display items being generated. |
| 199 PaintChunker chunker; | 199 PaintChunker chunker; |
| 200 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 200 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 201 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 201 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 202 | 202 |
| 203 PaintChunkProperties firstTransform; | 203 PaintChunkProperties firstTransform; |
| 204 firstTransform.transform = TransformPaintPropertyNode::create(Transformation
Matrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 204 firstTransform.transform = TransformPaintPropertyNode::create(nullptr, Trans
formationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 205 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); | 205 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); |
| 206 | 206 |
| 207 PaintChunkProperties secondTransform; | 207 PaintChunkProperties secondTransform; |
| 208 secondTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); | 208 secondTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); |
| 209 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); | 209 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); |
| 210 | 210 |
| 211 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 211 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 212 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 212 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 213 | 213 |
| 214 EXPECT_THAT(chunks, ElementsAre( | 214 EXPECT_THAT(chunks, ElementsAre( |
| 215 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 215 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), |
| 216 PaintChunk(1, 2, nullptr, secondTransform))); | 216 PaintChunk(1, 2, nullptr, secondTransform))); |
| 217 } | 217 } |
| 218 | 218 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 PaintChunker chunker; | 256 PaintChunker chunker; |
| 257 TestDisplayItem i1(DisplayItem::DrawingFirst); | 257 TestDisplayItem i1(DisplayItem::DrawingFirst); |
| 258 DisplayItem::Id id1 = i1.getId(); | 258 DisplayItem::Id id1 = i1.getId(); |
| 259 TestDisplayItemRequiringSeparateChunk i2; | 259 TestDisplayItemRequiringSeparateChunk i2; |
| 260 DisplayItem::Id id2 = i2.getId(); | 260 DisplayItem::Id id2 = i2.getId(); |
| 261 | 261 |
| 262 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 262 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 263 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 263 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 264 | 264 |
| 265 PaintChunkProperties simpleTransform; | 265 PaintChunkProperties simpleTransform; |
| 266 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 266 simpleTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 267 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | 267 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); |
| 268 | 268 |
| 269 chunker.incrementDisplayItemIndex(i1); | 269 chunker.incrementDisplayItemIndex(i1); |
| 270 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 270 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 271 chunker.incrementDisplayItemIndex(i2); | 271 chunker.incrementDisplayItemIndex(i2); |
| 272 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 272 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 273 | 273 |
| 274 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 274 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 275 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 275 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 276 | 276 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 289 TestDisplayItem i1(DisplayItem::DrawingFirst); | 289 TestDisplayItem i1(DisplayItem::DrawingFirst); |
| 290 i1.setSkippedCache(); | 290 i1.setSkippedCache(); |
| 291 DisplayItem::Id id1 = i1.getId(); | 291 DisplayItem::Id id1 = i1.getId(); |
| 292 TestDisplayItemRequiringSeparateChunk i2; | 292 TestDisplayItemRequiringSeparateChunk i2; |
| 293 i2.setSkippedCache(); | 293 i2.setSkippedCache(); |
| 294 | 294 |
| 295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 297 | 297 |
| 298 PaintChunkProperties simpleTransform; | 298 PaintChunkProperties simpleTransform; |
| 299 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 299 simpleTransform.transform = TransformPaintPropertyNode::create(nullptr, Tran
sformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
| 300 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | 300 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); |
| 301 | 301 |
| 302 chunker.incrementDisplayItemIndex(i1); | 302 chunker.incrementDisplayItemIndex(i1); |
| 303 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 303 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 304 chunker.incrementDisplayItemIndex(i2); | 304 chunker.incrementDisplayItemIndex(i2); |
| 305 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 305 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 306 | 306 |
| 307 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 307 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); |
| 308 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 308 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
| 309 | 309 |
| 310 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 310 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 311 EXPECT_THAT(chunks, ElementsAre( | 311 EXPECT_THAT(chunks, ElementsAre( |
| 312 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | 312 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), |
| 313 PaintChunk(2, 4, nullptr, simpleTransform), | 313 PaintChunk(2, 4, nullptr, simpleTransform), |
| 314 PaintChunk(4, 5, nullptr, simpleTransform), | 314 PaintChunk(4, 5, nullptr, simpleTransform), |
| 315 PaintChunk(5, 6, nullptr, simpleTransform), | 315 PaintChunk(5, 6, nullptr, simpleTransform), |
| 316 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | 316 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); |
| 317 } | 317 } |
| 318 | 318 |
| 319 #endif | 319 #endif |
| 320 | 320 |
| 321 } // namespace | 321 } // namespace |
| 322 } // namespace blink | 322 } // namespace blink |
| OLD | NEW |