| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| 10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 11 #include "platform/graphics/paint/ClipRecorder.h" | 11 #include "platform/graphics/paint/ClipRecorder.h" |
| 12 #include "platform/graphics/paint/CompositingRecorder.h" | 12 #include "platform/graphics/paint/CompositingRecorder.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 14 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
| 15 #include "platform/graphics/paint/SubsequenceRecorder.h" | 15 #include "platform/graphics/paint/SubsequenceRecorder.h" |
| 16 #include "platform/testing/FakeDisplayItemClient.h" | 16 #include "platform/testing/FakeDisplayItemClient.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 using testing::UnorderedElementsAre; | 21 using testing::UnorderedElementsAre; |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 namespace { |
| 26 TransformPaintPropertyNode* dummyRootTransform() { |
| 27 DEFINE_STATIC_REF(TransformPaintPropertyNode, rootTransform, |
| 28 (TransformPaintPropertyNode::create( |
| 29 nullptr, TransformationMatrix(), FloatPoint3D()))); |
| 30 return rootTransform; |
| 31 } |
| 32 |
| 33 ClipPaintPropertyNode* dummyRootClip() { |
| 34 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, |
| 35 (ClipPaintPropertyNode::create( |
| 36 nullptr, dummyRootTransform(), |
| 37 FloatRoundedRect(LayoutRect::infiniteIntRect())))); |
| 38 return rootClip; |
| 39 } |
| 40 |
| 41 EffectPaintPropertyNode* dummyRootEffect() { |
| 42 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, |
| 43 (EffectPaintPropertyNode::create( |
| 44 nullptr, dummyRootTransform(), dummyRootClip(), |
| 45 CompositorFilterOperations(), 1.0))); |
| 46 return rootEffect; |
| 47 } |
| 48 } // namespace |
| 49 |
| 25 class PaintControllerTestBase : public testing::Test { | 50 class PaintControllerTestBase : public testing::Test { |
| 26 public: | 51 public: |
| 27 PaintControllerTestBase() : m_paintController(PaintController::create()) {} | 52 PaintControllerTestBase() : m_paintController(PaintController::create()) {} |
| 28 | 53 |
| 29 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) { | 54 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) { |
| 30 return paintArtifact.getDisplayItemList().visualRect(index); | 55 return paintArtifact.getDisplayItemList().visualRect(index); |
| 31 } | 56 } |
| 32 | 57 |
| 33 protected: | 58 protected: |
| 34 PaintController& getPaintController() { return *m_paintController; } | 59 PaintController& getPaintController() { return *m_paintController; } |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 LayoutRect(100, 200, 100, 100)); | 1037 LayoutRect(100, 200, 100, 100)); |
| 1013 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 1038 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 1014 GraphicsContext context(getPaintController()); | 1039 GraphicsContext context(getPaintController()); |
| 1015 | 1040 |
| 1016 PaintChunkProperties container1Properties; | 1041 PaintChunkProperties container1Properties; |
| 1017 PaintChunkProperties container2Properties; | 1042 PaintChunkProperties container2Properties; |
| 1018 | 1043 |
| 1019 { | 1044 { |
| 1020 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1045 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1021 PaintChunk::Id id(container1, backgroundDrawingType); | 1046 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1022 container1Properties.effect = | 1047 container1Properties.effect = EffectPaintPropertyNode::create( |
| 1023 EffectPaintPropertyNode::create(nullptr, 0.5); | 1048 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1049 CompositorFilterOperations(), 0.5); |
| 1024 getPaintController().updateCurrentPaintChunkProperties( | 1050 getPaintController().updateCurrentPaintChunkProperties( |
| 1025 &id, container1Properties); | 1051 &id, container1Properties); |
| 1026 } | 1052 } |
| 1027 SubsequenceRecorder r(context, container1); | 1053 SubsequenceRecorder r(context, container1); |
| 1028 drawRect(context, container1, backgroundDrawingType, | 1054 drawRect(context, container1, backgroundDrawingType, |
| 1029 FloatRect(100, 100, 100, 100)); | 1055 FloatRect(100, 100, 100, 100)); |
| 1030 drawRect(context, content1, backgroundDrawingType, | 1056 drawRect(context, content1, backgroundDrawingType, |
| 1031 FloatRect(100, 100, 50, 200)); | 1057 FloatRect(100, 100, 50, 200)); |
| 1032 drawRect(context, content1, foregroundDrawingType, | 1058 drawRect(context, content1, foregroundDrawingType, |
| 1033 FloatRect(100, 100, 50, 200)); | 1059 FloatRect(100, 100, 50, 200)); |
| 1034 drawRect(context, container1, foregroundDrawingType, | 1060 drawRect(context, container1, foregroundDrawingType, |
| 1035 FloatRect(100, 100, 100, 100)); | 1061 FloatRect(100, 100, 100, 100)); |
| 1036 } | 1062 } |
| 1037 { | 1063 { |
| 1038 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1064 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1039 PaintChunk::Id id(container2, backgroundDrawingType); | 1065 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1040 container2Properties.effect = | 1066 container2Properties.effect = EffectPaintPropertyNode::create( |
| 1041 EffectPaintPropertyNode::create(nullptr, 0.5); | 1067 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1068 CompositorFilterOperations(), 0.5); |
| 1042 getPaintController().updateCurrentPaintChunkProperties( | 1069 getPaintController().updateCurrentPaintChunkProperties( |
| 1043 &id, container2Properties); | 1070 &id, container2Properties); |
| 1044 } | 1071 } |
| 1045 SubsequenceRecorder r(context, container2); | 1072 SubsequenceRecorder r(context, container2); |
| 1046 drawRect(context, container2, backgroundDrawingType, | 1073 drawRect(context, container2, backgroundDrawingType, |
| 1047 FloatRect(100, 200, 100, 100)); | 1074 FloatRect(100, 200, 100, 100)); |
| 1048 drawRect(context, content2, backgroundDrawingType, | 1075 drawRect(context, content2, backgroundDrawingType, |
| 1049 FloatRect(100, 200, 50, 200)); | 1076 FloatRect(100, 200, 50, 200)); |
| 1050 drawRect(context, content2, foregroundDrawingType, | 1077 drawRect(context, content2, foregroundDrawingType, |
| 1051 FloatRect(100, 200, 50, 200)); | 1078 FloatRect(100, 200, 50, 200)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 LayoutRect(100, 200, 100, 100)); | 1209 LayoutRect(100, 200, 100, 100)); |
| 1183 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 1210 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 1184 GraphicsContext context(getPaintController()); | 1211 GraphicsContext context(getPaintController()); |
| 1185 | 1212 |
| 1186 PaintChunkProperties container1Properties; | 1213 PaintChunkProperties container1Properties; |
| 1187 PaintChunkProperties container2Properties; | 1214 PaintChunkProperties container2Properties; |
| 1188 | 1215 |
| 1189 { | 1216 { |
| 1190 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1217 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1191 PaintChunk::Id id(container1, backgroundDrawingType); | 1218 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1192 container1Properties.effect = | 1219 container1Properties.effect = EffectPaintPropertyNode::create( |
| 1193 EffectPaintPropertyNode::create(nullptr, 0.5); | 1220 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1221 CompositorFilterOperations(), 0.5); |
| 1194 getPaintController().updateCurrentPaintChunkProperties( | 1222 getPaintController().updateCurrentPaintChunkProperties( |
| 1195 &id, container1Properties); | 1223 &id, container1Properties); |
| 1196 } | 1224 } |
| 1197 drawRect(context, container1, backgroundDrawingType, | 1225 drawRect(context, container1, backgroundDrawingType, |
| 1198 FloatRect(100, 100, 100, 100)); | 1226 FloatRect(100, 100, 100, 100)); |
| 1199 drawRect(context, content1, backgroundDrawingType, | 1227 drawRect(context, content1, backgroundDrawingType, |
| 1200 FloatRect(100, 100, 50, 200)); | 1228 FloatRect(100, 100, 50, 200)); |
| 1201 } | 1229 } |
| 1202 { | 1230 { |
| 1203 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1231 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1204 PaintChunk::Id id(container2, backgroundDrawingType); | 1232 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1205 container2Properties.effect = | 1233 container2Properties.effect = EffectPaintPropertyNode::create( |
| 1206 EffectPaintPropertyNode::create(nullptr, 0.5); | 1234 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1235 CompositorFilterOperations(), 0.5); |
| 1207 getPaintController().updateCurrentPaintChunkProperties( | 1236 getPaintController().updateCurrentPaintChunkProperties( |
| 1208 &id, container2Properties); | 1237 &id, container2Properties); |
| 1209 } | 1238 } |
| 1210 drawRect(context, container2, backgroundDrawingType, | 1239 drawRect(context, container2, backgroundDrawingType, |
| 1211 FloatRect(100, 200, 100, 100)); | 1240 FloatRect(100, 200, 100, 100)); |
| 1212 drawRect(context, content2, backgroundDrawingType, | 1241 drawRect(context, content2, backgroundDrawingType, |
| 1213 FloatRect(100, 200, 50, 200)); | 1242 FloatRect(100, 200, 50, 200)); |
| 1214 } | 1243 } |
| 1215 getPaintController().commitNewDisplayItems(); | 1244 getPaintController().commitNewDisplayItems(); |
| 1216 | 1245 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 | 1348 |
| 1320 PaintChunkProperties container1BackgroundProperties; | 1349 PaintChunkProperties container1BackgroundProperties; |
| 1321 PaintChunkProperties content1Properties; | 1350 PaintChunkProperties content1Properties; |
| 1322 PaintChunkProperties container1ForegroundProperties; | 1351 PaintChunkProperties container1ForegroundProperties; |
| 1323 PaintChunkProperties container2BackgroundProperties; | 1352 PaintChunkProperties container2BackgroundProperties; |
| 1324 PaintChunkProperties content2Properties; | 1353 PaintChunkProperties content2Properties; |
| 1325 | 1354 |
| 1326 { | 1355 { |
| 1327 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1356 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1328 PaintChunk::Id id(container1, backgroundDrawingType); | 1357 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1329 container1BackgroundProperties.effect = | 1358 container1BackgroundProperties.effect = EffectPaintPropertyNode::create( |
| 1330 EffectPaintPropertyNode::create(nullptr, 0.5); | 1359 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1360 CompositorFilterOperations(), 0.5); |
| 1331 getPaintController().updateCurrentPaintChunkProperties( | 1361 getPaintController().updateCurrentPaintChunkProperties( |
| 1332 &id, container1BackgroundProperties); | 1362 &id, container1BackgroundProperties); |
| 1333 } | 1363 } |
| 1334 SubsequenceRecorder r(context, container1); | 1364 SubsequenceRecorder r(context, container1); |
| 1335 drawRect(context, container1, backgroundDrawingType, | 1365 drawRect(context, container1, backgroundDrawingType, |
| 1336 FloatRect(100, 100, 100, 100)); | 1366 FloatRect(100, 100, 100, 100)); |
| 1337 { | 1367 { |
| 1338 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1368 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1339 PaintChunk::Id id(content1, backgroundDrawingType); | 1369 PaintChunk::Id id(content1, backgroundDrawingType); |
| 1340 content1Properties.effect = | 1370 content1Properties.effect = EffectPaintPropertyNode::create( |
| 1341 EffectPaintPropertyNode::create(nullptr, 0.6); | 1371 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1372 CompositorFilterOperations(), 0.6); |
| 1342 getPaintController().updateCurrentPaintChunkProperties( | 1373 getPaintController().updateCurrentPaintChunkProperties( |
| 1343 &id, content1Properties); | 1374 &id, content1Properties); |
| 1344 } | 1375 } |
| 1345 SubsequenceRecorder r(context, content1); | 1376 SubsequenceRecorder r(context, content1); |
| 1346 drawRect(context, content1, backgroundDrawingType, | 1377 drawRect(context, content1, backgroundDrawingType, |
| 1347 FloatRect(100, 100, 50, 200)); | 1378 FloatRect(100, 100, 50, 200)); |
| 1348 drawRect(context, content1, foregroundDrawingType, | 1379 drawRect(context, content1, foregroundDrawingType, |
| 1349 FloatRect(100, 100, 50, 200)); | 1380 FloatRect(100, 100, 50, 200)); |
| 1350 } | 1381 } |
| 1351 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1382 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1352 PaintChunk::Id id(container1, foregroundDrawingType); | 1383 PaintChunk::Id id(container1, foregroundDrawingType); |
| 1353 container1ForegroundProperties.effect = | 1384 container1ForegroundProperties.effect = EffectPaintPropertyNode::create( |
| 1354 EffectPaintPropertyNode::create(nullptr, 0.5); | 1385 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1386 CompositorFilterOperations(), 0.5); |
| 1355 getPaintController().updateCurrentPaintChunkProperties( | 1387 getPaintController().updateCurrentPaintChunkProperties( |
| 1356 &id, container1ForegroundProperties); | 1388 &id, container1ForegroundProperties); |
| 1357 } | 1389 } |
| 1358 drawRect(context, container1, foregroundDrawingType, | 1390 drawRect(context, container1, foregroundDrawingType, |
| 1359 FloatRect(100, 100, 100, 100)); | 1391 FloatRect(100, 100, 100, 100)); |
| 1360 } | 1392 } |
| 1361 { | 1393 { |
| 1362 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1394 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1363 PaintChunk::Id id(container2, backgroundDrawingType); | 1395 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1364 container2BackgroundProperties.effect = | 1396 container2BackgroundProperties.effect = EffectPaintPropertyNode::create( |
| 1365 EffectPaintPropertyNode::create(nullptr, 0.7); | 1397 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1398 CompositorFilterOperations(), 0.7); |
| 1366 getPaintController().updateCurrentPaintChunkProperties( | 1399 getPaintController().updateCurrentPaintChunkProperties( |
| 1367 &id, container2BackgroundProperties); | 1400 &id, container2BackgroundProperties); |
| 1368 } | 1401 } |
| 1369 SubsequenceRecorder r(context, container2); | 1402 SubsequenceRecorder r(context, container2); |
| 1370 drawRect(context, container2, backgroundDrawingType, | 1403 drawRect(context, container2, backgroundDrawingType, |
| 1371 FloatRect(100, 200, 100, 100)); | 1404 FloatRect(100, 200, 100, 100)); |
| 1372 { | 1405 { |
| 1373 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1406 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1374 PaintChunk::Id id(content2, backgroundDrawingType); | 1407 PaintChunk::Id id(content2, backgroundDrawingType); |
| 1375 content2Properties.effect = | 1408 content2Properties.effect = EffectPaintPropertyNode::create( |
| 1376 EffectPaintPropertyNode::create(nullptr, 0.8); | 1409 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 1410 CompositorFilterOperations(), 0.8); |
| 1377 getPaintController().updateCurrentPaintChunkProperties( | 1411 getPaintController().updateCurrentPaintChunkProperties( |
| 1378 &id, content2Properties); | 1412 &id, content2Properties); |
| 1379 } | 1413 } |
| 1380 SubsequenceRecorder r(context, content2); | 1414 SubsequenceRecorder r(context, content2); |
| 1381 drawRect(context, content2, backgroundDrawingType, | 1415 drawRect(context, content2, backgroundDrawingType, |
| 1382 FloatRect(100, 200, 50, 200)); | 1416 FloatRect(100, 200, 50, 200)); |
| 1383 } | 1417 } |
| 1384 } | 1418 } |
| 1385 getPaintController().commitNewDisplayItems(); | 1419 getPaintController().commitNewDisplayItems(); |
| 1386 | 1420 |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 } | 2294 } |
| 2261 | 2295 |
| 2262 TEST_F(PaintControllerUnderInvalidationTest, | 2296 TEST_F(PaintControllerUnderInvalidationTest, |
| 2263 FoldCompositingDrawingInSubsequence) { | 2297 FoldCompositingDrawingInSubsequence) { |
| 2264 testFoldCompositingDrawingInSubsequence(); | 2298 testFoldCompositingDrawingInSubsequence(); |
| 2265 } | 2299 } |
| 2266 | 2300 |
| 2267 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2301 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 2268 | 2302 |
| 2269 } // namespace blink | 2303 } // namespace blink |
| OLD | NEW |