| Index: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
|
| index 82caadbd4232b58397bcdcd435dc635b10441011..535e0b8df3925bc173501c89ee780ae522d04034 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
|
| @@ -80,6 +80,7 @@
|
| PaintInvalidationReason reason;
|
| };
|
|
|
| +#if DCHECK_IS_ON()
|
| struct UnderPaintInvalidation {
|
| DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| int x;
|
| @@ -87,13 +88,16 @@
|
| SkColor oldPixel;
|
| SkColor newPixel;
|
| };
|
| +#endif
|
|
|
| struct PaintInvalidationTracking {
|
| DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| Vector<PaintInvalidationInfo> trackedPaintInvalidations;
|
| +#if DCHECK_IS_ON()
|
| RefPtr<SkPicture> lastPaintedPicture;
|
| Region paintInvalidationRegionSinceLastPaint;
|
| Vector<UnderPaintInvalidation> underPaintInvalidations;
|
| +#endif
|
| };
|
|
|
| typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidationTrackingMap;
|
| @@ -332,13 +336,15 @@
|
| {
|
| if (paintWithoutCommit(interestRect, disabledMode)) {
|
| getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSubpixelAccumulation());
|
| - if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
|
| +#if DCHECK_IS_ON()
|
| + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) {
|
| RefPtr<SkPicture> newPicture = capturePicture();
|
| checkPaintUnderInvalidations(*newPicture);
|
| PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(this, PaintInvalidationTracking()).storedValue->value;
|
| tracking.lastPaintedPicture = newPicture;
|
| tracking.paintInvalidationRegionSinceLastPaint = Region();
|
| }
|
| +#endif
|
| }
|
| }
|
|
|
| @@ -548,7 +554,7 @@
|
| if (it == paintInvalidationTrackingMap().end())
|
| return;
|
|
|
| - if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled())
|
| + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
|
| it->value.trackedPaintInvalidations.clear();
|
| else
|
| paintInvalidationTrackingMap().remove(it);
|
| @@ -574,12 +580,14 @@
|
| tracking.trackedPaintInvalidations.append(info);
|
| }
|
|
|
| - if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
|
| +#if DCHECK_IS_ON()
|
| + if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) {
|
| // TODO(crbug.com/496260): Some antialiasing effects overflows the paint invalidation rect.
|
| IntRect r = rect;
|
| r.inflate(1);
|
| tracking.paintInvalidationRegionSinceLastPaint.unite(r);
|
| }
|
| +#endif
|
| }
|
|
|
| static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const PaintInvalidationInfo& b)
|
| @@ -772,7 +780,7 @@
|
| }
|
| json->setArray("paintInvalidations", std::move(paintInvalidationsJSON));
|
| }
|
| -
|
| +#if DCHECK_IS_ON()
|
| Vector<UnderPaintInvalidation>& underPaintInvalidations = it->value.underPaintInvalidations;
|
| if (!underPaintInvalidations.isEmpty()) {
|
| std::unique_ptr<JSONArray> underPaintInvalidationsJSON = JSONArray::create();
|
| @@ -786,6 +794,7 @@
|
| }
|
| json->setArray("underPaintInvalidations", std::move(underPaintInvalidationsJSON));
|
| }
|
| +#endif
|
| }
|
| }
|
|
|
| @@ -1244,6 +1253,8 @@
|
| layer->setCompositorMutableProperties(properties);
|
| }
|
|
|
| +#if DCHECK_IS_ON()
|
| +
|
| PassRefPtr<SkPicture> GraphicsLayer::capturePicture()
|
| {
|
| if (!drawsContent())
|
| @@ -1289,19 +1300,11 @@
|
| int width = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cullRect().width(), newPicture.cullRect().width())));
|
| int height = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cullRect().height(), newPicture.cullRect().height())));
|
| oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
|
| - {
|
| - SkCanvas canvas(oldBitmap);
|
| - canvas.clear(SK_ColorTRANSPARENT);
|
| - canvas.drawPicture(tracking.lastPaintedPicture.get());
|
| - }
|
| + SkCanvas(oldBitmap).drawPicture(tracking.lastPaintedPicture.get());
|
|
|
| SkBitmap newBitmap;
|
| newBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height));
|
| - {
|
| - SkCanvas canvas(newBitmap);
|
| - canvas.clear(SK_ColorTRANSPARENT);
|
| - canvas.drawPicture(&newPicture);
|
| - }
|
| + SkCanvas(newBitmap).drawPicture(&newPicture);
|
|
|
| oldBitmap.lockPixels();
|
| newBitmap.lockPixels();
|
| @@ -1320,7 +1323,7 @@
|
| LOG(ERROR) << "and more...";
|
| }
|
| ++mismatchingPixels;
|
| - *newBitmap.getAddr32(x, y) = SkColorSetARGB(0x80, 0xFF, 0, 0xFF); // Half translucent magenta.
|
| + *newBitmap.getAddr32(x, y) = SK_ColorRED;
|
| } else {
|
| *newBitmap.getAddr32(x, y) = SK_ColorTRANSPARENT;
|
| }
|
| @@ -1339,6 +1342,8 @@
|
| getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFromLayoutObjectWithSubpixelAccumulation());
|
| }
|
|
|
| +#endif // DCHECK_IS_ON()
|
| +
|
| } // namespace blink
|
|
|
| #ifndef NDEBUG
|
|
|