Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp

Issue 2573883002: Refactor PaintChunkProperties to use PropertyTreeState (Closed)
Patch Set: none Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 702 {
703 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 703 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
704 PaintChunk::Id id(first, clipType); 704 PaintChunk::Id id(first, clipType);
705 PaintChunkProperties properties = defaultPaintChunkProperties(); 705 PaintChunkProperties properties = defaultPaintChunkProperties();
706 properties.clip = ClipPaintPropertyNode::create( 706 properties.propertyTreeState.setClip(
707 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); 707 ClipPaintPropertyNode::create(nullptr, nullptr,
708 FloatRoundedRect(1, 1, 2, 2))
709 .get());
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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));
762 { 764 {
763 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 765 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
764 PaintChunk::Id id(second, clipType); 766 PaintChunk::Id id(second, clipType);
765 PaintChunkProperties properties = defaultPaintChunkProperties(); 767 PaintChunkProperties properties = defaultPaintChunkProperties();
766 properties.clip = ClipPaintPropertyNode::create( 768 properties.propertyTreeState.setClip(
767 nullptr, nullptr, FloatRoundedRect(1, 1, 2, 2)); 769 ClipPaintPropertyNode::create(nullptr, nullptr,
770 FloatRoundedRect(1, 1, 2, 2))
771 .get());
768 getPaintController().updateCurrentPaintChunkProperties(&id, properties); 772 getPaintController().updateCurrentPaintChunkProperties(&id, properties);
769 } 773 }
770 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2)); 774 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2));
771 drawRect(context, second, backgroundDrawingType, 775 drawRect(context, second, backgroundDrawingType,
772 FloatRect(100, 100, 200, 200)); 776 FloatRect(100, 100, 200, 200));
773 } 777 }
774 getPaintController().commitNewDisplayItems(); 778 getPaintController().commitNewDisplayItems();
775 779
776 EXPECT_DISPLAY_LIST( 780 EXPECT_DISPLAY_LIST(
777 getPaintController().getDisplayItemList(), 4, 781 getPaintController().getDisplayItemList(), 4,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 LayoutRect(100, 200, 100, 100)); 1046 LayoutRect(100, 200, 100, 100));
1043 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1047 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1044 GraphicsContext context(getPaintController()); 1048 GraphicsContext context(getPaintController());
1045 1049
1046 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); 1050 PaintChunkProperties container1Properties = defaultPaintChunkProperties();
1047 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); 1051 PaintChunkProperties container2Properties = defaultPaintChunkProperties();
1048 1052
1049 { 1053 {
1050 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1054 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1051 PaintChunk::Id id(container1, backgroundDrawingType); 1055 PaintChunk::Id id(container1, backgroundDrawingType);
1052 container1Properties.effect = 1056 container1Properties.propertyTreeState.setEffect(
1053 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1057 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1054 getPaintController().updateCurrentPaintChunkProperties( 1058 getPaintController().updateCurrentPaintChunkProperties(
1055 &id, container1Properties); 1059 &id, container1Properties);
1056 } 1060 }
1057 SubsequenceRecorder r(context, container1); 1061 SubsequenceRecorder r(context, container1);
1058 drawRect(context, container1, backgroundDrawingType, 1062 drawRect(context, container1, backgroundDrawingType,
1059 FloatRect(100, 100, 100, 100)); 1063 FloatRect(100, 100, 100, 100));
1060 drawRect(context, content1, backgroundDrawingType, 1064 drawRect(context, content1, backgroundDrawingType,
1061 FloatRect(100, 100, 50, 200)); 1065 FloatRect(100, 100, 50, 200));
1062 drawRect(context, content1, foregroundDrawingType, 1066 drawRect(context, content1, foregroundDrawingType,
1063 FloatRect(100, 100, 50, 200)); 1067 FloatRect(100, 100, 50, 200));
1064 drawRect(context, container1, foregroundDrawingType, 1068 drawRect(context, container1, foregroundDrawingType,
1065 FloatRect(100, 100, 100, 100)); 1069 FloatRect(100, 100, 100, 100));
1066 } 1070 }
1067 { 1071 {
1068 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1072 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1069 PaintChunk::Id id(container2, backgroundDrawingType); 1073 PaintChunk::Id id(container2, backgroundDrawingType);
1070 container2Properties.effect = 1074 container2Properties.propertyTreeState.setEffect(
1071 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1075 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1072 getPaintController().updateCurrentPaintChunkProperties( 1076 getPaintController().updateCurrentPaintChunkProperties(
1073 &id, container2Properties); 1077 &id, container2Properties);
1074 } 1078 }
1075 SubsequenceRecorder r(context, container2); 1079 SubsequenceRecorder r(context, container2);
1076 drawRect(context, container2, backgroundDrawingType, 1080 drawRect(context, container2, backgroundDrawingType,
1077 FloatRect(100, 200, 100, 100)); 1081 FloatRect(100, 200, 100, 100));
1078 drawRect(context, content2, backgroundDrawingType, 1082 drawRect(context, content2, backgroundDrawingType,
1079 FloatRect(100, 200, 50, 200)); 1083 FloatRect(100, 200, 50, 200));
1080 drawRect(context, content2, foregroundDrawingType, 1084 drawRect(context, content2, foregroundDrawingType,
1081 FloatRect(100, 200, 50, 200)); 1085 FloatRect(100, 200, 50, 200));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 LayoutRect(100, 200, 100, 100)); 1216 LayoutRect(100, 200, 100, 100));
1213 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1217 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1214 GraphicsContext context(getPaintController()); 1218 GraphicsContext context(getPaintController());
1215 1219
1216 PaintChunkProperties container1Properties = defaultPaintChunkProperties(); 1220 PaintChunkProperties container1Properties = defaultPaintChunkProperties();
1217 PaintChunkProperties container2Properties = defaultPaintChunkProperties(); 1221 PaintChunkProperties container2Properties = defaultPaintChunkProperties();
1218 1222
1219 { 1223 {
1220 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1224 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1221 PaintChunk::Id id(container1, backgroundDrawingType); 1225 PaintChunk::Id id(container1, backgroundDrawingType);
1222 container1Properties.effect = 1226 container1Properties.propertyTreeState.setEffect(
1223 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1227 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1224 getPaintController().updateCurrentPaintChunkProperties( 1228 getPaintController().updateCurrentPaintChunkProperties(
1225 &id, container1Properties); 1229 &id, container1Properties);
1226 } 1230 }
1227 drawRect(context, container1, backgroundDrawingType, 1231 drawRect(context, container1, backgroundDrawingType,
1228 FloatRect(100, 100, 100, 100)); 1232 FloatRect(100, 100, 100, 100));
1229 drawRect(context, content1, backgroundDrawingType, 1233 drawRect(context, content1, backgroundDrawingType,
1230 FloatRect(100, 100, 50, 200)); 1234 FloatRect(100, 100, 50, 200));
1231 } 1235 }
1232 { 1236 {
1233 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1237 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1234 PaintChunk::Id id(container2, backgroundDrawingType); 1238 PaintChunk::Id id(container2, backgroundDrawingType);
1235 container2Properties.effect = 1239 container2Properties.propertyTreeState.setEffect(
1236 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1240 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1237 getPaintController().updateCurrentPaintChunkProperties( 1241 getPaintController().updateCurrentPaintChunkProperties(
1238 &id, container2Properties); 1242 &id, container2Properties);
1239 } 1243 }
1240 drawRect(context, container2, backgroundDrawingType, 1244 drawRect(context, container2, backgroundDrawingType,
1241 FloatRect(100, 200, 100, 100)); 1245 FloatRect(100, 200, 100, 100));
1242 drawRect(context, content2, backgroundDrawingType, 1246 drawRect(context, content2, backgroundDrawingType,
1243 FloatRect(100, 200, 50, 200)); 1247 FloatRect(100, 200, 50, 200));
1244 } 1248 }
1245 getPaintController().commitNewDisplayItems(); 1249 getPaintController().commitNewDisplayItems();
1246 1250
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 PaintChunkProperties content1Properties = defaultPaintChunkProperties(); 1364 PaintChunkProperties content1Properties = defaultPaintChunkProperties();
1361 PaintChunkProperties container1ForegroundProperties = 1365 PaintChunkProperties container1ForegroundProperties =
1362 defaultPaintChunkProperties(); 1366 defaultPaintChunkProperties();
1363 PaintChunkProperties container2BackgroundProperties = 1367 PaintChunkProperties container2BackgroundProperties =
1364 defaultPaintChunkProperties(); 1368 defaultPaintChunkProperties();
1365 PaintChunkProperties content2Properties = defaultPaintChunkProperties(); 1369 PaintChunkProperties content2Properties = defaultPaintChunkProperties();
1366 1370
1367 { 1371 {
1368 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1372 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1369 PaintChunk::Id id(container1, backgroundDrawingType); 1373 PaintChunk::Id id(container1, backgroundDrawingType);
1370 container1BackgroundProperties.effect = 1374 container1BackgroundProperties.propertyTreeState.setEffect(
1371 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1375 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1372 getPaintController().updateCurrentPaintChunkProperties( 1376 getPaintController().updateCurrentPaintChunkProperties(
1373 &id, container1BackgroundProperties); 1377 &id, container1BackgroundProperties);
1374 } 1378 }
1375 SubsequenceRecorder r(context, container1); 1379 SubsequenceRecorder r(context, container1);
1376 drawRect(context, container1, backgroundDrawingType, 1380 drawRect(context, container1, backgroundDrawingType,
1377 FloatRect(100, 100, 100, 100)); 1381 FloatRect(100, 100, 100, 100));
1378 { 1382 {
1379 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1383 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1380 PaintChunk::Id id(content1, backgroundDrawingType); 1384 PaintChunk::Id id(content1, backgroundDrawingType);
1381 content1Properties.effect = 1385 content1Properties.propertyTreeState.setEffect(
1382 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.6); 1386 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.6)
1387 .get());
1383 getPaintController().updateCurrentPaintChunkProperties( 1388 getPaintController().updateCurrentPaintChunkProperties(
1384 &id, content1Properties); 1389 &id, content1Properties);
1385 } 1390 }
1386 SubsequenceRecorder r(context, content1); 1391 SubsequenceRecorder r(context, content1);
1387 drawRect(context, content1, backgroundDrawingType, 1392 drawRect(context, content1, backgroundDrawingType,
1388 FloatRect(100, 100, 50, 200)); 1393 FloatRect(100, 100, 50, 200));
1389 drawRect(context, content1, foregroundDrawingType, 1394 drawRect(context, content1, foregroundDrawingType,
1390 FloatRect(100, 100, 50, 200)); 1395 FloatRect(100, 100, 50, 200));
1391 } 1396 }
1392 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1397 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1393 PaintChunk::Id id(container1, foregroundDrawingType); 1398 PaintChunk::Id id(container1, foregroundDrawingType);
1394 container1ForegroundProperties.effect = 1399 container1ForegroundProperties.propertyTreeState.setEffect(
1395 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); 1400 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5).get());
1396 getPaintController().updateCurrentPaintChunkProperties( 1401 getPaintController().updateCurrentPaintChunkProperties(
1397 &id, container1ForegroundProperties); 1402 &id, container1ForegroundProperties);
1398 } 1403 }
1399 drawRect(context, container1, foregroundDrawingType, 1404 drawRect(context, container1, foregroundDrawingType,
1400 FloatRect(100, 100, 100, 100)); 1405 FloatRect(100, 100, 100, 100));
1401 } 1406 }
1402 { 1407 {
1403 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1408 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1404 PaintChunk::Id id(container2, backgroundDrawingType); 1409 PaintChunk::Id id(container2, backgroundDrawingType);
1405 container2BackgroundProperties.effect = 1410 container2BackgroundProperties.propertyTreeState.setEffect(
1406 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.7); 1411 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.7).get());
1407 getPaintController().updateCurrentPaintChunkProperties( 1412 getPaintController().updateCurrentPaintChunkProperties(
1408 &id, container2BackgroundProperties); 1413 &id, container2BackgroundProperties);
1409 } 1414 }
1410 SubsequenceRecorder r(context, container2); 1415 SubsequenceRecorder r(context, container2);
1411 drawRect(context, container2, backgroundDrawingType, 1416 drawRect(context, container2, backgroundDrawingType,
1412 FloatRect(100, 200, 100, 100)); 1417 FloatRect(100, 200, 100, 100));
1413 { 1418 {
1414 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1419 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1415 PaintChunk::Id id(content2, backgroundDrawingType); 1420 PaintChunk::Id id(content2, backgroundDrawingType);
1416 content2Properties.effect = 1421 content2Properties.propertyTreeState.setEffect(
1417 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.8); 1422 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.8)
1423 .get());
1418 getPaintController().updateCurrentPaintChunkProperties( 1424 getPaintController().updateCurrentPaintChunkProperties(
1419 &id, content2Properties); 1425 &id, content2Properties);
1420 } 1426 }
1421 SubsequenceRecorder r(context, content2); 1427 SubsequenceRecorder r(context, content2);
1422 drawRect(context, content2, backgroundDrawingType, 1428 drawRect(context, content2, backgroundDrawingType,
1423 FloatRect(100, 200, 50, 200)); 1429 FloatRect(100, 200, 50, 200));
1424 } 1430 }
1425 } 1431 }
1426 getPaintController().commitNewDisplayItems(); 1432 getPaintController().commitNewDisplayItems();
1427 1433
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 } 2318 }
2313 2319
2314 TEST_F(PaintControllerUnderInvalidationTest, 2320 TEST_F(PaintControllerUnderInvalidationTest,
2315 FoldCompositingDrawingInSubsequence) { 2321 FoldCompositingDrawingInSubsequence) {
2316 testFoldCompositingDrawingInSubsequence(); 2322 testFoldCompositingDrawingInSubsequence();
2317 } 2323 }
2318 2324
2319 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2325 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2320 2326
2321 } // namespace blink 2327 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698