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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp

Issue 2874553002: [SPv2] Fix layout test crashes about raster invalidation (Closed)
Patch Set: - Created 3 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 unified diff | Download patch
OLDNEW
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (PaintWithoutCommit(interest_rect, disabled_mode)) { 279 if (PaintWithoutCommit(interest_rect, disabled_mode)) {
280 GetPaintController().CommitNewDisplayItems( 280 GetPaintController().CommitNewDisplayItems(
281 OffsetFromLayoutObjectWithSubpixelAccumulation()); 281 OffsetFromLayoutObjectWithSubpixelAccumulation());
282 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { 282 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
283 sk_sp<PaintRecord> record = CaptureRecord(); 283 sk_sp<PaintRecord> record = CaptureRecord();
284 CheckPaintUnderInvalidations(record); 284 CheckPaintUnderInvalidations(record);
285 RasterInvalidationTracking& tracking = 285 RasterInvalidationTracking& tracking =
286 GetRasterInvalidationTrackingMap().Add(this); 286 GetRasterInvalidationTrackingMap().Add(this);
287 tracking.last_painted_record = std::move(record); 287 tracking.last_painted_record = std::move(record);
288 tracking.last_interest_rect = previous_interest_rect_; 288 tracking.last_interest_rect = previous_interest_rect_;
289 tracking.raster_invalidation_region_since_last_paint = Region(); 289 tracking.invalidation_region_since_last_paint = Region();
290 } 290 }
291 } 291 }
292 } 292 }
293 293
294 bool GraphicsLayer::PaintWithoutCommit( 294 bool GraphicsLayer::PaintWithoutCommit(
295 const IntRect* interest_rect, 295 const IntRect* interest_rect,
296 GraphicsContext::DisabledMode disabled_mode) { 296 GraphicsContext::DisabledMode disabled_mode) {
297 DCHECK(DrawsContent()); 297 DCHECK(DrawsContent());
298 298
299 if (!client_) 299 if (!client_)
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 is_tracking_raster_invalidations_ = tracks_raster_invalidations; 475 is_tracking_raster_invalidations_ = tracks_raster_invalidations;
476 } 476 }
477 477
478 void GraphicsLayer::ResetTrackedRasterInvalidations() { 478 void GraphicsLayer::ResetTrackedRasterInvalidations() {
479 RasterInvalidationTracking* tracking = 479 RasterInvalidationTracking* tracking =
480 GetRasterInvalidationTrackingMap().Find(this); 480 GetRasterInvalidationTrackingMap().Find(this);
481 if (!tracking) 481 if (!tracking)
482 return; 482 return;
483 483
484 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) 484 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled())
485 tracking->tracked_raster_invalidations.clear(); 485 tracking->tracked_invalidations.clear();
486 else 486 else
487 GetRasterInvalidationTrackingMap().Remove(this); 487 GetRasterInvalidationTrackingMap().Remove(this);
488 } 488 }
489 489
490 bool GraphicsLayer::HasTrackedRasterInvalidations() const { 490 bool GraphicsLayer::HasTrackedRasterInvalidations() const {
491 if (auto* tracking = GetRasterInvalidationTracking()) 491 if (auto* tracking = GetRasterInvalidationTracking())
492 return !tracking->tracked_raster_invalidations.IsEmpty(); 492 return !tracking->tracked_invalidations.IsEmpty();
493 return false; 493 return false;
494 } 494 }
495 495
496 const RasterInvalidationTracking* GraphicsLayer::GetRasterInvalidationTracking() 496 const RasterInvalidationTracking* GraphicsLayer::GetRasterInvalidationTracking()
497 const { 497 const {
498 return GetRasterInvalidationTrackingMap().Find(this); 498 return GetRasterInvalidationTrackingMap().Find(this);
499 } 499 }
500 500
501 void GraphicsLayer::TrackRasterInvalidation(const DisplayItemClient& client, 501 void GraphicsLayer::TrackRasterInvalidation(const DisplayItemClient& client,
502 const IntRect& rect, 502 const IntRect& rect,
503 PaintInvalidationReason reason) { 503 PaintInvalidationReason reason) {
504 if (!IsTrackingOrCheckingRasterInvalidations() || rect.IsEmpty()) 504 if (!IsTrackingOrCheckingRasterInvalidations() || rect.IsEmpty())
505 return; 505 return;
506 506
507 RasterInvalidationTracking& tracking = 507 RasterInvalidationInfo info;
508 GetRasterInvalidationTrackingMap().Add(this); 508 info.client = &client;
509 509 info.client_debug_name = client.DebugName();
510 if (is_tracking_raster_invalidations_) { 510 info.rect = rect;
511 RasterInvalidationInfo info; 511 info.reason = reason;
512 info.client = &client; 512 GetRasterInvalidationTrackingMap().AddInvalidation(this, info);
513 info.client_debug_name = client.DebugName();
514 info.rect = rect;
515 info.reason = reason;
516 tracking.tracked_raster_invalidations.push_back(info);
517 }
518
519 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
chrishtr 2017/05/10 17:25:33 No longer needed?
Xianzhu 2017/05/10 18:27:01 This is moved into RasterInvalidationTrackingMap::
520 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint
521 // invalidation rect.
522 IntRect r = rect;
523 r.Inflate(1);
524 tracking.raster_invalidation_region_since_last_paint.Unite(r);
525 }
526 } 513 }
527 514
528 template <typename T> 515 template <typename T>
529 static std::unique_ptr<JSONArray> PointAsJSONArray(const T& point) { 516 static std::unique_ptr<JSONArray> PointAsJSONArray(const T& point) {
530 std::unique_ptr<JSONArray> array = JSONArray::Create(); 517 std::unique_ptr<JSONArray> array = JSONArray::Create();
531 array->PushDouble(point.X()); 518 array->PushDouble(point.X());
532 array->PushDouble(point.Y()); 519 array->PushDouble(point.Y());
533 return array; 520 return array;
534 } 521 }
535 522
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1246
1260 int mismatching_pixels = 0; 1247 int mismatching_pixels = 0;
1261 static const int kMaxMismatchesToReport = 50; 1248 static const int kMaxMismatchesToReport = 50;
1262 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) { 1249 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) {
1263 int layer_y = bitmap_y + rect.Y(); 1250 int layer_y = bitmap_y + rect.Y();
1264 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) { 1251 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) {
1265 int layer_x = bitmap_x + rect.X(); 1252 int layer_x = bitmap_x + rect.X();
1266 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y); 1253 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y);
1267 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y); 1254 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y);
1268 if (PixelsDiffer(old_pixel, new_pixel) && 1255 if (PixelsDiffer(old_pixel, new_pixel) &&
1269 !tracking->raster_invalidation_region_since_last_paint.Contains( 1256 !tracking->invalidation_region_since_last_paint.Contains(
1270 IntPoint(layer_x, layer_y))) { 1257 IntPoint(layer_x, layer_y))) {
1271 if (mismatching_pixels < kMaxMismatchesToReport) { 1258 if (mismatching_pixels < kMaxMismatchesToReport) {
1272 UnderPaintInvalidation under_paint_invalidation = { 1259 UnderRasterInvalidation under_invalidation = {layer_x, layer_y,
1273 layer_x, layer_y, old_pixel, new_pixel}; 1260 old_pixel, new_pixel};
1274 tracking->under_paint_invalidations.push_back( 1261 tracking->under_invalidations.push_back(under_invalidation);
1275 under_paint_invalidation);
1276 LOG(ERROR) << DebugName() 1262 LOG(ERROR) << DebugName()
1277 << " Uninvalidated old/new pixels mismatch at " << layer_x 1263 << " Uninvalidated old/new pixels mismatch at " << layer_x
1278 << "," << layer_y << " old:" << std::hex << old_pixel 1264 << "," << layer_y << " old:" << std::hex << old_pixel
1279 << " new:" << new_pixel; 1265 << " new:" << new_pixel;
1280 } else if (mismatching_pixels == kMaxMismatchesToReport) { 1266 } else if (mismatching_pixels == kMaxMismatchesToReport) {
1281 LOG(ERROR) << "and more..."; 1267 LOG(ERROR) << "and more...";
1282 } 1268 }
1283 ++mismatching_pixels; 1269 ++mismatching_pixels;
1284 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = 1270 *new_bitmap.getAddr32(bitmap_x, bitmap_y) =
1285 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. 1271 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red.
(...skipping 20 matching lines...) Expand all
1306 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { 1292 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) {
1307 if (!layer) { 1293 if (!layer) {
1308 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; 1294 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil).";
1309 return; 1295 return;
1310 } 1296 }
1311 1297
1312 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo); 1298 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo);
1313 LOG(INFO) << output.Utf8().data(); 1299 LOG(INFO) << output.Utf8().data();
1314 } 1300 }
1315 #endif 1301 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698