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

Unified Diff: Source/platform/graphics/paint/DisplayItemList.cpp

Issue 1160223004: Avoid false-positives of under-invalidation checking (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698