| 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 24 matching lines...) Expand all Loading... |
| 35 #include "platform/geometry/LayoutRect.h" | 35 #include "platform/geometry/LayoutRect.h" |
| 36 #include "platform/geometry/Region.h" | 36 #include "platform/geometry/Region.h" |
| 37 #include "platform/graphics/BitmapImage.h" | 37 #include "platform/graphics/BitmapImage.h" |
| 38 #include "platform/graphics/CompositorFilterOperations.h" | 38 #include "platform/graphics/CompositorFilterOperations.h" |
| 39 #include "platform/graphics/FirstPaintInvalidationTracking.h" | 39 #include "platform/graphics/FirstPaintInvalidationTracking.h" |
| 40 #include "platform/graphics/GraphicsContext.h" | 40 #include "platform/graphics/GraphicsContext.h" |
| 41 #include "platform/graphics/Image.h" | 41 #include "platform/graphics/Image.h" |
| 42 #include "platform/graphics/LinkHighlight.h" | 42 #include "platform/graphics/LinkHighlight.h" |
| 43 #include "platform/graphics/paint/DrawingRecorder.h" | 43 #include "platform/graphics/paint/DrawingRecorder.h" |
| 44 #include "platform/graphics/paint/PaintController.h" | 44 #include "platform/graphics/paint/PaintController.h" |
| 45 #include "platform/graphics/paint/PaintInvalidationTracking.h" |
| 45 #include "platform/json/JSONValues.h" | 46 #include "platform/json/JSONValues.h" |
| 46 #include "platform/scroll/ScrollableArea.h" | 47 #include "platform/scroll/ScrollableArea.h" |
| 47 #include "platform/text/TextStream.h" | 48 #include "platform/text/TextStream.h" |
| 48 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 49 #include "public/platform/WebCompositorSupport.h" | 50 #include "public/platform/WebCompositorSupport.h" |
| 50 #include "public/platform/WebFloatPoint.h" | 51 #include "public/platform/WebFloatPoint.h" |
| 51 #include "public/platform/WebFloatRect.h" | 52 #include "public/platform/WebFloatRect.h" |
| 52 #include "public/platform/WebLayer.h" | 53 #include "public/platform/WebLayer.h" |
| 53 #include "public/platform/WebPoint.h" | 54 #include "public/platform/WebPoint.h" |
| 54 #include "public/platform/WebSize.h" | 55 #include "public/platform/WebSize.h" |
| 55 #include "wtf/CurrentTime.h" | 56 #include "wtf/CurrentTime.h" |
| 56 #include "wtf/HashMap.h" | 57 #include "wtf/HashMap.h" |
| 57 #include "wtf/HashSet.h" | 58 #include "wtf/HashSet.h" |
| 58 #include "wtf/MathExtras.h" | 59 #include "wtf/MathExtras.h" |
| 59 #include "wtf/PtrUtil.h" | 60 #include "wtf/PtrUtil.h" |
| 60 #include "wtf/text/StringUTF8Adaptor.h" | 61 #include "wtf/text/StringUTF8Adaptor.h" |
| 61 #include "wtf/text/WTFString.h" | 62 #include "wtf/text/WTFString.h" |
| 62 #include <algorithm> | 63 #include <algorithm> |
| 63 #include <cmath> | 64 #include <cmath> |
| 64 #include <memory> | 65 #include <memory> |
| 65 #include <utility> | 66 #include <utility> |
| 66 | 67 |
| 67 #ifndef NDEBUG | 68 #ifndef NDEBUG |
| 68 #include <stdio.h> | 69 #include <stdio.h> |
| 69 #endif | 70 #endif |
| 70 | 71 |
| 71 namespace blink { | 72 namespace blink { |
| 72 | 73 |
| 73 struct PaintInvalidationInfo { | 74 template class PaintInvalidationTrackingMap<const GraphicsLayer>; |
| 74 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 75 static PaintInvalidationTrackingMap<const GraphicsLayer>& paintInvalidationTrack
ingMap() |
| 75 // This is for comparison only. Don't dereference because the client may hav
e died. | |
| 76 const DisplayItemClient* client; | |
| 77 String clientDebugName; | |
| 78 IntRect rect; | |
| 79 PaintInvalidationReason reason; | |
| 80 }; | |
| 81 | |
| 82 struct UnderPaintInvalidation { | |
| 83 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 84 int x; | |
| 85 int y; | |
| 86 SkColor oldPixel; | |
| 87 SkColor newPixel; | |
| 88 }; | |
| 89 | |
| 90 struct PaintInvalidationTracking { | |
| 91 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 92 Vector<PaintInvalidationInfo> trackedPaintInvalidations; | |
| 93 sk_sp<SkPicture> lastPaintedPicture; | |
| 94 IntRect lastInterestRect; | |
| 95 Region paintInvalidationRegionSinceLastPaint; | |
| 96 Vector<UnderPaintInvalidation> underPaintInvalidations; | |
| 97 }; | |
| 98 | |
| 99 typedef HashMap<const GraphicsLayer*, PaintInvalidationTracking> PaintInvalidati
onTrackingMap; | |
| 100 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() | |
| 101 { | 76 { |
| 102 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); | 77 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap<const GraphicsLayer>, map,
()); |
| 103 return map; | 78 return map; |
| 104 } | 79 } |
| 105 | 80 |
| 106 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client
) | 81 std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client
) |
| 107 { | 82 { |
| 108 return wrapUnique(new GraphicsLayer(client)); | 83 return wrapUnique(new GraphicsLayer(client)); |
| 109 } | 84 } |
| 110 | 85 |
| 111 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) | 86 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) |
| 112 : m_client(client) | 87 : m_client(client) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return m_previousInterestRect; | 302 return m_previousInterestRect; |
| 328 } | 303 } |
| 329 | 304 |
| 330 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) | 305 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) |
| 331 { | 306 { |
| 332 if (paintWithoutCommit(interestRect, disabledMode)) { | 307 if (paintWithoutCommit(interestRect, disabledMode)) { |
| 333 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); | 308 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); |
| 334 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 309 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 335 sk_sp<SkPicture> newPicture = capturePicture(); | 310 sk_sp<SkPicture> newPicture = capturePicture(); |
| 336 checkPaintUnderInvalidations(*newPicture); | 311 checkPaintUnderInvalidations(*newPicture); |
| 337 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap()
.add(this, PaintInvalidationTracking()).storedValue->value; | 312 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap()
.add(this); |
| 338 tracking.lastPaintedPicture = std::move(newPicture); | 313 tracking.lastPaintedPicture = std::move(newPicture); |
| 339 tracking.lastInterestRect = m_previousInterestRect; | 314 tracking.lastInterestRect = m_previousInterestRect; |
| 340 tracking.paintInvalidationRegionSinceLastPaint = Region(); | 315 tracking.paintInvalidationRegionSinceLastPaint = Region(); |
| 341 } | 316 } |
| 342 } | 317 } |
| 343 } | 318 } |
| 344 | 319 |
| 345 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) | 320 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) |
| 346 { | 321 { |
| 347 ASSERT(drawsContent()); | 322 ASSERT(drawsContent()); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 512 } |
| 538 | 513 |
| 539 void GraphicsLayer::setTracksPaintInvalidations(bool tracksPaintInvalidations) | 514 void GraphicsLayer::setTracksPaintInvalidations(bool tracksPaintInvalidations) |
| 540 { | 515 { |
| 541 resetTrackedPaintInvalidations(); | 516 resetTrackedPaintInvalidations(); |
| 542 m_isTrackingPaintInvalidations = tracksPaintInvalidations; | 517 m_isTrackingPaintInvalidations = tracksPaintInvalidations; |
| 543 } | 518 } |
| 544 | 519 |
| 545 void GraphicsLayer::resetTrackedPaintInvalidations() | 520 void GraphicsLayer::resetTrackedPaintInvalidations() |
| 546 { | 521 { |
| 547 auto it = paintInvalidationTrackingMap().find(this); | 522 PaintInvalidationTracking* tracking = paintInvalidationTrackingMap().find(th
is); |
| 548 if (it == paintInvalidationTrackingMap().end()) | 523 if (!tracking) |
| 549 return; | 524 return; |
| 550 | 525 |
| 551 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 526 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
| 552 it->value.trackedPaintInvalidations.clear(); | 527 tracking->trackedPaintInvalidations.clear(); |
| 553 else | 528 else |
| 554 paintInvalidationTrackingMap().remove(it); | 529 paintInvalidationTrackingMap().remove(this); |
| 555 } | 530 } |
| 556 | 531 |
| 557 bool GraphicsLayer::hasTrackedPaintInvalidations() const | 532 bool GraphicsLayer::hasTrackedPaintInvalidations() const |
| 558 { | 533 { |
| 559 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 534 PaintInvalidationTracking* tracking = paintInvalidationTrackingMap().find(th
is); |
| 560 if (it != paintInvalidationTrackingMap().end()) | 535 if (tracking) |
| 561 return !it->value.trackedPaintInvalidations.isEmpty(); | 536 return !tracking->trackedPaintInvalidations.isEmpty(); |
| 562 return false; | 537 return false; |
| 563 } | 538 } |
| 564 | 539 |
| 565 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) | 540 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) |
| 566 { | 541 { |
| 567 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) | 542 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) |
| 568 return; | 543 return; |
| 569 | 544 |
| 570 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; | 545 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s); |
| 571 | 546 |
| 572 if (m_isTrackingPaintInvalidations) { | 547 if (m_isTrackingPaintInvalidations) { |
| 573 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason
}; | 548 PaintInvalidationInfo info; |
| 549 info.client = &client; |
| 550 info.clientDebugName = client.debugName(); |
| 551 info.rect = rect; |
| 552 info.reason = reason; |
| 574 tracking.trackedPaintInvalidations.append(info); | 553 tracking.trackedPaintInvalidations.append(info); |
| 575 } | 554 } |
| 576 | 555 |
| 577 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 556 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
| 578 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. | 557 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. |
| 579 IntRect r = rect; | 558 IntRect r = rect; |
| 580 r.inflate(1); | 559 r.inflate(1); |
| 581 tracking.paintInvalidationRegionSinceLastPaint.unite(r); | 560 tracking.paintInvalidationRegionSinceLastPaint.unite(r); |
| 582 } | 561 } |
| 583 } | 562 } |
| 584 | 563 |
| 585 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) | |
| 586 { | |
| 587 // Sort by rect first, bigger rects before smaller ones. | |
| 588 if (a.rect.width() != b.rect.width()) | |
| 589 return a.rect.width() > b.rect.width(); | |
| 590 if (a.rect.height() != b.rect.height()) | |
| 591 return a.rect.height() > b.rect.height(); | |
| 592 if (a.rect.x() != b.rect.x()) | |
| 593 return a.rect.x() > b.rect.x(); | |
| 594 if (a.rect.y() != b.rect.y()) | |
| 595 return a.rect.y() > b.rect.y(); | |
| 596 | |
| 597 // Then compare clientDebugName, in alphabetic order. | |
| 598 int nameCompareResult = codePointCompare(a.clientDebugName, b.clientDebugNam
e); | |
| 599 if (nameCompareResult != 0) | |
| 600 return nameCompareResult < 0; | |
| 601 | |
| 602 return a.reason < b.reason; | |
| 603 } | |
| 604 | |
| 605 template <typename T> | 564 template <typename T> |
| 606 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) | 565 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) |
| 607 { | 566 { |
| 608 std::unique_ptr<JSONArray> array = JSONArray::create(); | 567 std::unique_ptr<JSONArray> array = JSONArray::create(); |
| 609 array->pushDouble(point.x()); | 568 array->pushDouble(point.x()); |
| 610 array->pushDouble(point.y()); | 569 array->pushDouble(point.y()); |
| 611 return array; | 570 return array; |
| 612 } | 571 } |
| 613 | 572 |
| 614 template <typename T> | 573 template <typename T> |
| 615 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) | 574 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) |
| 616 { | 575 { |
| 617 std::unique_ptr<JSONArray> array = JSONArray::create(); | 576 std::unique_ptr<JSONArray> array = JSONArray::create(); |
| 618 array->pushDouble(size.width()); | 577 array->pushDouble(size.width()); |
| 619 array->pushDouble(size.height()); | 578 array->pushDouble(size.height()); |
| 620 return array; | 579 return array; |
| 621 } | 580 } |
| 622 | 581 |
| 623 template <typename T> | |
| 624 static std::unique_ptr<JSONArray> rectAsJSONArray(const T& rect) | |
| 625 { | |
| 626 std::unique_ptr<JSONArray> array = JSONArray::create(); | |
| 627 array->pushDouble(rect.x()); | |
| 628 array->pushDouble(rect.y()); | |
| 629 array->pushDouble(rect.width()); | |
| 630 array->pushDouble(rect.height()); | |
| 631 return array; | |
| 632 } | |
| 633 | |
| 634 static double roundCloseToZero(double number) | 582 static double roundCloseToZero(double number) |
| 635 { | 583 { |
| 636 return std::abs(number) < 1e-7 ? 0 : number; | 584 return std::abs(number) < 1e-7 ? 0 : number; |
| 637 } | 585 } |
| 638 | 586 |
| 639 static std::unique_ptr<JSONArray> transformAsJSONArray(const TransformationMatri
x& t) | 587 static std::unique_ptr<JSONArray> transformAsJSONArray(const TransformationMatri
x& t) |
| 640 { | 588 { |
| 641 std::unique_ptr<JSONArray> array = JSONArray::create(); | 589 std::unique_ptr<JSONArray> array = JSONArray::create(); |
| 642 { | 590 { |
| 643 std::unique_ptr<JSONArray> row = JSONArray::create(); | 591 std::unique_ptr<JSONArray> row = JSONArray::create(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 696 |
| 749 if (!m_transform.isIdentity()) | 697 if (!m_transform.isIdentity()) |
| 750 json->setArray("transform", transformAsJSONArray(m_transform)); | 698 json->setArray("transform", transformAsJSONArray(m_transform)); |
| 751 | 699 |
| 752 if (m_replicaLayer) | 700 if (m_replicaLayer) |
| 753 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSONInternal(
flags, renderingContextMap)); | 701 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSONInternal(
flags, renderingContextMap)); |
| 754 | 702 |
| 755 if (m_replicatedLayer) | 703 if (m_replicatedLayer) |
| 756 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); | 704 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); |
| 757 | 705 |
| 758 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 706 paintInvalidationTrackingMap().asJSON(this, json.get()); |
| 759 if (it != paintInvalidationTrackingMap().end()) { | |
| 760 if (flags & LayerTreeIncludesPaintInvalidations) { | |
| 761 Vector<PaintInvalidationInfo>& infos = it->value.trackedPaintInvalid
ations; | |
| 762 if (!infos.isEmpty()) { | |
| 763 std::sort(infos.begin(), infos.end(), &comparePaintInvalidationI
nfo); | |
| 764 std::unique_ptr<JSONArray> paintInvalidationsJSON = JSONArray::c
reate(); | |
| 765 for (auto& info : infos) { | |
| 766 std::unique_ptr<JSONObject> infoJSON = JSONObject::create(); | |
| 767 infoJSON->setString("object", info.clientDebugName); | |
| 768 if (!info.rect.isEmpty()) | |
| 769 infoJSON->setArray("rect", rectAsJSONArray(info.rect)); | |
| 770 infoJSON->setString("reason", paintInvalidationReasonToStrin
g(info.reason)); | |
| 771 paintInvalidationsJSON->pushObject(std::move(infoJSON)); | |
| 772 } | |
| 773 json->setArray("paintInvalidations", std::move(paintInvalidation
sJSON)); | |
| 774 } | |
| 775 | |
| 776 Vector<UnderPaintInvalidation>& underPaintInvalidations = it->value.
underPaintInvalidations; | |
| 777 if (!underPaintInvalidations.isEmpty()) { | |
| 778 std::unique_ptr<JSONArray> underPaintInvalidationsJSON = JSONArr
ay::create(); | |
| 779 for (auto& underPaintInvalidation : underPaintInvalidations) { | |
| 780 std::unique_ptr<JSONObject> underPaintInvalidationJSON = JSO
NObject::create(); | |
| 781 underPaintInvalidationJSON->setDouble("x", underPaintInvalid
ation.x); | |
| 782 underPaintInvalidationJSON->setDouble("y", underPaintInvalid
ation.y); | |
| 783 underPaintInvalidationJSON->setString("oldPixel", Color(unde
rPaintInvalidation.oldPixel).nameForLayoutTreeAsText()); | |
| 784 underPaintInvalidationJSON->setString("newPixel", Color(unde
rPaintInvalidation.newPixel).nameForLayoutTreeAsText()); | |
| 785 underPaintInvalidationsJSON->pushObject(std::move(underPaint
InvalidationJSON)); | |
| 786 } | |
| 787 json->setArray("underPaintInvalidations", std::move(underPaintIn
validationsJSON)); | |
| 788 } | |
| 789 } | |
| 790 } | |
| 791 | 707 |
| 792 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { | 708 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { |
| 793 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); | 709 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); |
| 794 if (m_paintingPhase & GraphicsLayerPaintBackground) | 710 if (m_paintingPhase & GraphicsLayerPaintBackground) |
| 795 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); | 711 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); |
| 796 if (m_paintingPhase & GraphicsLayerPaintForeground) | 712 if (m_paintingPhase & GraphicsLayerPaintForeground) |
| 797 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); | 713 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); |
| 798 if (m_paintingPhase & GraphicsLayerPaintMask) | 714 if (m_paintingPhase & GraphicsLayerPaintMask) |
| 799 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); | 715 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); |
| 800 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) | 716 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 || pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) | 1192 || pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) |
| 1277 || pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) | 1193 || pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) |
| 1278 || pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); | 1194 || pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); |
| 1279 } | 1195 } |
| 1280 | 1196 |
| 1281 void GraphicsLayer::checkPaintUnderInvalidations(const SkPicture& newPicture) | 1197 void GraphicsLayer::checkPaintUnderInvalidations(const SkPicture& newPicture) |
| 1282 { | 1198 { |
| 1283 if (!drawsContent()) | 1199 if (!drawsContent()) |
| 1284 return; | 1200 return; |
| 1285 | 1201 |
| 1286 auto it = paintInvalidationTrackingMap().find(this); | 1202 PaintInvalidationTracking* tracking = paintInvalidationTrackingMap().find(th
is); |
| 1287 if (it == paintInvalidationTrackingMap().end()) | 1203 if (!tracking) |
| 1288 return; | |
| 1289 PaintInvalidationTracking& tracking = it->value; | |
| 1290 if (!tracking.lastPaintedPicture) | |
| 1291 return; | 1204 return; |
| 1292 | 1205 |
| 1293 IntRect rect = intersection(tracking.lastInterestRect, interestRect()); | 1206 if (!tracking->lastPaintedPicture) |
| 1207 return; |
| 1208 |
| 1209 IntRect rect = intersection(tracking->lastInterestRect, interestRect()); |
| 1294 if (rect.isEmpty()) | 1210 if (rect.isEmpty()) |
| 1295 return; | 1211 return; |
| 1296 | 1212 |
| 1297 SkBitmap oldBitmap; | 1213 SkBitmap oldBitmap; |
| 1298 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); | 1214 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); |
| 1299 { | 1215 { |
| 1300 SkCanvas canvas(oldBitmap); | 1216 SkCanvas canvas(oldBitmap); |
| 1301 canvas.clear(SK_ColorTRANSPARENT); | 1217 canvas.clear(SK_ColorTRANSPARENT); |
| 1302 canvas.translate(-rect.x(), -rect.y()); | 1218 canvas.translate(-rect.x(), -rect.y()); |
| 1303 canvas.drawPicture(tracking.lastPaintedPicture.get()); | 1219 canvas.drawPicture(tracking->lastPaintedPicture.get()); |
| 1304 } | 1220 } |
| 1305 | 1221 |
| 1306 SkBitmap newBitmap; | 1222 SkBitmap newBitmap; |
| 1307 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); | 1223 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); |
| 1308 { | 1224 { |
| 1309 SkCanvas canvas(newBitmap); | 1225 SkCanvas canvas(newBitmap); |
| 1310 canvas.clear(SK_ColorTRANSPARENT); | 1226 canvas.clear(SK_ColorTRANSPARENT); |
| 1311 canvas.translate(-rect.x(), -rect.y()); | 1227 canvas.translate(-rect.x(), -rect.y()); |
| 1312 canvas.drawPicture(&newPicture); | 1228 canvas.drawPicture(&newPicture); |
| 1313 } | 1229 } |
| 1314 | 1230 |
| 1315 oldBitmap.lockPixels(); | 1231 oldBitmap.lockPixels(); |
| 1316 newBitmap.lockPixels(); | 1232 newBitmap.lockPixels(); |
| 1317 int mismatchingPixels = 0; | 1233 int mismatchingPixels = 0; |
| 1318 static const int maxMismatchesToReport = 50; | 1234 static const int maxMismatchesToReport = 50; |
| 1319 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { | 1235 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { |
| 1320 int layerY = bitmapY + rect.y(); | 1236 int layerY = bitmapY + rect.y(); |
| 1321 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { | 1237 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { |
| 1322 int layerX = bitmapX + rect.x(); | 1238 int layerX = bitmapX + rect.x(); |
| 1323 SkColor oldPixel = oldBitmap.getColor(bitmapX, bitmapY); | 1239 SkColor oldPixel = oldBitmap.getColor(bitmapX, bitmapY); |
| 1324 SkColor newPixel = newBitmap.getColor(bitmapX, bitmapY); | 1240 SkColor newPixel = newBitmap.getColor(bitmapX, bitmapY); |
| 1325 if (pixelsDiffer(oldPixel, newPixel) && !tracking.paintInvalidationR
egionSinceLastPaint.contains(IntPoint(layerX, layerY))) { | 1241 if (pixelsDiffer(oldPixel, newPixel) && !tracking->paintInvalidation
RegionSinceLastPaint.contains(IntPoint(layerX, layerY))) { |
| 1326 if (mismatchingPixels < maxMismatchesToReport) { | 1242 if (mismatchingPixels < maxMismatchesToReport) { |
| 1327 UnderPaintInvalidation underPaintInvalidation = { layerX, la
yerY, oldPixel, newPixel }; | 1243 UnderPaintInvalidation underPaintInvalidation = { layerX, la
yerY, oldPixel, newPixel }; |
| 1328 tracking.underPaintInvalidations.append(underPaintInvalidati
on); | 1244 tracking->underPaintInvalidations.append(underPaintInvalidat
ion); |
| 1329 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << layerX << "," << layerY << " old:" << std::hex << oldPixel << "
new:" << newPixel; | 1245 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << layerX << "," << layerY << " old:" << std::hex << oldPixel << "
new:" << newPixel; |
| 1330 } else if (mismatchingPixels == maxMismatchesToReport) { | 1246 } else if (mismatchingPixels == maxMismatchesToReport) { |
| 1331 LOG(ERROR) << "and more..."; | 1247 LOG(ERROR) << "and more..."; |
| 1332 } | 1248 } |
| 1333 ++mismatchingPixels; | 1249 ++mismatchingPixels; |
| 1334 *newBitmap.getAddr32(bitmapX, bitmapY) = SkColorSetARGB(0xFF, 0x
A0, 0, 0); // Dark red. | 1250 *newBitmap.getAddr32(bitmapX, bitmapY) = SkColorSetARGB(0xFF, 0x
A0, 0, 0); // Dark red. |
| 1335 } else { | 1251 } else { |
| 1336 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT; | 1252 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT; |
| 1337 } | 1253 } |
| 1338 } | 1254 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1356 { | 1272 { |
| 1357 if (!layer) { | 1273 if (!layer) { |
| 1358 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1274 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
| 1359 return; | 1275 return; |
| 1360 } | 1276 } |
| 1361 | 1277 |
| 1362 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1278 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1363 fprintf(stderr, "%s\n", output.utf8().data()); | 1279 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1364 } | 1280 } |
| 1365 #endif | 1281 #endif |
| OLD | NEW |