| 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" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 FloatRect(200, 200, 50, | 692 FloatRect(200, 200, 50, |
| 693 50))); // |second| disappeared from the chunk. | 693 50))); // |second| disappeared from the chunk. |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 TEST_P(PaintControllerTest, UpdateClip) { | 697 TEST_P(PaintControllerTest, UpdateClip) { |
| 698 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); | 698 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); |
| 699 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); | 699 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); |
| 700 GraphicsContext context(getPaintController()); | 700 GraphicsContext context(getPaintController()); |
| 701 | 701 |
| 702 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 703 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); |
| 704 |
| 702 { | 705 { |
| 703 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 706 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 704 PaintChunk::Id id(first, clipType); | 707 PaintChunk::Id id(first, clipType); |
| 705 PaintChunkProperties properties = defaultPaintChunkProperties(); | 708 PaintChunkProperties properties = defaultPaintChunkProperties(); |
| 706 properties.clip = ClipPaintPropertyNode::create( | 709 properties.propertyTreeState.setClip(clip.get()); |
| 707 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); | |
| 708 getPaintController().updateCurrentPaintChunkProperties(&id, properties); | 710 getPaintController().updateCurrentPaintChunkProperties(&id, properties); |
| 709 } | 711 } |
| 710 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)); | 712 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)); |
| 711 drawRect(context, first, backgroundDrawingType, | 713 drawRect(context, first, backgroundDrawingType, |
| 712 FloatRect(100, 100, 150, 150)); | 714 FloatRect(100, 100, 150, 150)); |
| 713 drawRect(context, second, backgroundDrawingType, | 715 drawRect(context, second, backgroundDrawingType, |
| 714 FloatRect(100, 100, 200, 200)); | 716 FloatRect(100, 100, 200, 200)); |
| 715 } | 717 } |
| 716 getPaintController().commitNewDisplayItems(); | 718 getPaintController().commitNewDisplayItems(); |
| 717 | 719 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 UnorderedElementsAre(FloatRect( | 754 UnorderedElementsAre(FloatRect( |
| 753 LayoutRect::infiniteIntRect()))); // This is a new chunk. | 755 LayoutRect::infiniteIntRect()))); // This is a new chunk. |
| 754 | 756 |
| 755 getPaintController().updateCurrentPaintChunkProperties( | 757 getPaintController().updateCurrentPaintChunkProperties( |
| 756 &m_rootPaintChunkId, defaultPaintChunkProperties()); | 758 &m_rootPaintChunkId, defaultPaintChunkProperties()); |
| 757 } | 759 } |
| 758 | 760 |
| 759 second.setDisplayItemsUncached(); | 761 second.setDisplayItemsUncached(); |
| 760 drawRect(context, first, backgroundDrawingType, | 762 drawRect(context, first, backgroundDrawingType, |
| 761 FloatRect(100, 100, 150, 150)); | 763 FloatRect(100, 100, 150, 150)); |
| 764 |
| 765 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 766 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); |
| 767 |
| 762 { | 768 { |
| 763 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 769 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 764 PaintChunk::Id id(second, clipType); | 770 PaintChunk::Id id(second, clipType); |
| 765 PaintChunkProperties properties = defaultPaintChunkProperties(); | 771 PaintChunkProperties properties = defaultPaintChunkProperties(); |
| 766 properties.clip = ClipPaintPropertyNode::create( | 772 properties.propertyTreeState.setClip(clip2.get()); |
| 767 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); | 773 |
| 768 getPaintController().updateCurrentPaintChunkProperties(&id, properties); | 774 getPaintController().updateCurrentPaintChunkProperties(&id, properties); |
| 769 } | 775 } |
| 770 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)); | 776 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)); |
| 771 drawRect(context, second, backgroundDrawingType, | 777 drawRect(context, second, backgroundDrawingType, |
| 772 FloatRect(100, 100, 200, 200)); | 778 FloatRect(100, 100, 200, 200)); |
| 773 } | 779 } |
| 774 getPaintController().commitNewDisplayItems(); | 780 getPaintController().commitNewDisplayItems(); |
| 775 | 781 |
| 776 EXPECT_DISPLAY_LIST( | 782 EXPECT_DISPLAY_LIST( |
| 777 getPaintController().getDisplayItemList(), 4, | 783 getPaintController().getDisplayItemList(), 4, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 LayoutRect(100, 200, 100, 100)); | 1048 LayoutRect(100, 200, 100, 100)); |
| 1043 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 1049 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 1044 GraphicsContext context(getPaintController()); | 1050 GraphicsContext context(getPaintController()); |
| 1045 | 1051 |
| 1046 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); | 1052 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); |
| 1047 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); | 1053 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); |
| 1048 | 1054 |
| 1049 { | 1055 { |
| 1050 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1056 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1051 PaintChunk::Id id(container1, backgroundDrawingType); | 1057 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1052 container1Properties.effect = | 1058 container1Properties.propertyTreeState.setEffect( |
| 1053 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1059 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1054 getPaintController().updateCurrentPaintChunkProperties( | 1060 getPaintController().updateCurrentPaintChunkProperties( |
| 1055 &id, container1Properties); | 1061 &id, container1Properties); |
| 1056 } | 1062 } |
| 1057 SubsequenceRecorder r(context, container1); | 1063 SubsequenceRecorder r(context, container1); |
| 1058 drawRect(context, container1, backgroundDrawingType, | 1064 drawRect(context, container1, backgroundDrawingType, |
| 1059 FloatRect(100, 100, 100, 100)); | 1065 FloatRect(100, 100, 100, 100)); |
| 1060 drawRect(context, content1, backgroundDrawingType, | 1066 drawRect(context, content1, backgroundDrawingType, |
| 1061 FloatRect(100, 100, 50, 200)); | 1067 FloatRect(100, 100, 50, 200)); |
| 1062 drawRect(context, content1, foregroundDrawingType, | 1068 drawRect(context, content1, foregroundDrawingType, |
| 1063 FloatRect(100, 100, 50, 200)); | 1069 FloatRect(100, 100, 50, 200)); |
| 1064 drawRect(context, container1, foregroundDrawingType, | 1070 drawRect(context, container1, foregroundDrawingType, |
| 1065 FloatRect(100, 100, 100, 100)); | 1071 FloatRect(100, 100, 100, 100)); |
| 1066 } | 1072 } |
| 1067 { | 1073 { |
| 1068 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1074 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1069 PaintChunk::Id id(container2, backgroundDrawingType); | 1075 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1070 container2Properties.effect = | 1076 container2Properties.propertyTreeState.setEffect( |
| 1071 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1077 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1072 getPaintController().updateCurrentPaintChunkProperties( | 1078 getPaintController().updateCurrentPaintChunkProperties( |
| 1073 &id, container2Properties); | 1079 &id, container2Properties); |
| 1074 } | 1080 } |
| 1075 SubsequenceRecorder r(context, container2); | 1081 SubsequenceRecorder r(context, container2); |
| 1076 drawRect(context, container2, backgroundDrawingType, | 1082 drawRect(context, container2, backgroundDrawingType, |
| 1077 FloatRect(100, 200, 100, 100)); | 1083 FloatRect(100, 200, 100, 100)); |
| 1078 drawRect(context, content2, backgroundDrawingType, | 1084 drawRect(context, content2, backgroundDrawingType, |
| 1079 FloatRect(100, 200, 50, 200)); | 1085 FloatRect(100, 200, 50, 200)); |
| 1080 drawRect(context, content2, foregroundDrawingType, | 1086 drawRect(context, content2, foregroundDrawingType, |
| 1081 FloatRect(100, 200, 50, 200)); | 1087 FloatRect(100, 200, 50, 200)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 LayoutRect(100, 200, 100, 100)); | 1218 LayoutRect(100, 200, 100, 100)); |
| 1213 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 1219 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 1214 GraphicsContext context(getPaintController()); | 1220 GraphicsContext context(getPaintController()); |
| 1215 | 1221 |
| 1216 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); | 1222 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); |
| 1217 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); | 1223 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); |
| 1218 | 1224 |
| 1219 { | 1225 { |
| 1220 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1226 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1221 PaintChunk::Id id(container1, backgroundDrawingType); | 1227 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1222 container1Properties.effect = | 1228 container1Properties.propertyTreeState.setEffect( |
| 1223 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1229 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1224 getPaintController().updateCurrentPaintChunkProperties( | 1230 getPaintController().updateCurrentPaintChunkProperties( |
| 1225 &id, container1Properties); | 1231 &id, container1Properties); |
| 1226 } | 1232 } |
| 1227 drawRect(context, container1, backgroundDrawingType, | 1233 drawRect(context, container1, backgroundDrawingType, |
| 1228 FloatRect(100, 100, 100, 100)); | 1234 FloatRect(100, 100, 100, 100)); |
| 1229 drawRect(context, content1, backgroundDrawingType, | 1235 drawRect(context, content1, backgroundDrawingType, |
| 1230 FloatRect(100, 100, 50, 200)); | 1236 FloatRect(100, 100, 50, 200)); |
| 1231 } | 1237 } |
| 1232 { | 1238 { |
| 1233 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1239 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1234 PaintChunk::Id id(container2, backgroundDrawingType); | 1240 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1235 container2Properties.effect = | 1241 container2Properties.propertyTreeState.setEffect( |
| 1236 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1242 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1237 getPaintController().updateCurrentPaintChunkProperties( | 1243 getPaintController().updateCurrentPaintChunkProperties( |
| 1238 &id, container2Properties); | 1244 &id, container2Properties); |
| 1239 } | 1245 } |
| 1240 drawRect(context, container2, backgroundDrawingType, | 1246 drawRect(context, container2, backgroundDrawingType, |
| 1241 FloatRect(100, 200, 100, 100)); | 1247 FloatRect(100, 200, 100, 100)); |
| 1242 drawRect(context, content2, backgroundDrawingType, | 1248 drawRect(context, content2, backgroundDrawingType, |
| 1243 FloatRect(100, 200, 50, 200)); | 1249 FloatRect(100, 200, 50, 200)); |
| 1244 } | 1250 } |
| 1245 getPaintController().commitNewDisplayItems(); | 1251 getPaintController().commitNewDisplayItems(); |
| 1246 | 1252 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 PaintChunkProperties content1Properties = defaultPaintChunkProperties(); | 1366 PaintChunkProperties content1Properties = defaultPaintChunkProperties(); |
| 1361 PaintChunkProperties container1ForegroundProperties = | 1367 PaintChunkProperties container1ForegroundProperties = |
| 1362 defaultPaintChunkProperties(); | 1368 defaultPaintChunkProperties(); |
| 1363 PaintChunkProperties container2BackgroundProperties = | 1369 PaintChunkProperties container2BackgroundProperties = |
| 1364 defaultPaintChunkProperties(); | 1370 defaultPaintChunkProperties(); |
| 1365 PaintChunkProperties content2Properties = defaultPaintChunkProperties(); | 1371 PaintChunkProperties content2Properties = defaultPaintChunkProperties(); |
| 1366 | 1372 |
| 1367 { | 1373 { |
| 1368 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1374 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1369 PaintChunk::Id id(container1, backgroundDrawingType); | 1375 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1370 container1BackgroundProperties.effect = | 1376 container1BackgroundProperties.propertyTreeState.setEffect( |
| 1371 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1377 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1372 getPaintController().updateCurrentPaintChunkProperties( | 1378 getPaintController().updateCurrentPaintChunkProperties( |
| 1373 &id, container1BackgroundProperties); | 1379 &id, container1BackgroundProperties); |
| 1374 } | 1380 } |
| 1375 SubsequenceRecorder r(context, container1); | 1381 SubsequenceRecorder r(context, container1); |
| 1376 drawRect(context, container1, backgroundDrawingType, | 1382 drawRect(context, container1, backgroundDrawingType, |
| 1377 FloatRect(100, 100, 100, 100)); | 1383 FloatRect(100, 100, 100, 100)); |
| 1378 { | 1384 { |
| 1379 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1385 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1380 PaintChunk::Id id(content1, backgroundDrawingType); | 1386 PaintChunk::Id id(content1, backgroundDrawingType); |
| 1381 content1Properties.effect = | 1387 content1Properties.propertyTreeState.setEffect( |
| 1382 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.6); | 1388 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.6) |
| 1389 .get()); |
| 1383 getPaintController().updateCurrentPaintChunkProperties( | 1390 getPaintController().updateCurrentPaintChunkProperties( |
| 1384 &id, content1Properties); | 1391 &id, content1Properties); |
| 1385 } | 1392 } |
| 1386 SubsequenceRecorder r(context, content1); | 1393 SubsequenceRecorder r(context, content1); |
| 1387 drawRect(context, content1, backgroundDrawingType, | 1394 drawRect(context, content1, backgroundDrawingType, |
| 1388 FloatRect(100, 100, 50, 200)); | 1395 FloatRect(100, 100, 50, 200)); |
| 1389 drawRect(context, content1, foregroundDrawingType, | 1396 drawRect(context, content1, foregroundDrawingType, |
| 1390 FloatRect(100, 100, 50, 200)); | 1397 FloatRect(100, 100, 50, 200)); |
| 1391 } | 1398 } |
| 1392 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1399 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1393 PaintChunk::Id id(container1, foregroundDrawingType); | 1400 PaintChunk::Id id(container1, foregroundDrawingType); |
| 1394 container1ForegroundProperties.effect = | 1401 container1ForegroundProperties.propertyTreeState.setEffect( |
| 1395 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 1402 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get()); |
| 1396 getPaintController().updateCurrentPaintChunkProperties( | 1403 getPaintController().updateCurrentPaintChunkProperties( |
| 1397 &id, container1ForegroundProperties); | 1404 &id, container1ForegroundProperties); |
| 1398 } | 1405 } |
| 1399 drawRect(context, container1, foregroundDrawingType, | 1406 drawRect(context, container1, foregroundDrawingType, |
| 1400 FloatRect(100, 100, 100, 100)); | 1407 FloatRect(100, 100, 100, 100)); |
| 1401 } | 1408 } |
| 1402 { | 1409 { |
| 1403 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1410 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1404 PaintChunk::Id id(container2, backgroundDrawingType); | 1411 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1405 container2BackgroundProperties.effect = | 1412 container2BackgroundProperties.propertyTreeState.setEffect( |
| 1406 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.7); | 1413 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.7).get()); |
| 1407 getPaintController().updateCurrentPaintChunkProperties( | 1414 getPaintController().updateCurrentPaintChunkProperties( |
| 1408 &id, container2BackgroundProperties); | 1415 &id, container2BackgroundProperties); |
| 1409 } | 1416 } |
| 1410 SubsequenceRecorder r(context, container2); | 1417 SubsequenceRecorder r(context, container2); |
| 1411 drawRect(context, container2, backgroundDrawingType, | 1418 drawRect(context, container2, backgroundDrawingType, |
| 1412 FloatRect(100, 200, 100, 100)); | 1419 FloatRect(100, 200, 100, 100)); |
| 1413 { | 1420 { |
| 1414 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1421 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1415 PaintChunk::Id id(content2, backgroundDrawingType); | 1422 PaintChunk::Id id(content2, backgroundDrawingType); |
| 1416 content2Properties.effect = | 1423 content2Properties.propertyTreeState.setEffect( |
| 1417 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.8); | 1424 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.8) |
| 1425 .get()); |
| 1418 getPaintController().updateCurrentPaintChunkProperties( | 1426 getPaintController().updateCurrentPaintChunkProperties( |
| 1419 &id, content2Properties); | 1427 &id, content2Properties); |
| 1420 } | 1428 } |
| 1421 SubsequenceRecorder r(context, content2); | 1429 SubsequenceRecorder r(context, content2); |
| 1422 drawRect(context, content2, backgroundDrawingType, | 1430 drawRect(context, content2, backgroundDrawingType, |
| 1423 FloatRect(100, 200, 50, 200)); | 1431 FloatRect(100, 200, 50, 200)); |
| 1424 } | 1432 } |
| 1425 } | 1433 } |
| 1426 getPaintController().commitNewDisplayItems(); | 1434 getPaintController().commitNewDisplayItems(); |
| 1427 | 1435 |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 } | 2320 } |
| 2313 | 2321 |
| 2314 TEST_F(PaintControllerUnderInvalidationTest, | 2322 TEST_F(PaintControllerUnderInvalidationTest, |
| 2315 FoldCompositingDrawingInSubsequence) { | 2323 FoldCompositingDrawingInSubsequence) { |
| 2316 testFoldCompositingDrawingInSubsequence(); | 2324 testFoldCompositingDrawingInSubsequence(); |
| 2317 } | 2325 } |
| 2318 | 2326 |
| 2319 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2327 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 2320 | 2328 |
| 2321 } // namespace blink | 2329 } // namespace blink |
| OLD | NEW |