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

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

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Self-review. Created 4 years, 3 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"
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 drawRect(context, content, foregroundDrawingType, rect1); 1126 drawRect(context, content, foregroundDrawingType, rect1);
1127 drawRect(context, content, foregroundDrawingType, rect2); 1127 drawRect(context, content, foregroundDrawingType, rect2);
1128 getPaintController().endSkippingCache(); 1128 getPaintController().endSkippingCache();
1129 1129
1130 getPaintController().commitNewDisplayItems(); 1130 getPaintController().commitNewDisplayItems();
1131 1131
1132 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1132 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1133 TestDisplayItem(multicol, backgroundDrawingType), 1133 TestDisplayItem(multicol, backgroundDrawingType),
1134 TestDisplayItem(content, foregroundDrawingType), 1134 TestDisplayItem(content, foregroundDrawingType),
1135 TestDisplayItem(content, foregroundDrawingType)); 1135 TestDisplayItem(content, foregroundDrawingType));
1136 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); 1136 sk_sp<const SkPicture> picture1 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[1]).picture());
1137 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); 1137 sk_sp<const SkPicture> picture2 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[2]).picture());
1138 EXPECT_NE(picture1, picture2); 1138 EXPECT_NE(picture1, picture2);
1139 1139
1140 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1140 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1141 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1141 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1142 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 1142 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
1143 1143
1144 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 1144 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
1145 } 1145 }
1146 1146
1147 // Draw again with nothing invalidated. 1147 // Draw again with nothing invalidated.
(...skipping 11 matching lines...) Expand all
1159 EXPECT_EQ(0, numOutOfOrderMatches()); 1159 EXPECT_EQ(0, numOutOfOrderMatches());
1160 EXPECT_EQ(0, numIndexedItems()); 1160 EXPECT_EQ(0, numIndexedItems());
1161 #endif 1161 #endif
1162 1162
1163 getPaintController().commitNewDisplayItems(); 1163 getPaintController().commitNewDisplayItems();
1164 1164
1165 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1165 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1166 TestDisplayItem(multicol, backgroundDrawingType), 1166 TestDisplayItem(multicol, backgroundDrawingType),
1167 TestDisplayItem(content, foregroundDrawingType), 1167 TestDisplayItem(content, foregroundDrawingType),
1168 TestDisplayItem(content, foregroundDrawingType)); 1168 TestDisplayItem(content, foregroundDrawingType));
1169 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 1169 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[1]).picture());
1170 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 1170 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[2]).picture());
1171 1171
1172 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1172 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1173 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1173 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1174 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 1174 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1175 FloatRect(100, 100, 100, 100), // Old bounds of |content|. 1175 FloatRect(100, 100, 100, 100), // Old bounds of |content|.
1176 FloatRect(100, 100, 100, 100))); // New bounds of |content|. 1176 FloatRect(100, 100, 100, 100))); // New bounds of |content|.
1177 1177
1178 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 1178 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
1179 } 1179 }
1180 1180
1181 // Now the multicol becomes 3 columns and repaints. 1181 // Now the multicol becomes 3 columns and repaints.
1182 multicol.setDisplayItemsUncached(); 1182 multicol.setDisplayItemsUncached();
1183 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 1183 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100));
1184 1184
1185 getPaintController().beginSkippingCache(); 1185 getPaintController().beginSkippingCache();
1186 drawRect(context, content, foregroundDrawingType, rect1); 1186 drawRect(context, content, foregroundDrawingType, rect1);
1187 drawRect(context, content, foregroundDrawingType, rect2); 1187 drawRect(context, content, foregroundDrawingType, rect2);
1188 drawRect(context, content, foregroundDrawingType, rect3); 1188 drawRect(context, content, foregroundDrawingType, rect3);
1189 getPaintController().endSkippingCache(); 1189 getPaintController().endSkippingCache();
1190 1190
1191 // We should repaint everything on invalidation of the scope container. 1191 // We should repaint everything on invalidation of the scope container.
1192 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, 1192 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4,
1193 TestDisplayItem(multicol, backgroundDrawingType), 1193 TestDisplayItem(multicol, backgroundDrawingType),
1194 TestDisplayItem(content, foregroundDrawingType), 1194 TestDisplayItem(content, foregroundDrawingType),
1195 TestDisplayItem(content, foregroundDrawingType), 1195 TestDisplayItem(content, foregroundDrawingType),
1196 TestDisplayItem(content, foregroundDrawingType)); 1196 TestDisplayItem(content, foregroundDrawingType));
1197 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); 1197 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().newDisplayItemList()[1]).picture());
1198 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); 1198 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().newDisplayItemList()[2]).picture());
1199 1199
1200 getPaintController().commitNewDisplayItems(); 1200 getPaintController().commitNewDisplayItems();
1201 1201
1202 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1202 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1203 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1203 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1204 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 1204 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1205 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. 1205 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|.
1206 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. 1206 FloatRect(100, 100, 200, 200), // New bounds of |multicol|.
1207 FloatRect(100, 100, 100, 100), // Old bounds of |content|. 1207 FloatRect(100, 100, 100, 100), // Old bounds of |content|.
1208 FloatRect(100, 100, 100, 100))); // New bounds of |content|. 1208 FloatRect(100, 100, 100, 100))); // New bounds of |content|.
(...skipping 14 matching lines...) Expand all
1223 drawRect(context, content, foregroundDrawingType, rect2); 1223 drawRect(context, content, foregroundDrawingType, rect2);
1224 getPaintController().endSkippingCache(); 1224 getPaintController().endSkippingCache();
1225 drawRect(context, content, foregroundDrawingType, rect3); 1225 drawRect(context, content, foregroundDrawingType, rect3);
1226 1226
1227 getPaintController().commitNewDisplayItems(); 1227 getPaintController().commitNewDisplayItems();
1228 1228
1229 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1229 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1230 TestDisplayItem(content, backgroundDrawingType), 1230 TestDisplayItem(content, backgroundDrawingType),
1231 TestDisplayItem(content, foregroundDrawingType), 1231 TestDisplayItem(content, foregroundDrawingType),
1232 TestDisplayItem(content, foregroundDrawingType)); 1232 TestDisplayItem(content, foregroundDrawingType));
1233 RefPtr<const SkPicture> picture0 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[0]).picture(); 1233 sk_sp<const SkPicture> picture0 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[0]).picture());
1234 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); 1234 sk_sp<const SkPicture> picture1 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[1]).picture());
1235 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); 1235 sk_sp<const SkPicture> picture2 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[2]).picture());
1236 EXPECT_NE(picture1, picture2); 1236 EXPECT_NE(picture1, picture2);
1237 1237
1238 // Content's cache is invalid because it has display items skipped cache. 1238 // Content's cache is invalid because it has display items skipped cache.
1239 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); 1239 EXPECT_FALSE(getPaintController().clientCacheIsValid(content));
1240 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); 1240 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
1241 1241
1242 // Draw again with nothing invalidated. 1242 // Draw again with nothing invalidated.
1243 drawRect(context, content, backgroundDrawingType, rect1); 1243 drawRect(context, content, backgroundDrawingType, rect1);
1244 getPaintController().beginSkippingCache(); 1244 getPaintController().beginSkippingCache();
1245 drawRect(context, content, foregroundDrawingType, rect2); 1245 drawRect(context, content, foregroundDrawingType, rect2);
1246 getPaintController().endSkippingCache(); 1246 getPaintController().endSkippingCache();
1247 drawRect(context, content, foregroundDrawingType, rect3); 1247 drawRect(context, content, foregroundDrawingType, rect3);
1248 1248
1249 EXPECT_EQ(0, numCachedNewItems()); 1249 EXPECT_EQ(0, numCachedNewItems());
1250 #if DCHECK_IS_ON() 1250 #if DCHECK_IS_ON()
1251 EXPECT_EQ(0, numSequentialMatches()); 1251 EXPECT_EQ(0, numSequentialMatches());
1252 EXPECT_EQ(0, numOutOfOrderMatches()); 1252 EXPECT_EQ(0, numOutOfOrderMatches());
1253 EXPECT_EQ(0, numIndexedItems()); 1253 EXPECT_EQ(0, numIndexedItems());
1254 #endif 1254 #endif
1255 1255
1256 getPaintController().commitNewDisplayItems(); 1256 getPaintController().commitNewDisplayItems();
1257 1257
1258 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1258 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1259 TestDisplayItem(content, backgroundDrawingType), 1259 TestDisplayItem(content, backgroundDrawingType),
1260 TestDisplayItem(content, foregroundDrawingType), 1260 TestDisplayItem(content, foregroundDrawingType),
1261 TestDisplayItem(content, foregroundDrawingType)); 1261 TestDisplayItem(content, foregroundDrawingType));
1262 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); 1262 EXPECT_NE(picture0.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[0]).picture());
1263 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 1263 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[1]).picture());
1264 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 1264 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[2]).picture());
1265 } 1265 }
1266 1266
1267 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) 1267 TEST_F(PaintControllerTestBase, OptimizeNoopPairs)
1268 { 1268 {
1269 FakeDisplayItemClient first("first"); 1269 FakeDisplayItemClient first("first");
1270 FakeDisplayItemClient second("second"); 1270 FakeDisplayItemClient second("second");
1271 FakeDisplayItemClient third("third"); 1271 FakeDisplayItemClient third("third");
1272 1272
1273 GraphicsContext context(getPaintController()); 1273 GraphicsContext context(getPaintController());
1274 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 1274 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 } 1757 }
1758 1758
1759 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) 1759 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence )
1760 { 1760 {
1761 testFoldCompositingDrawingInSubsequence(); 1761 testFoldCompositingDrawingInSubsequence();
1762 } 1762 }
1763 1763
1764 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 1764 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1765 1765
1766 } // namespace blink 1766 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698