Chromium Code Reviews| Index: Source/platform/graphics/paint/DisplayItemList.cpp |
| diff --git a/Source/platform/graphics/paint/DisplayItemList.cpp b/Source/platform/graphics/paint/DisplayItemList.cpp |
| index 24227418e7fa6ce1df0b008ca6f5c38a18e2876e..2338bdde40d99165eebc440065cabd8c48499a01 100644 |
| --- a/Source/platform/graphics/paint/DisplayItemList.cpp |
| +++ b/Source/platform/graphics/paint/DisplayItemList.cpp |
| @@ -296,6 +296,20 @@ static void showUnderInvalidationError(const char* reason, const DisplayItem& di |
| #endif // NDEBUG |
| } |
| +static bool bitmapIsAllZero(const SkBitmap& bitmap) |
| +{ |
| + bitmap.lockPixels(); |
| + bool result = true; |
| + for (int x = 0; result && x < bitmap.width(); ++x) { |
| + for (int y = 0; result && y < bitmap.height(); ++y) { |
| + if (SkColorSetA(bitmap.getColor(x, y), 0) != SK_ColorTRANSPARENT) |
| + result = false; |
| + } |
| + } |
| + bitmap.unlockPixels(); |
| + return result; |
| +} |
| + |
| void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItem& displayItem, DisplayItemIndicesByClientMap& displayItemIndicesByClient) |
| { |
| ASSERT(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()); |
| @@ -337,6 +351,21 @@ void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItem& displ |
| } |
| } |
| + SkRect rect = newPicture->cullRect(); |
|
chrishtr
2015/06/01 19:04:28
I think this would induce too many false negatives
Xianzhu
2015/06/01 19:10:15
Could you give more details about the case of fals
|
| + if (rect == oldPicture->cullRect()) { |
| + // Some pictures may have same contents but different representations. |
| + SkBitmap bitmap; |
| + bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height())); |
| + SkCanvas canvas(bitmap); |
| + canvas.translate(-rect.x(), -rect.y()); |
| + canvas.drawPicture(oldPicture.get()); |
| + SkPaint diffPaint; |
| + diffPaint.setXfermodeMode(SkXfermode::kDifference_Mode); |
| + canvas.drawPicture(newPicture.get(), nullptr, &diffPaint); |
| + if (bitmapIsAllZero(bitmap)) // Contents are the same. |
| + return; |
| + } |
| + |
| showUnderInvalidationError("ERROR: under-invalidation: display item changed", displayItem); |
| #ifndef NDEBUG |
| String oldPictureDebugString = oldPicture ? pictureAsDebugString(oldPicture.get()) : "None"; |