| 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/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 13 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
| 14 #include "platform/graphics/paint/SubsequenceRecorder.h" | 15 #include "platform/graphics/paint/SubsequenceRecorder.h" |
| 15 #include "platform/testing/FakeDisplayItemClient.h" | 16 #include "platform/testing/FakeDisplayItemClient.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include <memory> | 18 #include <memory> |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 class PaintControllerTestBase : public testing::Test { | 22 class PaintControllerTestBase : public testing::Test { |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 { | 1336 { |
| 1336 SubsequenceRecorder r(context, container); | 1337 SubsequenceRecorder r(context, container); |
| 1337 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); | 1338 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); |
| 1338 } | 1339 } |
| 1339 getPaintController().commitNewDisplayItems(); | 1340 getPaintController().commitNewDisplayItems(); |
| 1340 | 1341 |
| 1341 content.setDisplayItemsUncached(); | 1342 content.setDisplayItemsUncached(); |
| 1342 // Leave container not invalidated. | 1343 // Leave container not invalidated. |
| 1343 { | 1344 { |
| 1344 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con
text, container)); | 1345 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con
text, container)); |
| 1345 SubsequenceRecorder r(context, content); | 1346 SubsequenceRecorder r(context, container); |
| 1346 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); | 1347 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); |
| 1347 } | 1348 } |
| 1348 getPaintController().commitNewDisplayItems(); | 1349 getPaintController().commitNewDisplayItems(); |
| 1350 |
| 1351 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 1352 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 1353 #endif |
| 1349 } | 1354 } |
| 1350 | 1355 |
| 1351 // TODO(wangxianzhu): Add under-invalidation checking test in case of compos
iting item folding. | 1356 void testFoldCompositingDrawingInSubsequence() |
| 1357 { |
| 1358 FakeDisplayItemClient container("container"); |
| 1359 FakeDisplayItemClient content("content"); |
| 1360 GraphicsContext context(getPaintController()); |
| 1361 |
| 1362 { |
| 1363 SubsequenceRecorder subsequence(context, container); |
| 1364 CompositingRecorder compositing(context, content, SkXfermode::kSrc_M
ode, 0.5); |
| 1365 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); |
| 1366 } |
| 1367 getPaintController().commitNewDisplayItems(); |
| 1368 EXPECT_EQ(3u, getPaintController().paintArtifact().getDisplayItemList().
size()); |
| 1369 |
| 1370 { |
| 1371 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con
text, container)); |
| 1372 SubsequenceRecorder subsequence(context, container); |
| 1373 CompositingRecorder compositing(context, content, SkXfermode::kSrc_M
ode, 0.5); |
| 1374 drawRect(context, content, backgroundDrawingType, FloatRect(100, 100
, 300, 300)); |
| 1375 } |
| 1376 getPaintController().commitNewDisplayItems(); |
| 1377 EXPECT_EQ(3u, getPaintController().paintArtifact().getDisplayItemList().
size()); |
| 1378 |
| 1379 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 1380 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 1381 #endif |
| 1382 } |
| 1352 }; | 1383 }; |
| 1353 | 1384 |
| 1354 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawing) | 1385 TEST_F(PaintControllerUnderInvalidationTest, ChangeDrawing) |
| 1355 { | 1386 { |
| 1356 EXPECT_DEATH(testChangeDrawing(), "under-invalidation: display item changed"
); | 1387 EXPECT_DEATH(testChangeDrawing(), "under-invalidation: display item changed"
); |
| 1357 } | 1388 } |
| 1358 | 1389 |
| 1359 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawing) | 1390 TEST_F(PaintControllerUnderInvalidationTest, MoreDrawing) |
| 1360 { | 1391 { |
| 1361 EXPECT_DEATH(testMoreDrawing(), "Can't find cached display item"); | 1392 EXPECT_DEATH(testMoreDrawing(), "Can't find cached display item"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1390 EXPECT_DEATH(testLessDrawingInSubsequence(), "\"\\(In cached subsequence of
first\\)\" under-invalidation: display item changed"); | 1421 EXPECT_DEATH(testLessDrawingInSubsequence(), "\"\\(In cached subsequence of
first\\)\" under-invalidation: display item changed"); |
| 1391 } | 1422 } |
| 1392 | 1423 |
| 1393 TEST_F(PaintControllerUnderInvalidationTest, ChangeNonCacheableInSubsequence) | 1424 TEST_F(PaintControllerUnderInvalidationTest, ChangeNonCacheableInSubsequence) |
| 1394 { | 1425 { |
| 1395 EXPECT_DEATH(testChangeNonCacheableInSubsequence(), "\"\\(In cached subseque
nce of container\\)\" under-invalidation: display item changed"); | 1426 EXPECT_DEATH(testChangeNonCacheableInSubsequence(), "\"\\(In cached subseque
nce of container\\)\" under-invalidation: display item changed"); |
| 1396 } | 1427 } |
| 1397 | 1428 |
| 1398 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) | 1429 TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) |
| 1399 { | 1430 { |
| 1400 EXPECT_DEATH(testInvalidationInSubsequence(), "\"\\(In cached subsequence of
container\\)\" under-invalidation of PaintLayer: invalidated in cached subseque
nce"); | 1431 // We allow invalidated display item clients as long as they would produce t
he same display items. |
| 1432 // The cases of changed display items are tested by other test cases. |
| 1433 testInvalidationInSubsequence(); |
| 1434 } |
| 1435 |
| 1436 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence
) |
| 1437 { |
| 1438 testFoldCompositingDrawingInSubsequence(); |
| 1401 } | 1439 } |
| 1402 | 1440 |
| 1403 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 1441 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 1404 | 1442 |
| 1405 } // namespace blink | 1443 } // namespace blink |
| OLD | NEW |