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

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

Issue 2428513004: [SPv2] Create effect nodes for CSS filter (Closed)
Patch Set: Created 4 years, 2 months 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"
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(nullptr, dummyRootTransform (), dummyRootClip(), 1.0, CompositorFilterOperations())));
44 return rootEffect;
45 }
46 } // namespace
47
25 class PaintControllerTestBase : public testing::Test { 48 class PaintControllerTestBase : public testing::Test {
26 public: 49 public:
27 PaintControllerTestBase() : m_paintController(PaintController::create()) {} 50 PaintControllerTestBase() : m_paintController(PaintController::create()) {}
28 51
29 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) { 52 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) {
30 return paintArtifact.getDisplayItemList().visualRect(index); 53 return paintArtifact.getDisplayItemList().visualRect(index);
31 } 54 }
32 55
33 protected: 56 protected:
34 PaintController& getPaintController() { return *m_paintController; } 57 PaintController& getPaintController() { return *m_paintController; }
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1036 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1014 GraphicsContext context(getPaintController()); 1037 GraphicsContext context(getPaintController());
1015 1038
1016 PaintChunkProperties container1Properties; 1039 PaintChunkProperties container1Properties;
1017 PaintChunkProperties container2Properties; 1040 PaintChunkProperties container2Properties;
1018 1041
1019 { 1042 {
1020 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1043 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1021 PaintChunk::Id id(container1, backgroundDrawingType); 1044 PaintChunk::Id id(container1, backgroundDrawingType);
1022 container1Properties.effect = 1045 container1Properties.effect =
1023 EffectPaintPropertyNode::create(nullptr, 0.5); 1046 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1024 getPaintController().updateCurrentPaintChunkProperties( 1047 getPaintController().updateCurrentPaintChunkProperties(
1025 &id, container1Properties); 1048 &id, container1Properties);
1026 } 1049 }
1027 SubsequenceRecorder r(context, container1); 1050 SubsequenceRecorder r(context, container1);
1028 drawRect(context, container1, backgroundDrawingType, 1051 drawRect(context, container1, backgroundDrawingType,
1029 FloatRect(100, 100, 100, 100)); 1052 FloatRect(100, 100, 100, 100));
1030 drawRect(context, content1, backgroundDrawingType, 1053 drawRect(context, content1, backgroundDrawingType,
1031 FloatRect(100, 100, 50, 200)); 1054 FloatRect(100, 100, 50, 200));
1032 drawRect(context, content1, foregroundDrawingType, 1055 drawRect(context, content1, foregroundDrawingType,
1033 FloatRect(100, 100, 50, 200)); 1056 FloatRect(100, 100, 50, 200));
1034 drawRect(context, container1, foregroundDrawingType, 1057 drawRect(context, container1, foregroundDrawingType,
1035 FloatRect(100, 100, 100, 100)); 1058 FloatRect(100, 100, 100, 100));
1036 } 1059 }
1037 { 1060 {
1038 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1061 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1039 PaintChunk::Id id(container2, backgroundDrawingType); 1062 PaintChunk::Id id(container2, backgroundDrawingType);
1040 container2Properties.effect = 1063 container2Properties.effect =
1041 EffectPaintPropertyNode::create(nullptr, 0.5); 1064 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1042 getPaintController().updateCurrentPaintChunkProperties( 1065 getPaintController().updateCurrentPaintChunkProperties(
1043 &id, container2Properties); 1066 &id, container2Properties);
1044 } 1067 }
1045 SubsequenceRecorder r(context, container2); 1068 SubsequenceRecorder r(context, container2);
1046 drawRect(context, container2, backgroundDrawingType, 1069 drawRect(context, container2, backgroundDrawingType,
1047 FloatRect(100, 200, 100, 100)); 1070 FloatRect(100, 200, 100, 100));
1048 drawRect(context, content2, backgroundDrawingType, 1071 drawRect(context, content2, backgroundDrawingType,
1049 FloatRect(100, 200, 50, 200)); 1072 FloatRect(100, 200, 50, 200));
1050 drawRect(context, content2, foregroundDrawingType, 1073 drawRect(context, content2, foregroundDrawingType,
1051 FloatRect(100, 200, 50, 200)); 1074 FloatRect(100, 200, 50, 200));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 1206 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
1184 GraphicsContext context(getPaintController()); 1207 GraphicsContext context(getPaintController());
1185 1208
1186 PaintChunkProperties container1Properties; 1209 PaintChunkProperties container1Properties;
1187 PaintChunkProperties container2Properties; 1210 PaintChunkProperties container2Properties;
1188 1211
1189 { 1212 {
1190 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1213 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1191 PaintChunk::Id id(container1, backgroundDrawingType); 1214 PaintChunk::Id id(container1, backgroundDrawingType);
1192 container1Properties.effect = 1215 container1Properties.effect =
1193 EffectPaintPropertyNode::create(nullptr, 0.5); 1216 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1194 getPaintController().updateCurrentPaintChunkProperties( 1217 getPaintController().updateCurrentPaintChunkProperties(
1195 &id, container1Properties); 1218 &id, container1Properties);
1196 } 1219 }
1197 drawRect(context, container1, backgroundDrawingType, 1220 drawRect(context, container1, backgroundDrawingType,
1198 FloatRect(100, 100, 100, 100)); 1221 FloatRect(100, 100, 100, 100));
1199 drawRect(context, content1, backgroundDrawingType, 1222 drawRect(context, content1, backgroundDrawingType,
1200 FloatRect(100, 100, 50, 200)); 1223 FloatRect(100, 100, 50, 200));
1201 } 1224 }
1202 { 1225 {
1203 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1226 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1204 PaintChunk::Id id(container2, backgroundDrawingType); 1227 PaintChunk::Id id(container2, backgroundDrawingType);
1205 container2Properties.effect = 1228 container2Properties.effect =
1206 EffectPaintPropertyNode::create(nullptr, 0.5); 1229 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1207 getPaintController().updateCurrentPaintChunkProperties( 1230 getPaintController().updateCurrentPaintChunkProperties(
1208 &id, container2Properties); 1231 &id, container2Properties);
1209 } 1232 }
1210 drawRect(context, container2, backgroundDrawingType, 1233 drawRect(context, container2, backgroundDrawingType,
1211 FloatRect(100, 200, 100, 100)); 1234 FloatRect(100, 200, 100, 100));
1212 drawRect(context, content2, backgroundDrawingType, 1235 drawRect(context, content2, backgroundDrawingType,
1213 FloatRect(100, 200, 50, 200)); 1236 FloatRect(100, 200, 50, 200));
1214 } 1237 }
1215 getPaintController().commitNewDisplayItems(); 1238 getPaintController().commitNewDisplayItems();
1216 1239
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 PaintChunkProperties container1BackgroundProperties; 1343 PaintChunkProperties container1BackgroundProperties;
1321 PaintChunkProperties content1Properties; 1344 PaintChunkProperties content1Properties;
1322 PaintChunkProperties container1ForegroundProperties; 1345 PaintChunkProperties container1ForegroundProperties;
1323 PaintChunkProperties container2BackgroundProperties; 1346 PaintChunkProperties container2BackgroundProperties;
1324 PaintChunkProperties content2Properties; 1347 PaintChunkProperties content2Properties;
1325 1348
1326 { 1349 {
1327 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1350 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1328 PaintChunk::Id id(container1, backgroundDrawingType); 1351 PaintChunk::Id id(container1, backgroundDrawingType);
1329 container1BackgroundProperties.effect = 1352 container1BackgroundProperties.effect =
1330 EffectPaintPropertyNode::create(nullptr, 0.5); 1353 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1331 getPaintController().updateCurrentPaintChunkProperties( 1354 getPaintController().updateCurrentPaintChunkProperties(
1332 &id, container1BackgroundProperties); 1355 &id, container1BackgroundProperties);
1333 } 1356 }
1334 SubsequenceRecorder r(context, container1); 1357 SubsequenceRecorder r(context, container1);
1335 drawRect(context, container1, backgroundDrawingType, 1358 drawRect(context, container1, backgroundDrawingType,
1336 FloatRect(100, 100, 100, 100)); 1359 FloatRect(100, 100, 100, 100));
1337 { 1360 {
1338 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1361 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1339 PaintChunk::Id id(content1, backgroundDrawingType); 1362 PaintChunk::Id id(content1, backgroundDrawingType);
1340 content1Properties.effect = 1363 content1Properties.effect =
1341 EffectPaintPropertyNode::create(nullptr, 0.6); 1364 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransfor m(), dummyRootClip(), 0.6, CompositorFilterOperations());
1342 getPaintController().updateCurrentPaintChunkProperties( 1365 getPaintController().updateCurrentPaintChunkProperties(
1343 &id, content1Properties); 1366 &id, content1Properties);
1344 } 1367 }
1345 SubsequenceRecorder r(context, content1); 1368 SubsequenceRecorder r(context, content1);
1346 drawRect(context, content1, backgroundDrawingType, 1369 drawRect(context, content1, backgroundDrawingType,
1347 FloatRect(100, 100, 50, 200)); 1370 FloatRect(100, 100, 50, 200));
1348 drawRect(context, content1, foregroundDrawingType, 1371 drawRect(context, content1, foregroundDrawingType,
1349 FloatRect(100, 100, 50, 200)); 1372 FloatRect(100, 100, 50, 200));
1350 } 1373 }
1351 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1374 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1352 PaintChunk::Id id(container1, foregroundDrawingType); 1375 PaintChunk::Id id(container1, foregroundDrawingType);
1353 container1ForegroundProperties.effect = 1376 container1ForegroundProperties.effect =
1354 EffectPaintPropertyNode::create(nullptr, 0.5); 1377 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.5, CompositorFilterOperations());
1355 getPaintController().updateCurrentPaintChunkProperties( 1378 getPaintController().updateCurrentPaintChunkProperties(
1356 &id, container1ForegroundProperties); 1379 &id, container1ForegroundProperties);
1357 } 1380 }
1358 drawRect(context, container1, foregroundDrawingType, 1381 drawRect(context, container1, foregroundDrawingType,
1359 FloatRect(100, 100, 100, 100)); 1382 FloatRect(100, 100, 100, 100));
1360 } 1383 }
1361 { 1384 {
1362 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1385 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1363 PaintChunk::Id id(container2, backgroundDrawingType); 1386 PaintChunk::Id id(container2, backgroundDrawingType);
1364 container2BackgroundProperties.effect = 1387 container2BackgroundProperties.effect =
1365 EffectPaintPropertyNode::create(nullptr, 0.7); 1388 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform( ), dummyRootClip(), 0.7, CompositorFilterOperations());
1366 getPaintController().updateCurrentPaintChunkProperties( 1389 getPaintController().updateCurrentPaintChunkProperties(
1367 &id, container2BackgroundProperties); 1390 &id, container2BackgroundProperties);
1368 } 1391 }
1369 SubsequenceRecorder r(context, container2); 1392 SubsequenceRecorder r(context, container2);
1370 drawRect(context, container2, backgroundDrawingType, 1393 drawRect(context, container2, backgroundDrawingType,
1371 FloatRect(100, 200, 100, 100)); 1394 FloatRect(100, 200, 100, 100));
1372 { 1395 {
1373 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1396 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1374 PaintChunk::Id id(content2, backgroundDrawingType); 1397 PaintChunk::Id id(content2, backgroundDrawingType);
1375 content2Properties.effect = 1398 content2Properties.effect =
1376 EffectPaintPropertyNode::create(nullptr, 0.8); 1399 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransfor m(), dummyRootClip(), 0.8, CompositorFilterOperations());
1377 getPaintController().updateCurrentPaintChunkProperties( 1400 getPaintController().updateCurrentPaintChunkProperties(
1378 &id, content2Properties); 1401 &id, content2Properties);
1379 } 1402 }
1380 SubsequenceRecorder r(context, content2); 1403 SubsequenceRecorder r(context, content2);
1381 drawRect(context, content2, backgroundDrawingType, 1404 drawRect(context, content2, backgroundDrawingType,
1382 FloatRect(100, 200, 50, 200)); 1405 FloatRect(100, 200, 50, 200));
1383 } 1406 }
1384 } 1407 }
1385 getPaintController().commitNewDisplayItems(); 1408 getPaintController().commitNewDisplayItems();
1386 1409
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 } 2283 }
2261 2284
2262 TEST_F(PaintControllerUnderInvalidationTest, 2285 TEST_F(PaintControllerUnderInvalidationTest,
2263 FoldCompositingDrawingInSubsequence) { 2286 FoldCompositingDrawingInSubsequence) {
2264 testFoldCompositingDrawingInSubsequence(); 2287 testFoldCompositingDrawingInSubsequence();
2265 } 2288 }
2266 2289
2267 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2290 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2268 2291
2269 } // namespace blink 2292 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698