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

Side by Side 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, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "platform/graphics/paint/DisplayItemList.h" 6 #include "platform/graphics/paint/DisplayItemList.h"
7 7
8 #include "platform/NotImplemented.h" 8 #include "platform/NotImplemented.h"
9 #include "platform/RuntimeEnabledFeatures.h" 9 #include "platform/RuntimeEnabledFeatures.h"
10 #include "platform/TraceEvent.h" 10 #include "platform/TraceEvent.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 static void showUnderInvalidationError(const char* reason, const DisplayItem& di splayItem) 290 static void showUnderInvalidationError(const char* reason, const DisplayItem& di splayItem)
291 { 291 {
292 #ifndef NDEBUG 292 #ifndef NDEBUG
293 WTFLogAlways("%s: %s\nSee http://crbug.com/450725.", reason, displayItem.asD ebugString().utf8().data()); 293 WTFLogAlways("%s: %s\nSee http://crbug.com/450725.", reason, displayItem.asD ebugString().utf8().data());
294 #else 294 #else
295 WTFLogAlways("%s. Run debug build to get more details\nSee http://crbug.com/ 450725.", reason); 295 WTFLogAlways("%s. Run debug build to get more details\nSee http://crbug.com/ 450725.", reason);
296 #endif // NDEBUG 296 #endif // NDEBUG
297 } 297 }
298 298
299 static bool bitmapIsAllZero(const SkBitmap& bitmap)
300 {
301 bitmap.lockPixels();
302 bool result = true;
303 for (int x = 0; result && x < bitmap.width(); ++x) {
304 for (int y = 0; result && y < bitmap.height(); ++y) {
305 if (SkColorSetA(bitmap.getColor(x, y), 0) != SK_ColorTRANSPARENT)
306 result = false;
307 }
308 }
309 bitmap.unlockPixels();
310 return result;
311 }
312
299 void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItem& displ ayItem, DisplayItemIndicesByClientMap& displayItemIndicesByClient) 313 void DisplayItemList::checkCachedDisplayItemIsUnchanged(const DisplayItem& displ ayItem, DisplayItemIndicesByClientMap& displayItemIndicesByClient)
300 { 314 {
301 ASSERT(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled ()); 315 ASSERT(RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled ());
302 316
303 if (!displayItem.isDrawing() || !clientCacheIsValid(displayItem.client())) 317 if (!displayItem.isDrawing() || !clientCacheIsValid(displayItem.client()))
304 return; 318 return;
305 319
306 if (static_cast<const DrawingDisplayItem&>(displayItem).skipUnderInvalidatio nChecking()) 320 if (static_cast<const DrawingDisplayItem&>(displayItem).skipUnderInvalidatio nChecking())
307 return; 321 return;
308 322
(...skipping 21 matching lines...) Expand all
330 oldPicture->serialize(&oldPictureSerialized); 344 oldPicture->serialize(&oldPictureSerialized);
331 345
332 if (newPictureSerialized.bytesWritten() == oldPictureSerialized.bytesWri tten()) { 346 if (newPictureSerialized.bytesWritten() == oldPictureSerialized.bytesWri tten()) {
333 RefPtr<SkData> oldData = adoptRef(oldPictureSerialized.copyToData()) ; 347 RefPtr<SkData> oldData = adoptRef(oldPictureSerialized.copyToData()) ;
334 RefPtr<SkData> newData = adoptRef(newPictureSerialized.copyToData()) ; 348 RefPtr<SkData> newData = adoptRef(newPictureSerialized.copyToData()) ;
335 if (oldData->equals(newData.get())) 349 if (oldData->equals(newData.get()))
336 return; 350 return;
337 } 351 }
338 } 352 }
339 353
354 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
355 if (rect == oldPicture->cullRect()) {
356 // Some pictures may have same contents but different representations.
357 SkBitmap bitmap;
358 bitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height( )));
359 SkCanvas canvas(bitmap);
360 canvas.translate(-rect.x(), -rect.y());
361 canvas.drawPicture(oldPicture.get());
362 SkPaint diffPaint;
363 diffPaint.setXfermodeMode(SkXfermode::kDifference_Mode);
364 canvas.drawPicture(newPicture.get(), nullptr, &diffPaint);
365 if (bitmapIsAllZero(bitmap)) // Contents are the same.
366 return;
367 }
368
340 showUnderInvalidationError("ERROR: under-invalidation: display item changed" , displayItem); 369 showUnderInvalidationError("ERROR: under-invalidation: display item changed" , displayItem);
341 #ifndef NDEBUG 370 #ifndef NDEBUG
342 String oldPictureDebugString = oldPicture ? pictureAsDebugString(oldPicture. get()) : "None"; 371 String oldPictureDebugString = oldPicture ? pictureAsDebugString(oldPicture. get()) : "None";
343 String newPictureDebugString = newPicture ? pictureAsDebugString(newPicture. get()) : "None"; 372 String newPictureDebugString = newPicture ? pictureAsDebugString(newPicture. get()) : "None";
344 WTFLogAlways("old picture:\n%s\n", oldPictureDebugString.utf8().data()); 373 WTFLogAlways("old picture:\n%s\n", oldPictureDebugString.utf8().data());
345 WTFLogAlways("new picture:\n%s\n", newPictureDebugString.utf8().data()); 374 WTFLogAlways("new picture:\n%s\n", newPictureDebugString.utf8().data());
346 #endif // NDEBUG 375 #endif // NDEBUG
347 376
348 ASSERT_NOT_REACHED(); 377 ASSERT_NOT_REACHED();
349 } 378 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 422
394 void DisplayItemList::replay(GraphicsContext& context) const 423 void DisplayItemList::replay(GraphicsContext& context) const
395 { 424 {
396 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); 425 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay");
397 ASSERT(m_newDisplayItems.isEmpty()); 426 ASSERT(m_newDisplayItems.isEmpty());
398 for (auto& displayItem : m_currentDisplayItems) 427 for (auto& displayItem : m_currentDisplayItems)
399 displayItem->replay(context); 428 displayItem->replay(context);
400 } 429 }
401 430
402 } // namespace blink 431 } // namespace blink
OLDNEW
« 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