| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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->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->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 RasterInvalidationTracking& tracking = |
| 508 GetRasterInvalidationTrackingMap().Add(this); | 508 GetRasterInvalidationTrackingMap().Add(this); |
| 509 | 509 |
| 510 if (is_tracking_raster_invalidations_) { | 510 if (is_tracking_raster_invalidations_) { |
| 511 RasterInvalidationInfo info; | 511 RasterInvalidationInfo info; |
| 512 info.client = &client; | 512 info.client = &client; |
| 513 info.client_debug_name = client.DebugName(); | 513 info.client_debug_name = client.DebugName(); |
| 514 info.rect = rect; | 514 info.rect = rect; |
| 515 info.reason = reason; | 515 info.reason = reason; |
| 516 tracking.tracked_raster_invalidations.push_back(info); | 516 tracking.invalidations.push_back(info); |
| 517 } | 517 } |
| 518 | 518 |
| 519 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 519 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 520 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint | 520 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint |
| 521 // invalidation rect. | 521 // invalidation rect. |
| 522 IntRect r = rect; | 522 IntRect r = rect; |
| 523 r.Inflate(1); | 523 r.Inflate(1); |
| 524 tracking.raster_invalidation_region_since_last_paint.Unite(r); | 524 tracking.invalidation_region_since_last_paint.Unite(r); |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 | 527 |
| 528 template <typename T> | 528 template <typename T> |
| 529 static std::unique_ptr<JSONArray> PointAsJSONArray(const T& point) { | 529 static std::unique_ptr<JSONArray> PointAsJSONArray(const T& point) { |
| 530 std::unique_ptr<JSONArray> array = JSONArray::Create(); | 530 std::unique_ptr<JSONArray> array = JSONArray::Create(); |
| 531 array->PushDouble(point.X()); | 531 array->PushDouble(point.X()); |
| 532 array->PushDouble(point.Y()); | 532 array->PushDouble(point.Y()); |
| 533 return array; | 533 return array; |
| 534 } | 534 } |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1245 |
| 1246 int mismatching_pixels = 0; | 1246 int mismatching_pixels = 0; |
| 1247 static const int kMaxMismatchesToReport = 50; | 1247 static const int kMaxMismatchesToReport = 50; |
| 1248 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) { | 1248 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) { |
| 1249 int layer_y = bitmap_y + rect.Y(); | 1249 int layer_y = bitmap_y + rect.Y(); |
| 1250 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) { | 1250 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) { |
| 1251 int layer_x = bitmap_x + rect.X(); | 1251 int layer_x = bitmap_x + rect.X(); |
| 1252 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y); | 1252 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y); |
| 1253 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y); | 1253 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y); |
| 1254 if (PixelsDiffer(old_pixel, new_pixel) && | 1254 if (PixelsDiffer(old_pixel, new_pixel) && |
| 1255 !tracking->raster_invalidation_region_since_last_paint.Contains( | 1255 !tracking->invalidation_region_since_last_paint.Contains( |
| 1256 IntPoint(layer_x, layer_y))) { | 1256 IntPoint(layer_x, layer_y))) { |
| 1257 if (mismatching_pixels < kMaxMismatchesToReport) { | 1257 if (mismatching_pixels < kMaxMismatchesToReport) { |
| 1258 UnderPaintInvalidation under_paint_invalidation = { | 1258 UnderRasterInvalidation under_invalidation = {layer_x, layer_y, |
| 1259 layer_x, layer_y, old_pixel, new_pixel}; | 1259 old_pixel, new_pixel}; |
| 1260 tracking->under_paint_invalidations.push_back( | 1260 tracking->under_invalidations.push_back(under_invalidation); |
| 1261 under_paint_invalidation); | |
| 1262 LOG(ERROR) << DebugName() | 1261 LOG(ERROR) << DebugName() |
| 1263 << " Uninvalidated old/new pixels mismatch at " << layer_x | 1262 << " Uninvalidated old/new pixels mismatch at " << layer_x |
| 1264 << "," << layer_y << " old:" << std::hex << old_pixel | 1263 << "," << layer_y << " old:" << std::hex << old_pixel |
| 1265 << " new:" << new_pixel; | 1264 << " new:" << new_pixel; |
| 1266 } else if (mismatching_pixels == kMaxMismatchesToReport) { | 1265 } else if (mismatching_pixels == kMaxMismatchesToReport) { |
| 1267 LOG(ERROR) << "and more..."; | 1266 LOG(ERROR) << "and more..."; |
| 1268 } | 1267 } |
| 1269 ++mismatching_pixels; | 1268 ++mismatching_pixels; |
| 1270 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = | 1269 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = |
| 1271 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. | 1270 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1292 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1291 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
| 1293 if (!layer) { | 1292 if (!layer) { |
| 1294 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1293 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
| 1295 return; | 1294 return; |
| 1296 } | 1295 } |
| 1297 | 1296 |
| 1298 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo); | 1297 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo); |
| 1299 LOG(INFO) << output.Utf8().data(); | 1298 LOG(INFO) << output.Utf8().data(); |
| 1300 } | 1299 } |
| 1301 #endif | 1300 #endif |
| OLD | NEW |