OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return m_previousInterestRect; | 273 return m_previousInterestRect; |
274 } | 274 } |
275 | 275 |
276 void GraphicsLayer::paint(const IntRect* interestRect, | 276 void GraphicsLayer::paint(const IntRect* interestRect, |
277 GraphicsContext::DisabledMode disabledMode) { | 277 GraphicsContext::DisabledMode disabledMode) { |
278 if (paintWithoutCommit(interestRect, disabledMode)) { | 278 if (paintWithoutCommit(interestRect, disabledMode)) { |
279 getPaintController().commitNewDisplayItems( | 279 getPaintController().commitNewDisplayItems( |
280 offsetFromLayoutObjectWithSubpixelAccumulation()); | 280 offsetFromLayoutObjectWithSubpixelAccumulation()); |
281 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 281 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
282 sk_sp<PaintRecord> record = captureRecord(); | 282 sk_sp<PaintRecord> record = captureRecord(); |
283 checkPaintUnderInvalidations(*record); | 283 checkPaintUnderInvalidations(record); |
284 RasterInvalidationTracking& tracking = | 284 RasterInvalidationTracking& tracking = |
285 rasterInvalidationTrackingMap().add(this); | 285 rasterInvalidationTrackingMap().add(this); |
286 tracking.lastPaintedRecord = std::move(record); | 286 tracking.lastPaintedRecord = std::move(record); |
287 tracking.lastInterestRect = m_previousInterestRect; | 287 tracking.lastInterestRect = m_previousInterestRect; |
288 tracking.rasterInvalidationRegionSinceLastPaint = Region(); | 288 tracking.rasterInvalidationRegionSinceLastPaint = Region(); |
289 } | 289 } |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 bool GraphicsLayer::paintWithoutCommit( | 293 bool GraphicsLayer::paintWithoutCommit( |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 return abs(c1 - c2) > 2; | 1195 return abs(c1 - c2) > 2; |
1196 } | 1196 } |
1197 | 1197 |
1198 static bool pixelsDiffer(SkColor p1, SkColor p2) { | 1198 static bool pixelsDiffer(SkColor p1, SkColor p2) { |
1199 return pixelComponentsDiffer(SkColorGetA(p1), SkColorGetA(p2)) || | 1199 return pixelComponentsDiffer(SkColorGetA(p1), SkColorGetA(p2)) || |
1200 pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) || | 1200 pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) || |
1201 pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) || | 1201 pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) || |
1202 pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); | 1202 pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); |
1203 } | 1203 } |
1204 | 1204 |
1205 void GraphicsLayer::checkPaintUnderInvalidations(const PaintRecord& newRecord) { | 1205 void GraphicsLayer::checkPaintUnderInvalidations(sk_sp<PaintRecord> newRecord) { |
1206 if (!drawsContent()) | 1206 if (!drawsContent()) |
1207 return; | 1207 return; |
1208 | 1208 |
1209 RasterInvalidationTracking* tracking = | 1209 RasterInvalidationTracking* tracking = |
1210 rasterInvalidationTrackingMap().find(this); | 1210 rasterInvalidationTrackingMap().find(this); |
1211 if (!tracking) | 1211 if (!tracking) |
1212 return; | 1212 return; |
1213 | 1213 |
1214 if (!tracking->lastPaintedRecord) | 1214 if (!tracking->lastPaintedRecord) |
1215 return; | 1215 return; |
1216 | 1216 |
1217 IntRect rect = intersection(tracking->lastInterestRect, interestRect()); | 1217 IntRect rect = intersection(tracking->lastInterestRect, interestRect()); |
1218 if (rect.isEmpty()) | 1218 if (rect.isEmpty()) |
1219 return; | 1219 return; |
1220 | 1220 |
1221 SkBitmap oldBitmap; | 1221 SkBitmap oldBitmap; |
1222 oldBitmap.allocPixels( | 1222 oldBitmap.allocPixels( |
1223 SkImageInfo::MakeN32Premul(rect.width(), rect.height())); | 1223 SkImageInfo::MakeN32Premul(rect.width(), rect.height())); |
1224 { | 1224 { |
1225 SkiaPaintCanvas canvas(oldBitmap); | 1225 SkiaPaintCanvas canvas(oldBitmap); |
1226 canvas.clear(SK_ColorTRANSPARENT); | 1226 canvas.clear(SK_ColorTRANSPARENT); |
1227 canvas.translate(-rect.x(), -rect.y()); | 1227 canvas.translate(-rect.x(), -rect.y()); |
1228 canvas.drawPicture(tracking->lastPaintedRecord.get()); | 1228 canvas.drawPicture(tracking->lastPaintedRecord); |
1229 } | 1229 } |
1230 | 1230 |
1231 SkBitmap newBitmap; | 1231 SkBitmap newBitmap; |
1232 newBitmap.allocPixels( | 1232 newBitmap.allocPixels( |
1233 SkImageInfo::MakeN32Premul(rect.width(), rect.height())); | 1233 SkImageInfo::MakeN32Premul(rect.width(), rect.height())); |
1234 { | 1234 { |
1235 SkiaPaintCanvas canvas(newBitmap); | 1235 SkiaPaintCanvas canvas(newBitmap); |
1236 canvas.clear(SK_ColorTRANSPARENT); | 1236 canvas.clear(SK_ColorTRANSPARENT); |
1237 canvas.translate(-rect.x(), -rect.y()); | 1237 canvas.translate(-rect.x(), -rect.y()); |
1238 canvas.drawPicture(&newRecord); | 1238 canvas.drawPicture(std::move(newRecord)); |
1239 } | 1239 } |
1240 | 1240 |
1241 oldBitmap.lockPixels(); | 1241 oldBitmap.lockPixels(); |
1242 newBitmap.lockPixels(); | 1242 newBitmap.lockPixels(); |
1243 int mismatchingPixels = 0; | 1243 int mismatchingPixels = 0; |
1244 static const int maxMismatchesToReport = 50; | 1244 static const int maxMismatchesToReport = 50; |
1245 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { | 1245 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { |
1246 int layerY = bitmapY + rect.y(); | 1246 int layerY = bitmapY + rect.y(); |
1247 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { | 1247 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { |
1248 int layerX = bitmapX + rect.x(); | 1248 int layerX = bitmapX + rect.x(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1290 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
1291 if (!layer) { | 1291 if (!layer) { |
1292 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1292 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
1293 return; | 1293 return; |
1294 } | 1294 } |
1295 | 1295 |
1296 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1296 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1297 LOG(INFO) << output.utf8().data(); | 1297 LOG(INFO) << output.utf8().data(); |
1298 } | 1298 } |
1299 #endif | 1299 #endif |
OLD | NEW |