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

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: Rebasing... 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 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 drawRect(context, content, foregroundDrawingType, rect1); 1118 drawRect(context, content, foregroundDrawingType, rect1);
1119 drawRect(context, content, foregroundDrawingType, rect2); 1119 drawRect(context, content, foregroundDrawingType, rect2);
1120 getPaintController().endSkippingCache(); 1120 getPaintController().endSkippingCache();
1121 1121
1122 getPaintController().commitNewDisplayItems(); 1122 getPaintController().commitNewDisplayItems();
1123 1123
1124 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1124 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1125 TestDisplayItem(multicol, backgroundDrawingType), 1125 TestDisplayItem(multicol, backgroundDrawingType),
1126 TestDisplayItem(content, foregroundDrawingType), 1126 TestDisplayItem(content, foregroundDrawingType),
1127 TestDisplayItem(content, foregroundDrawingType)); 1127 TestDisplayItem(content, foregroundDrawingType));
1128 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); 1128 sk_sp<const SkPicture> picture1 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[1]).picture());
1129 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); 1129 sk_sp<const SkPicture> picture2 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[2]).picture());
1130 EXPECT_NE(picture1, picture2); 1130 EXPECT_NE(picture1, picture2);
1131 1131
1132 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1132 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1133 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1133 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1134 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 1134 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
1135 1135
1136 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 1136 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
1137 } 1137 }
1138 1138
1139 // Draw again with nothing invalidated. 1139 // Draw again with nothing invalidated.
(...skipping 11 matching lines...) Expand all
1151 EXPECT_EQ(0, numOutOfOrderMatches()); 1151 EXPECT_EQ(0, numOutOfOrderMatches());
1152 EXPECT_EQ(0, numIndexedItems()); 1152 EXPECT_EQ(0, numIndexedItems());
1153 #endif 1153 #endif
1154 1154
1155 getPaintController().commitNewDisplayItems(); 1155 getPaintController().commitNewDisplayItems();
1156 1156
1157 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1157 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1158 TestDisplayItem(multicol, backgroundDrawingType), 1158 TestDisplayItem(multicol, backgroundDrawingType),
1159 TestDisplayItem(content, foregroundDrawingType), 1159 TestDisplayItem(content, foregroundDrawingType),
1160 TestDisplayItem(content, foregroundDrawingType)); 1160 TestDisplayItem(content, foregroundDrawingType));
1161 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 1161 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[1]).picture());
1162 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 1162 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[2]).picture());
1163 1163
1164 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1164 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1165 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1165 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1166 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 1166 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1167 FloatRect(100, 100, 100, 100), // Old bounds of |content|. 1167 FloatRect(100, 100, 100, 100), // Old bounds of |content|.
1168 FloatRect(100, 100, 100, 100))); // New bounds of |content|. 1168 FloatRect(100, 100, 100, 100))); // New bounds of |content|.
1169 1169
1170 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 1170 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
1171 } 1171 }
1172 1172
1173 // Now the multicol becomes 3 columns and repaints. 1173 // Now the multicol becomes 3 columns and repaints.
1174 multicol.setDisplayItemsUncached(); 1174 multicol.setDisplayItemsUncached();
1175 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 1175 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100));
1176 1176
1177 getPaintController().beginSkippingCache(); 1177 getPaintController().beginSkippingCache();
1178 drawRect(context, content, foregroundDrawingType, rect1); 1178 drawRect(context, content, foregroundDrawingType, rect1);
1179 drawRect(context, content, foregroundDrawingType, rect2); 1179 drawRect(context, content, foregroundDrawingType, rect2);
1180 drawRect(context, content, foregroundDrawingType, rect3); 1180 drawRect(context, content, foregroundDrawingType, rect3);
1181 getPaintController().endSkippingCache(); 1181 getPaintController().endSkippingCache();
1182 1182
1183 // We should repaint everything on invalidation of the scope container. 1183 // We should repaint everything on invalidation of the scope container.
1184 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, 1184 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4,
1185 TestDisplayItem(multicol, backgroundDrawingType), 1185 TestDisplayItem(multicol, backgroundDrawingType),
1186 TestDisplayItem(content, foregroundDrawingType), 1186 TestDisplayItem(content, foregroundDrawingType),
1187 TestDisplayItem(content, foregroundDrawingType), 1187 TestDisplayItem(content, foregroundDrawingType),
1188 TestDisplayItem(content, foregroundDrawingType)); 1188 TestDisplayItem(content, foregroundDrawingType));
1189 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); 1189 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().newDisplayItemList()[1]).picture());
1190 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); 1190 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().newDisplayItemList()[2]).picture());
1191 1191
1192 getPaintController().commitNewDisplayItems(); 1192 getPaintController().commitNewDisplayItems();
1193 1193
1194 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1194 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1195 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1195 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1196 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 1196 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1197 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. 1197 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|.
1198 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. 1198 FloatRect(100, 100, 200, 200), // New bounds of |multicol|.
1199 FloatRect(100, 100, 100, 100), // Old bounds of |content|. 1199 FloatRect(100, 100, 100, 100), // Old bounds of |content|.
1200 FloatRect(100, 100, 100, 100))); // New bounds of |content|. 1200 FloatRect(100, 100, 100, 100))); // New bounds of |content|.
(...skipping 14 matching lines...) Expand all
1215 drawRect(context, content, foregroundDrawingType, rect2); 1215 drawRect(context, content, foregroundDrawingType, rect2);
1216 getPaintController().endSkippingCache(); 1216 getPaintController().endSkippingCache();
1217 drawRect(context, content, foregroundDrawingType, rect3); 1217 drawRect(context, content, foregroundDrawingType, rect3);
1218 1218
1219 getPaintController().commitNewDisplayItems(); 1219 getPaintController().commitNewDisplayItems();
1220 1220
1221 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1221 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1222 TestDisplayItem(content, backgroundDrawingType), 1222 TestDisplayItem(content, backgroundDrawingType),
1223 TestDisplayItem(content, foregroundDrawingType), 1223 TestDisplayItem(content, foregroundDrawingType),
1224 TestDisplayItem(content, foregroundDrawingType)); 1224 TestDisplayItem(content, foregroundDrawingType));
1225 RefPtr<const SkPicture> picture0 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[0]).picture(); 1225 sk_sp<const SkPicture> picture0 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[0]).picture());
1226 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); 1226 sk_sp<const SkPicture> picture1 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[1]).picture());
1227 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); 1227 sk_sp<const SkPicture> picture2 = sk_ref_sp(static_cast<const DrawingDisplay Item&>(getPaintController().getDisplayItemList()[2]).picture());
1228 EXPECT_NE(picture1, picture2); 1228 EXPECT_NE(picture1, picture2);
1229 1229
1230 // Content's cache is invalid because it has display items skipped cache. 1230 // Content's cache is invalid because it has display items skipped cache.
1231 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); 1231 EXPECT_FALSE(getPaintController().clientCacheIsValid(content));
1232 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); 1232 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
1233 1233
1234 // Draw again with nothing invalidated. 1234 // Draw again with nothing invalidated.
1235 drawRect(context, content, backgroundDrawingType, rect1); 1235 drawRect(context, content, backgroundDrawingType, rect1);
1236 getPaintController().beginSkippingCache(); 1236 getPaintController().beginSkippingCache();
1237 drawRect(context, content, foregroundDrawingType, rect2); 1237 drawRect(context, content, foregroundDrawingType, rect2);
1238 getPaintController().endSkippingCache(); 1238 getPaintController().endSkippingCache();
1239 drawRect(context, content, foregroundDrawingType, rect3); 1239 drawRect(context, content, foregroundDrawingType, rect3);
1240 1240
1241 EXPECT_EQ(0, numCachedNewItems()); 1241 EXPECT_EQ(0, numCachedNewItems());
1242 #ifndef NDEBUG 1242 #ifndef NDEBUG
1243 EXPECT_EQ(0, numSequentialMatches()); 1243 EXPECT_EQ(0, numSequentialMatches());
1244 EXPECT_EQ(0, numOutOfOrderMatches()); 1244 EXPECT_EQ(0, numOutOfOrderMatches());
1245 EXPECT_EQ(0, numIndexedItems()); 1245 EXPECT_EQ(0, numIndexedItems());
1246 #endif 1246 #endif
1247 1247
1248 getPaintController().commitNewDisplayItems(); 1248 getPaintController().commitNewDisplayItems();
1249 1249
1250 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1250 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1251 TestDisplayItem(content, backgroundDrawingType), 1251 TestDisplayItem(content, backgroundDrawingType),
1252 TestDisplayItem(content, foregroundDrawingType), 1252 TestDisplayItem(content, foregroundDrawingType),
1253 TestDisplayItem(content, foregroundDrawingType)); 1253 TestDisplayItem(content, foregroundDrawingType));
1254 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); 1254 EXPECT_NE(picture0.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[0]).picture());
1255 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 1255 EXPECT_NE(picture1.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[1]).picture());
1256 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 1256 EXPECT_NE(picture2.get(), static_cast<const DrawingDisplayItem&>(getPaintCon troller().getDisplayItemList()[2]).picture());
1257 } 1257 }
1258 1258
1259 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) 1259 TEST_F(PaintControllerTestBase, OptimizeNoopPairs)
1260 { 1260 {
1261 FakeDisplayItemClient first("first"); 1261 FakeDisplayItemClient first("first");
1262 FakeDisplayItemClient second("second"); 1262 FakeDisplayItemClient second("second");
1263 FakeDisplayItemClient third("third"); 1263 FakeDisplayItemClient third("third");
1264 1264
1265 GraphicsContext context(getPaintController()); 1265 GraphicsContext context(getPaintController());
1266 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 1266 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 } 1748 }
1749 1749
1750 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) 1750 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence )
1751 { 1751 {
1752 testFoldCompositingDrawingInSubsequence(); 1752 testFoldCompositingDrawingInSubsequence();
1753 } 1753 }
1754 1754
1755 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 1755 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1756 1756
1757 } // namespace blink 1757 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698