| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 struct PaintInvalidationInfo { | 74 struct PaintInvalidationInfo { |
| 75 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 75 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 76 // This is for comparison only. Don't dereference because the client may hav
e died. | 76 // This is for comparison only. Don't dereference because the client may hav
e died. |
| 77 const DisplayItemClient* client; | 77 const DisplayItemClient* client; |
| 78 String clientDebugName; | 78 String clientDebugName; |
| 79 IntRect rect; | 79 IntRect rect; |
| 80 PaintInvalidationReason reason; | 80 PaintInvalidationReason reason; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 #if DCHECK_IS_ON() |
| 83 struct UnderPaintInvalidation { | 84 struct UnderPaintInvalidation { |
| 84 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 85 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 85 int x; | 86 int x; |
| 86 int y; | 87 int y; |
| 87 SkColor oldPixel; | 88 SkColor oldPixel; |
| 88 SkColor newPixel; | 89 SkColor newPixel; |
| 89 }; | 90 }; |
| 91 #endif |
| 90 | 92 |
| 91 struct PaintInvalidationTracking { | 93 struct PaintInvalidationTracking { |
| 92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 94 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 93 Vector<PaintInvalidationInfo> trackedPaintInvalidations; | 95 Vector<PaintInvalidationInfo> trackedPaintInvalidations; |
| 96 #if DCHECK_IS_ON() |
| 94 sk_sp<SkPicture> lastPaintedPicture; | 97 sk_sp<SkPicture> lastPaintedPicture; |
| 95 Region paintInvalidationRegionSinceLastPaint; | 98 Region paintInvalidationRegionSinceLastPaint; |
| 96 Vector<UnderPaintInvalidation> underPaintInvalidations; | 99 Vector<UnderPaintInvalidation> underPaintInvalidations; |
| 100 #endif |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati
onTrackingMap; | 103 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati
onTrackingMap; |
| 100 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() | 104 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() |
| 101 { | 105 { |
| 102 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); | 106 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); |
| 103 return map; | 107 return map; |
| 104 } | 108 } |
| 105 | 109 |
| 106 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client
) | 110 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client
) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 329 |
| 326 IntRect GraphicsLayer::interestRect() | 330 IntRect GraphicsLayer::interestRect() |
| 327 { | 331 { |
| 328 return m_previousInterestRect; | 332 return m_previousInterestRect; |
| 329 } | 333 } |
| 330 | 334 |
| 331 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) | 335 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) |
| 332 { | 336 { |
| 333 if (paintWithoutCommit(interestRect, disabledMode)) { | 337 if (paintWithoutCommit(interestRect, disabledMode)) { |
| 334 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); | 338 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); |
| 335 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 339 #if DCHECK_IS_ON() |
| 340 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable
d()) { |
| 336 sk_sp<SkPicture> newPicture = capturePicture(); | 341 sk_sp<SkPicture> newPicture = capturePicture(); |
| 337 checkPaintUnderInvalidations(*newPicture); | 342 checkPaintUnderInvalidations(*newPicture); |
| 338 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap()
.add(this, PaintInvalidationTracking()).storedValue->value; | 343 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap()
.add(this, PaintInvalidationTracking()).storedValue->value; |
| 339 tracking.lastPaintedPicture = std::move(newPicture); | 344 tracking.lastPaintedPicture = std::move(newPicture); |
| 340 tracking.paintInvalidationRegionSinceLastPaint = Region(); | 345 tracking.paintInvalidationRegionSinceLastPaint = Region(); |
| 341 } | 346 } |
| 347 #endif |
| 342 } | 348 } |
| 343 } | 349 } |
| 344 | 350 |
| 345 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) | 351 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) |
| 346 { | 352 { |
| 347 ASSERT(drawsContent()); | 353 ASSERT(drawsContent()); |
| 348 | 354 |
| 349 if (!m_client) | 355 if (!m_client) |
| 350 return false; | 356 return false; |
| 351 if (firstPaintInvalidationTrackingEnabled()) | 357 if (firstPaintInvalidationTrackingEnabled()) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 resetTrackedPaintInvalidations(); | 547 resetTrackedPaintInvalidations(); |
| 542 m_isTrackingPaintInvalidations = tracksPaintInvalidations; | 548 m_isTrackingPaintInvalidations = tracksPaintInvalidations; |
| 543 } | 549 } |
| 544 | 550 |
| 545 void GraphicsLayer::resetTrackedPaintInvalidations() | 551 void GraphicsLayer::resetTrackedPaintInvalidations() |
| 546 { | 552 { |
| 547 auto it = paintInvalidationTrackingMap().find(this); | 553 auto it = paintInvalidationTrackingMap().find(this); |
| 548 if (it == paintInvalidationTrackingMap().end()) | 554 if (it == paintInvalidationTrackingMap().end()) |
| 549 return; | 555 return; |
| 550 | 556 |
| 551 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 557 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) |
| 552 it->value.trackedPaintInvalidations.clear(); | 558 it->value.trackedPaintInvalidations.clear(); |
| 553 else | 559 else |
| 554 paintInvalidationTrackingMap().remove(it); | 560 paintInvalidationTrackingMap().remove(it); |
| 555 } | 561 } |
| 556 | 562 |
| 557 bool GraphicsLayer::hasTrackedPaintInvalidations() const | 563 bool GraphicsLayer::hasTrackedPaintInvalidations() const |
| 558 { | 564 { |
| 559 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 565 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); |
| 560 if (it != paintInvalidationTrackingMap().end()) | 566 if (it != paintInvalidationTrackingMap().end()) |
| 561 return !it->value.trackedPaintInvalidations.isEmpty(); | 567 return !it->value.trackedPaintInvalidations.isEmpty(); |
| 562 return false; | 568 return false; |
| 563 } | 569 } |
| 564 | 570 |
| 565 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) | 571 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) |
| 566 { | 572 { |
| 567 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) | 573 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) |
| 568 return; | 574 return; |
| 569 | 575 |
| 570 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; | 576 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; |
| 571 | 577 |
| 572 if (m_isTrackingPaintInvalidations) { | 578 if (m_isTrackingPaintInvalidations) { |
| 573 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason
}; | 579 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason
}; |
| 574 tracking.trackedPaintInvalidations.append(info); | 580 tracking.trackedPaintInvalidations.append(info); |
| 575 } | 581 } |
| 576 | 582 |
| 577 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 583 #if DCHECK_IS_ON() |
| 584 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
{ |
| 578 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. | 585 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. |
| 579 IntRect r = rect; | 586 IntRect r = rect; |
| 580 r.inflate(1); | 587 r.inflate(1); |
| 581 tracking.paintInvalidationRegionSinceLastPaint.unite(r); | 588 tracking.paintInvalidationRegionSinceLastPaint.unite(r); |
| 582 } | 589 } |
| 590 #endif |
| 583 } | 591 } |
| 584 | 592 |
| 585 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) | 593 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) |
| 586 { | 594 { |
| 587 // Sort by rect first, bigger rects before smaller ones. | 595 // Sort by rect first, bigger rects before smaller ones. |
| 588 if (a.rect.width() != b.rect.width()) | 596 if (a.rect.width() != b.rect.width()) |
| 589 return a.rect.width() > b.rect.width(); | 597 return a.rect.width() > b.rect.width(); |
| 590 if (a.rect.height() != b.rect.height()) | 598 if (a.rect.height() != b.rect.height()) |
| 591 return a.rect.height() > b.rect.height(); | 599 return a.rect.height() > b.rect.height(); |
| 592 if (a.rect.x() != b.rect.x()) | 600 if (a.rect.x() != b.rect.x()) |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 for (auto& info : infos) { | 773 for (auto& info : infos) { |
| 766 std::unique_ptr<JSONObject> infoJSON = JSONObject::create(); | 774 std::unique_ptr<JSONObject> infoJSON = JSONObject::create(); |
| 767 infoJSON->setString("object", info.clientDebugName); | 775 infoJSON->setString("object", info.clientDebugName); |
| 768 if (!info.rect.isEmpty()) | 776 if (!info.rect.isEmpty()) |
| 769 infoJSON->setArray("rect", rectAsJSONArray(info.rect)); | 777 infoJSON->setArray("rect", rectAsJSONArray(info.rect)); |
| 770 infoJSON->setString("reason", paintInvalidationReasonToStrin
g(info.reason)); | 778 infoJSON->setString("reason", paintInvalidationReasonToStrin
g(info.reason)); |
| 771 paintInvalidationsJSON->pushObject(std::move(infoJSON)); | 779 paintInvalidationsJSON->pushObject(std::move(infoJSON)); |
| 772 } | 780 } |
| 773 json->setArray("paintInvalidations", std::move(paintInvalidation
sJSON)); | 781 json->setArray("paintInvalidations", std::move(paintInvalidation
sJSON)); |
| 774 } | 782 } |
| 775 | 783 #if DCHECK_IS_ON() |
| 776 Vector<UnderPaintInvalidation>& underPaintInvalidations = it->value.
underPaintInvalidations; | 784 Vector<UnderPaintInvalidation>& underPaintInvalidations = it->value.
underPaintInvalidations; |
| 777 if (!underPaintInvalidations.isEmpty()) { | 785 if (!underPaintInvalidations.isEmpty()) { |
| 778 std::unique_ptr<JSONArray> underPaintInvalidationsJSON = JSONArr
ay::create(); | 786 std::unique_ptr<JSONArray> underPaintInvalidationsJSON = JSONArr
ay::create(); |
| 779 for (auto& underPaintInvalidation : underPaintInvalidations) { | 787 for (auto& underPaintInvalidation : underPaintInvalidations) { |
| 780 std::unique_ptr<JSONObject> underPaintInvalidationJSON = JSO
NObject::create(); | 788 std::unique_ptr<JSONObject> underPaintInvalidationJSON = JSO
NObject::create(); |
| 781 underPaintInvalidationJSON->setDouble("x", underPaintInvalid
ation.x); | 789 underPaintInvalidationJSON->setDouble("x", underPaintInvalid
ation.x); |
| 782 underPaintInvalidationJSON->setDouble("y", underPaintInvalid
ation.x); | 790 underPaintInvalidationJSON->setDouble("y", underPaintInvalid
ation.x); |
| 783 underPaintInvalidationJSON->setString("oldPixel", Color(unde
rPaintInvalidation.oldPixel).nameForLayoutTreeAsText()); | 791 underPaintInvalidationJSON->setString("oldPixel", Color(unde
rPaintInvalidation.oldPixel).nameForLayoutTreeAsText()); |
| 784 underPaintInvalidationJSON->setString("newPixel", Color(unde
rPaintInvalidation.newPixel).nameForLayoutTreeAsText()); | 792 underPaintInvalidationJSON->setString("newPixel", Color(unde
rPaintInvalidation.newPixel).nameForLayoutTreeAsText()); |
| 785 underPaintInvalidationsJSON->pushObject(std::move(underPaint
InvalidationJSON)); | 793 underPaintInvalidationsJSON->pushObject(std::move(underPaint
InvalidationJSON)); |
| 786 } | 794 } |
| 787 json->setArray("underPaintInvalidations", std::move(underPaintIn
validationsJSON)); | 795 json->setArray("underPaintInvalidations", std::move(underPaintIn
validationsJSON)); |
| 788 } | 796 } |
| 797 #endif |
| 789 } | 798 } |
| 790 } | 799 } |
| 791 | 800 |
| 792 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { | 801 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { |
| 793 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); | 802 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); |
| 794 if (m_paintingPhase & GraphicsLayerPaintBackground) | 803 if (m_paintingPhase & GraphicsLayerPaintBackground) |
| 795 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); | 804 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); |
| 796 if (m_paintingPhase & GraphicsLayerPaintForeground) | 805 if (m_paintingPhase & GraphicsLayerPaintForeground) |
| 797 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); | 806 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); |
| 798 if (m_paintingPhase & GraphicsLayerPaintMask) | 807 if (m_paintingPhase & GraphicsLayerPaintMask) |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 if (WebLayer* layer = platformLayer()) | 1246 if (WebLayer* layer = platformLayer()) |
| 1238 layer->setElementId(id); | 1247 layer->setElementId(id); |
| 1239 } | 1248 } |
| 1240 | 1249 |
| 1241 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties) | 1250 void GraphicsLayer::setCompositorMutableProperties(uint32_t properties) |
| 1242 { | 1251 { |
| 1243 if (WebLayer* layer = platformLayer()) | 1252 if (WebLayer* layer = platformLayer()) |
| 1244 layer->setCompositorMutableProperties(properties); | 1253 layer->setCompositorMutableProperties(properties); |
| 1245 } | 1254 } |
| 1246 | 1255 |
| 1256 #if DCHECK_IS_ON() |
| 1257 |
| 1247 sk_sp<SkPicture> GraphicsLayer::capturePicture() | 1258 sk_sp<SkPicture> GraphicsLayer::capturePicture() |
| 1248 { | 1259 { |
| 1249 if (!drawsContent()) | 1260 if (!drawsContent()) |
| 1250 return nullptr; | 1261 return nullptr; |
| 1251 | 1262 |
| 1252 IntSize intSize = expandedIntSize(size()); | 1263 IntSize intSize = expandedIntSize(size()); |
| 1253 GraphicsContext graphicsContext(getPaintController()); | 1264 GraphicsContext graphicsContext(getPaintController()); |
| 1254 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); | 1265 graphicsContext.beginRecording(IntRect(IntPoint(0, 0), intSize)); |
| 1255 getPaintController().paintArtifact().replay(graphicsContext); | 1266 getPaintController().paintArtifact().replay(graphicsContext); |
| 1256 return graphicsContext.endRecording(); | 1267 return graphicsContext.endRecording(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1282 if (it == paintInvalidationTrackingMap().end()) | 1293 if (it == paintInvalidationTrackingMap().end()) |
| 1283 return; | 1294 return; |
| 1284 PaintInvalidationTracking& tracking = it->value; | 1295 PaintInvalidationTracking& tracking = it->value; |
| 1285 if (!tracking.lastPaintedPicture) | 1296 if (!tracking.lastPaintedPicture) |
| 1286 return; | 1297 return; |
| 1287 | 1298 |
| 1288 SkBitmap oldBitmap; | 1299 SkBitmap oldBitmap; |
| 1289 int width = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cul
lRect().width(), newPicture.cullRect().width()))); | 1300 int width = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cul
lRect().width(), newPicture.cullRect().width()))); |
| 1290 int height = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cu
llRect().height(), newPicture.cullRect().height()))); | 1301 int height = static_cast<int>(ceilf(std::min(tracking.lastPaintedPicture->cu
llRect().height(), newPicture.cullRect().height()))); |
| 1291 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height)); | 1302 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height)); |
| 1292 { | 1303 SkCanvas(oldBitmap).drawPicture(tracking.lastPaintedPicture.get()); |
| 1293 SkCanvas canvas(oldBitmap); | |
| 1294 canvas.clear(SK_ColorTRANSPARENT); | |
| 1295 canvas.drawPicture(tracking.lastPaintedPicture.get()); | |
| 1296 } | |
| 1297 | 1304 |
| 1298 SkBitmap newBitmap; | 1305 SkBitmap newBitmap; |
| 1299 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height)); | 1306 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(width, height)); |
| 1300 { | 1307 SkCanvas(newBitmap).drawPicture(&newPicture); |
| 1301 SkCanvas canvas(newBitmap); | |
| 1302 canvas.clear(SK_ColorTRANSPARENT); | |
| 1303 canvas.drawPicture(&newPicture); | |
| 1304 } | |
| 1305 | 1308 |
| 1306 oldBitmap.lockPixels(); | 1309 oldBitmap.lockPixels(); |
| 1307 newBitmap.lockPixels(); | 1310 newBitmap.lockPixels(); |
| 1308 int mismatchingPixels = 0; | 1311 int mismatchingPixels = 0; |
| 1309 static const int maxMismatchesToReport = 50; | 1312 static const int maxMismatchesToReport = 50; |
| 1310 for (int y = 0; y < height; ++y) { | 1313 for (int y = 0; y < height; ++y) { |
| 1311 for (int x = 0; x < width; ++x) { | 1314 for (int x = 0; x < width; ++x) { |
| 1312 SkColor oldPixel = oldBitmap.getColor(x, y); | 1315 SkColor oldPixel = oldBitmap.getColor(x, y); |
| 1313 SkColor newPixel = newBitmap.getColor(x, y); | 1316 SkColor newPixel = newBitmap.getColor(x, y); |
| 1314 if (pixelsDiffer(oldPixel, newPixel) && !tracking.paintInvalidationR
egionSinceLastPaint.contains(IntPoint(x, y))) { | 1317 if (pixelsDiffer(oldPixel, newPixel) && !tracking.paintInvalidationR
egionSinceLastPaint.contains(IntPoint(x, y))) { |
| 1315 if (mismatchingPixels < maxMismatchesToReport) { | 1318 if (mismatchingPixels < maxMismatchesToReport) { |
| 1316 UnderPaintInvalidation underPaintInvalidation = { x, y, oldP
ixel, newPixel }; | 1319 UnderPaintInvalidation underPaintInvalidation = { x, y, oldP
ixel, newPixel }; |
| 1317 tracking.underPaintInvalidations.append(underPaintInvalidati
on); | 1320 tracking.underPaintInvalidations.append(underPaintInvalidati
on); |
| 1318 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << x << "," << y << " old:" << std::hex << oldPixel << " new:" <<
newPixel; | 1321 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << x << "," << y << " old:" << std::hex << oldPixel << " new:" <<
newPixel; |
| 1319 } else if (mismatchingPixels == maxMismatchesToReport) { | 1322 } else if (mismatchingPixels == maxMismatchesToReport) { |
| 1320 LOG(ERROR) << "and more..."; | 1323 LOG(ERROR) << "and more..."; |
| 1321 } | 1324 } |
| 1322 ++mismatchingPixels; | 1325 ++mismatchingPixels; |
| 1323 *newBitmap.getAddr32(x, y) = SkColorSetARGB(0x80, 0xFF, 0, 0xFF)
; // Half translucent magenta. | 1326 *newBitmap.getAddr32(x, y) = SK_ColorRED; |
| 1324 } else { | 1327 } else { |
| 1325 *newBitmap.getAddr32(x, y) = SK_ColorTRANSPARENT; | 1328 *newBitmap.getAddr32(x, y) = SK_ColorTRANSPARENT; |
| 1326 } | 1329 } |
| 1327 } | 1330 } |
| 1328 } | 1331 } |
| 1329 | 1332 |
| 1330 oldBitmap.unlockPixels(); | 1333 oldBitmap.unlockPixels(); |
| 1331 newBitmap.unlockPixels(); | 1334 newBitmap.unlockPixels(); |
| 1332 | 1335 |
| 1333 // Visualize under-invalidations by overlaying the new bitmap (containing re
d pixels indicating under-invalidations, | 1336 // Visualize under-invalidations by overlaying the new bitmap (containing re
d pixels indicating under-invalidations, |
| 1334 // and transparent pixels otherwise) onto the painting. | 1337 // and transparent pixels otherwise) onto the painting. |
| 1335 SkPictureRecorder recorder; | 1338 SkPictureRecorder recorder; |
| 1336 recorder.beginRecording(width, height); | 1339 recorder.beginRecording(width, height); |
| 1337 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0); | 1340 recorder.getRecordingCanvas()->drawBitmap(newBitmap, 0, 0); |
| 1338 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); | 1341 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
| 1339 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro
mLayoutObjectWithSubpixelAccumulation()); | 1342 getPaintController().appendDebugDrawingAfterCommit(*this, picture, offsetFro
mLayoutObjectWithSubpixelAccumulation()); |
| 1340 } | 1343 } |
| 1341 | 1344 |
| 1345 #endif // DCHECK_IS_ON() |
| 1346 |
| 1342 } // namespace blink | 1347 } // namespace blink |
| 1343 | 1348 |
| 1344 #ifndef NDEBUG | 1349 #ifndef NDEBUG |
| 1345 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) | 1350 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) |
| 1346 { | 1351 { |
| 1347 if (!layer) { | 1352 if (!layer) { |
| 1348 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1353 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
| 1349 return; | 1354 return; |
| 1350 } | 1355 } |
| 1351 | 1356 |
| 1352 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1357 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1353 fprintf(stderr, "%s\n", output.utf8().data()); | 1358 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1354 } | 1359 } |
| 1355 #endif | 1360 #endif |
| OLD | NEW |