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/RasterInvalidationTracking.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 RasterInvalidationTrackingMap<const GraphicsLayer>; |
74 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 75 static RasterInvalidationTrackingMap<const GraphicsLayer>& rasterInvalidationTra
ckingMap() |
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(RasterInvalidationTrackingMap<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) |
113 , m_backgroundColor(Color::transparent) | 88 , m_backgroundColor(Color::transparent) |
114 , m_opacity(1) | 89 , m_opacity(1) |
115 , m_blendMode(WebBlendModeNormal) | 90 , m_blendMode(WebBlendModeNormal) |
116 , m_hasTransformOrigin(false) | 91 , m_hasTransformOrigin(false) |
117 , m_contentsOpaque(false) | 92 , m_contentsOpaque(false) |
118 , m_shouldFlattenTransform(true) | 93 , m_shouldFlattenTransform(true) |
119 , m_backfaceVisibility(true) | 94 , m_backfaceVisibility(true) |
120 , m_drawsContent(false) | 95 , m_drawsContent(false) |
121 , m_contentsVisible(true) | 96 , m_contentsVisible(true) |
122 , m_isRootForIsolatedGroup(false) | 97 , m_isRootForIsolatedGroup(false) |
123 , m_hasScrollParent(false) | 98 , m_hasScrollParent(false) |
124 , m_hasClipParent(false) | 99 , m_hasClipParent(false) |
125 , m_painted(false) | 100 , m_painted(false) |
126 , m_isTrackingPaintInvalidations(client && client->isTrackingPaintInvalidati
ons()) | 101 , m_isTrackingRasterInvalidations(client && client->isTrackingRasterInvalida
tions()) |
127 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) | 102 , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip) |
128 , m_parent(0) | 103 , m_parent(0) |
129 , m_maskLayer(0) | 104 , m_maskLayer(0) |
130 , m_contentsClippingMaskLayer(0) | 105 , m_contentsClippingMaskLayer(0) |
131 , m_paintCount(0) | 106 , m_paintCount(0) |
132 , m_contentsLayer(0) | 107 , m_contentsLayer(0) |
133 , m_contentsLayerId(0) | 108 , m_contentsLayerId(0) |
134 , m_scrollableArea(nullptr) | 109 , m_scrollableArea(nullptr) |
135 , m_renderingContext3d(0) | 110 , m_renderingContext3d(0) |
136 { | 111 { |
(...skipping 15 matching lines...) Expand all Loading... |
152 m_linkHighlights.clear(); | 127 m_linkHighlights.clear(); |
153 | 128 |
154 #if ENABLE(ASSERT) | 129 #if ENABLE(ASSERT) |
155 if (m_client) | 130 if (m_client) |
156 m_client->verifyNotPainting(); | 131 m_client->verifyNotPainting(); |
157 #endif | 132 #endif |
158 | 133 |
159 removeAllChildren(); | 134 removeAllChildren(); |
160 removeFromParent(); | 135 removeFromParent(); |
161 | 136 |
162 paintInvalidationTrackingMap().remove(this); | 137 rasterInvalidationTrackingMap().remove(this); |
163 ASSERT(!m_parent); | 138 ASSERT(!m_parent); |
164 } | 139 } |
165 | 140 |
166 LayoutRect GraphicsLayer::visualRect() const | 141 LayoutRect GraphicsLayer::visualRect() const |
167 { | 142 { |
168 LayoutRect bounds = LayoutRect(FloatPoint(), size()); | 143 LayoutRect bounds = LayoutRect(FloatPoint(), size()); |
169 bounds.move(offsetFromLayoutObjectWithSubpixelAccumulation()); | 144 bounds.move(offsetFromLayoutObjectWithSubpixelAccumulation()); |
170 return bounds; | 145 return bounds; |
171 } | 146 } |
172 | 147 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return m_previousInterestRect; | 277 return m_previousInterestRect; |
303 } | 278 } |
304 | 279 |
305 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) | 280 void GraphicsLayer::paint(const IntRect* interestRect, GraphicsContext::Disabled
Mode disabledMode) |
306 { | 281 { |
307 if (paintWithoutCommit(interestRect, disabledMode)) { | 282 if (paintWithoutCommit(interestRect, disabledMode)) { |
308 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); | 283 getPaintController().commitNewDisplayItems(offsetFromLayoutObjectWithSub
pixelAccumulation()); |
309 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 284 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
310 sk_sp<SkPicture> newPicture = capturePicture(); | 285 sk_sp<SkPicture> newPicture = capturePicture(); |
311 checkPaintUnderInvalidations(*newPicture); | 286 checkPaintUnderInvalidations(*newPicture); |
312 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap()
.add(this, PaintInvalidationTracking()).storedValue->value; | 287 RasterInvalidationTracking& tracking = rasterInvalidationTrackingMap
().add(this); |
313 tracking.lastPaintedPicture = std::move(newPicture); | 288 tracking.lastPaintedPicture = std::move(newPicture); |
314 tracking.lastInterestRect = m_previousInterestRect; | 289 tracking.lastInterestRect = m_previousInterestRect; |
315 tracking.paintInvalidationRegionSinceLastPaint = Region(); | 290 tracking.rasterInvalidationRegionSinceLastPaint = Region(); |
316 } | 291 } |
317 } | 292 } |
318 } | 293 } |
319 | 294 |
320 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) | 295 bool GraphicsLayer::paintWithoutCommit(const IntRect* interestRect, GraphicsCont
ext::DisabledMode disabledMode) |
321 { | 296 { |
322 ASSERT(drawsContent()); | 297 ASSERT(drawsContent()); |
323 | 298 |
324 if (!m_client) | 299 if (!m_client) |
325 return false; | 300 return false; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 { | 479 { |
505 return m_debugInfo; | 480 return m_debugInfo; |
506 } | 481 } |
507 | 482 |
508 WebLayer* GraphicsLayer::contentsLayerIfRegistered() | 483 WebLayer* GraphicsLayer::contentsLayerIfRegistered() |
509 { | 484 { |
510 clearContentsLayerIfUnregistered(); | 485 clearContentsLayerIfUnregistered(); |
511 return m_contentsLayer; | 486 return m_contentsLayer; |
512 } | 487 } |
513 | 488 |
514 void GraphicsLayer::setTracksPaintInvalidations(bool tracksPaintInvalidations) | 489 void GraphicsLayer::setTracksRasterInvalidations(bool tracksRasterInvalidations) |
515 { | 490 { |
516 resetTrackedPaintInvalidations(); | 491 resetTrackedRasterInvalidations(); |
517 m_isTrackingPaintInvalidations = tracksPaintInvalidations; | 492 m_isTrackingRasterInvalidations = tracksRasterInvalidations; |
518 } | 493 } |
519 | 494 |
520 void GraphicsLayer::resetTrackedPaintInvalidations() | 495 void GraphicsLayer::resetTrackedRasterInvalidations() |
521 { | 496 { |
522 auto it = paintInvalidationTrackingMap().find(this); | 497 RasterInvalidationTracking* tracking = rasterInvalidationTrackingMap().find(
this); |
523 if (it == paintInvalidationTrackingMap().end()) | 498 if (!tracking) |
524 return; | 499 return; |
525 | 500 |
526 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) | 501 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) |
527 it->value.trackedPaintInvalidations.clear(); | 502 tracking->trackedRasterInvalidations.clear(); |
528 else | 503 else |
529 paintInvalidationTrackingMap().remove(it); | 504 rasterInvalidationTrackingMap().remove(this); |
530 } | 505 } |
531 | 506 |
532 bool GraphicsLayer::hasTrackedPaintInvalidations() const | 507 bool GraphicsLayer::hasTrackedRasterInvalidations() const |
533 { | 508 { |
534 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 509 RasterInvalidationTracking* tracking = rasterInvalidationTrackingMap().find(
this); |
535 if (it != paintInvalidationTrackingMap().end()) | 510 if (tracking) |
536 return !it->value.trackedPaintInvalidations.isEmpty(); | 511 return !tracking->trackedRasterInvalidations.isEmpty(); |
537 return false; | 512 return false; |
538 } | 513 } |
539 | 514 |
540 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) | 515 void GraphicsLayer::trackRasterInvalidation(const DisplayItemClient& client, con
st IntRect& rect, PaintInvalidationReason reason) |
541 { | 516 { |
542 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) | 517 if (!isTrackingOrCheckingRasterInvalidations() || rect.isEmpty()) |
543 return; | 518 return; |
544 | 519 |
545 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; | 520 RasterInvalidationTracking& tracking = rasterInvalidationTrackingMap().add(t
his); |
546 | 521 |
547 if (m_isTrackingPaintInvalidations) { | 522 if (m_isTrackingRasterInvalidations) { |
548 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason
}; | 523 RasterInvalidationInfo info; |
549 tracking.trackedPaintInvalidations.append(info); | 524 info.client = &client; |
| 525 info.clientDebugName = client.debugName(); |
| 526 info.rect = rect; |
| 527 info.reason = reason; |
| 528 tracking.trackedRasterInvalidations.append(info); |
550 } | 529 } |
551 | 530 |
552 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 531 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
553 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. | 532 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. |
554 IntRect r = rect; | 533 IntRect r = rect; |
555 r.inflate(1); | 534 r.inflate(1); |
556 tracking.paintInvalidationRegionSinceLastPaint.unite(r); | 535 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); |
557 } | 536 } |
558 } | 537 } |
559 | 538 |
560 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) | |
561 { | |
562 // Sort by rect first, bigger rects before smaller ones. | |
563 if (a.rect.width() != b.rect.width()) | |
564 return a.rect.width() > b.rect.width(); | |
565 if (a.rect.height() != b.rect.height()) | |
566 return a.rect.height() > b.rect.height(); | |
567 if (a.rect.x() != b.rect.x()) | |
568 return a.rect.x() > b.rect.x(); | |
569 if (a.rect.y() != b.rect.y()) | |
570 return a.rect.y() > b.rect.y(); | |
571 | |
572 // Then compare clientDebugName, in alphabetic order. | |
573 int nameCompareResult = codePointCompare(a.clientDebugName, b.clientDebugNam
e); | |
574 if (nameCompareResult != 0) | |
575 return nameCompareResult < 0; | |
576 | |
577 return a.reason < b.reason; | |
578 } | |
579 | |
580 template <typename T> | 539 template <typename T> |
581 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) | 540 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) |
582 { | 541 { |
583 std::unique_ptr<JSONArray> array = JSONArray::create(); | 542 std::unique_ptr<JSONArray> array = JSONArray::create(); |
584 array->pushDouble(point.x()); | 543 array->pushDouble(point.x()); |
585 array->pushDouble(point.y()); | 544 array->pushDouble(point.y()); |
586 return array; | 545 return array; |
587 } | 546 } |
588 | 547 |
589 template <typename T> | 548 template <typename T> |
590 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) | 549 static std::unique_ptr<JSONArray> sizeAsJSONArray(const T& size) |
591 { | 550 { |
592 std::unique_ptr<JSONArray> array = JSONArray::create(); | 551 std::unique_ptr<JSONArray> array = JSONArray::create(); |
593 array->pushDouble(size.width()); | 552 array->pushDouble(size.width()); |
594 array->pushDouble(size.height()); | 553 array->pushDouble(size.height()); |
595 return array; | 554 return array; |
596 } | 555 } |
597 | 556 |
598 template <typename T> | |
599 static std::unique_ptr<JSONArray> rectAsJSONArray(const T& rect) | |
600 { | |
601 std::unique_ptr<JSONArray> array = JSONArray::create(); | |
602 array->pushDouble(rect.x()); | |
603 array->pushDouble(rect.y()); | |
604 array->pushDouble(rect.width()); | |
605 array->pushDouble(rect.height()); | |
606 return array; | |
607 } | |
608 | |
609 static double roundCloseToZero(double number) | 557 static double roundCloseToZero(double number) |
610 { | 558 { |
611 return std::abs(number) < 1e-7 ? 0 : number; | 559 return std::abs(number) < 1e-7 ? 0 : number; |
612 } | 560 } |
613 | 561 |
614 static std::unique_ptr<JSONArray> transformAsJSONArray(const TransformationMatri
x& t) | 562 static std::unique_ptr<JSONArray> transformAsJSONArray(const TransformationMatri
x& t) |
615 { | 563 { |
616 std::unique_ptr<JSONArray> array = JSONArray::create(); | 564 std::unique_ptr<JSONArray> array = JSONArray::create(); |
617 { | 565 { |
618 std::unique_ptr<JSONArray> row = JSONArray::create(); | 566 std::unique_ptr<JSONArray> row = JSONArray::create(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 665 |
718 if (flags & LayerTreeIncludesDebugInfo) | 666 if (flags & LayerTreeIncludesDebugInfo) |
719 json->setString("client", pointerAsString(m_client)); | 667 json->setString("client", pointerAsString(m_client)); |
720 | 668 |
721 if (m_backgroundColor.alpha()) | 669 if (m_backgroundColor.alpha()) |
722 json->setString("backgroundColor", m_backgroundColor.nameForLayoutTreeAs
Text()); | 670 json->setString("backgroundColor", m_backgroundColor.nameForLayoutTreeAs
Text()); |
723 | 671 |
724 if (!m_transform.isIdentity()) | 672 if (!m_transform.isIdentity()) |
725 json->setArray("transform", transformAsJSONArray(m_transform)); | 673 json->setArray("transform", transformAsJSONArray(m_transform)); |
726 | 674 |
727 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 675 rasterInvalidationTrackingMap().asJSON(this, json.get()); |
728 if (it != paintInvalidationTrackingMap().end()) { | |
729 if (flags & LayerTreeIncludesPaintInvalidations) { | |
730 Vector<PaintInvalidationInfo>& infos = it->value.trackedPaintInvalid
ations; | |
731 if (!infos.isEmpty()) { | |
732 std::sort(infos.begin(), infos.end(), &comparePaintInvalidationI
nfo); | |
733 std::unique_ptr<JSONArray> paintInvalidationsJSON = JSONArray::c
reate(); | |
734 for (auto& info : infos) { | |
735 std::unique_ptr<JSONObject> infoJSON = JSONObject::create(); | |
736 infoJSON->setString("object", info.clientDebugName); | |
737 if (!info.rect.isEmpty()) | |
738 infoJSON->setArray("rect", rectAsJSONArray(info.rect)); | |
739 infoJSON->setString("reason", paintInvalidationReasonToStrin
g(info.reason)); | |
740 paintInvalidationsJSON->pushObject(std::move(infoJSON)); | |
741 } | |
742 json->setArray("paintInvalidations", std::move(paintInvalidation
sJSON)); | |
743 } | |
744 | |
745 Vector<UnderPaintInvalidation>& underPaintInvalidations = it->value.
underPaintInvalidations; | |
746 if (!underPaintInvalidations.isEmpty()) { | |
747 std::unique_ptr<JSONArray> underPaintInvalidationsJSON = JSONArr
ay::create(); | |
748 for (auto& underPaintInvalidation : underPaintInvalidations) { | |
749 std::unique_ptr<JSONObject> underPaintInvalidationJSON = JSO
NObject::create(); | |
750 underPaintInvalidationJSON->setDouble("x", underPaintInvalid
ation.x); | |
751 underPaintInvalidationJSON->setDouble("y", underPaintInvalid
ation.y); | |
752 underPaintInvalidationJSON->setString("oldPixel", Color(unde
rPaintInvalidation.oldPixel).nameForLayoutTreeAsText()); | |
753 underPaintInvalidationJSON->setString("newPixel", Color(unde
rPaintInvalidation.newPixel).nameForLayoutTreeAsText()); | |
754 underPaintInvalidationsJSON->pushObject(std::move(underPaint
InvalidationJSON)); | |
755 } | |
756 json->setArray("underPaintInvalidations", std::move(underPaintIn
validationsJSON)); | |
757 } | |
758 } | |
759 } | |
760 | 676 |
761 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { | 677 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { |
762 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); | 678 std::unique_ptr<JSONArray> paintingPhasesJSON = JSONArray::create(); |
763 if (m_paintingPhase & GraphicsLayerPaintBackground) | 679 if (m_paintingPhase & GraphicsLayerPaintBackground) |
764 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); | 680 paintingPhasesJSON->pushString("GraphicsLayerPaintBackground"); |
765 if (m_paintingPhase & GraphicsLayerPaintForeground) | 681 if (m_paintingPhase & GraphicsLayerPaintForeground) |
766 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); | 682 paintingPhasesJSON->pushString("GraphicsLayerPaintForeground"); |
767 if (m_paintingPhase & GraphicsLayerPaintMask) | 683 if (m_paintingPhase & GraphicsLayerPaintMask) |
768 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); | 684 paintingPhasesJSON->pushString("GraphicsLayerPaintMask"); |
769 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) | 685 if (m_paintingPhase & GraphicsLayerPaintChildClippingMask) |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 if (m_isRootForIsolatedGroup == isolated) | 950 if (m_isRootForIsolatedGroup == isolated) |
1035 return; | 951 return; |
1036 m_isRootForIsolatedGroup = isolated; | 952 m_isRootForIsolatedGroup = isolated; |
1037 platformLayer()->setIsRootForIsolatedGroup(isolated); | 953 platformLayer()->setIsRootForIsolatedGroup(isolated); |
1038 } | 954 } |
1039 | 955 |
1040 void GraphicsLayer::setContentsNeedsDisplay() | 956 void GraphicsLayer::setContentsNeedsDisplay() |
1041 { | 957 { |
1042 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { | 958 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { |
1043 contentsLayer->invalidate(); | 959 contentsLayer->invalidate(); |
1044 trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull); | 960 trackRasterInvalidation(*this, m_contentsRect, PaintInvalidationFull); |
1045 } | 961 } |
1046 } | 962 } |
1047 | 963 |
1048 void GraphicsLayer::setNeedsDisplay() | 964 void GraphicsLayer::setNeedsDisplay() |
1049 { | 965 { |
1050 if (!drawsContent()) | 966 if (!drawsContent()) |
1051 return; | 967 return; |
1052 | 968 |
1053 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. | 969 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. |
1054 m_layer->layer()->invalidate(); | 970 m_layer->layer()->invalidate(); |
1055 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 971 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1056 m_linkHighlights[i]->invalidate(); | 972 m_linkHighlights[i]->invalidate(); |
1057 getPaintController().invalidateAll(); | 973 getPaintController().invalidateAll(); |
1058 | 974 |
1059 trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)),
PaintInvalidationFull); | 975 trackRasterInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)),
PaintInvalidationFull); |
1060 } | 976 } |
1061 | 977 |
1062 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) | 978 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) |
1063 { | 979 { |
1064 if (!drawsContent()) | 980 if (!drawsContent()) |
1065 return; | 981 return; |
1066 | 982 |
1067 m_layer->layer()->invalidateRect(rect); | 983 m_layer->layer()->invalidateRect(rect); |
1068 if (firstPaintInvalidationTrackingEnabled()) | 984 if (firstPaintInvalidationTrackingEnabled()) |
1069 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); | 985 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); |
1070 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 986 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1071 m_linkHighlights[i]->invalidate(); | 987 m_linkHighlights[i]->invalidate(); |
1072 | 988 |
1073 trackPaintInvalidation(client, rect, invalidationReason); | 989 trackRasterInvalidation(client, rect, invalidationReason); |
1074 } | 990 } |
1075 | 991 |
1076 void GraphicsLayer::setContentsRect(const IntRect& rect) | 992 void GraphicsLayer::setContentsRect(const IntRect& rect) |
1077 { | 993 { |
1078 if (rect == m_contentsRect) | 994 if (rect == m_contentsRect) |
1079 return; | 995 return; |
1080 | 996 |
1081 m_contentsRect = rect; | 997 m_contentsRect = rect; |
1082 updateContentsRect(); | 998 updateContentsRect(); |
1083 } | 999 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 || pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) | 1161 || pixelComponentsDiffer(SkColorGetR(p1), SkColorGetR(p2)) |
1246 || pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) | 1162 || pixelComponentsDiffer(SkColorGetG(p1), SkColorGetG(p2)) |
1247 || pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); | 1163 || pixelComponentsDiffer(SkColorGetB(p1), SkColorGetB(p2)); |
1248 } | 1164 } |
1249 | 1165 |
1250 void GraphicsLayer::checkPaintUnderInvalidations(const SkPicture& newPicture) | 1166 void GraphicsLayer::checkPaintUnderInvalidations(const SkPicture& newPicture) |
1251 { | 1167 { |
1252 if (!drawsContent()) | 1168 if (!drawsContent()) |
1253 return; | 1169 return; |
1254 | 1170 |
1255 auto it = paintInvalidationTrackingMap().find(this); | 1171 RasterInvalidationTracking* tracking = rasterInvalidationTrackingMap().find(
this); |
1256 if (it == paintInvalidationTrackingMap().end()) | 1172 if (!tracking) |
1257 return; | |
1258 PaintInvalidationTracking& tracking = it->value; | |
1259 if (!tracking.lastPaintedPicture) | |
1260 return; | 1173 return; |
1261 | 1174 |
1262 IntRect rect = intersection(tracking.lastInterestRect, interestRect()); | 1175 if (!tracking->lastPaintedPicture) |
| 1176 return; |
| 1177 |
| 1178 IntRect rect = intersection(tracking->lastInterestRect, interestRect()); |
1263 if (rect.isEmpty()) | 1179 if (rect.isEmpty()) |
1264 return; | 1180 return; |
1265 | 1181 |
1266 SkBitmap oldBitmap; | 1182 SkBitmap oldBitmap; |
1267 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); | 1183 oldBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); |
1268 { | 1184 { |
1269 SkCanvas canvas(oldBitmap); | 1185 SkCanvas canvas(oldBitmap); |
1270 canvas.clear(SK_ColorTRANSPARENT); | 1186 canvas.clear(SK_ColorTRANSPARENT); |
1271 canvas.translate(-rect.x(), -rect.y()); | 1187 canvas.translate(-rect.x(), -rect.y()); |
1272 canvas.drawPicture(tracking.lastPaintedPicture.get()); | 1188 canvas.drawPicture(tracking->lastPaintedPicture.get()); |
1273 } | 1189 } |
1274 | 1190 |
1275 SkBitmap newBitmap; | 1191 SkBitmap newBitmap; |
1276 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); | 1192 newBitmap.allocPixels(SkImageInfo::MakeN32Premul(rect.width(), rect.height()
)); |
1277 { | 1193 { |
1278 SkCanvas canvas(newBitmap); | 1194 SkCanvas canvas(newBitmap); |
1279 canvas.clear(SK_ColorTRANSPARENT); | 1195 canvas.clear(SK_ColorTRANSPARENT); |
1280 canvas.translate(-rect.x(), -rect.y()); | 1196 canvas.translate(-rect.x(), -rect.y()); |
1281 canvas.drawPicture(&newPicture); | 1197 canvas.drawPicture(&newPicture); |
1282 } | 1198 } |
1283 | 1199 |
1284 oldBitmap.lockPixels(); | 1200 oldBitmap.lockPixels(); |
1285 newBitmap.lockPixels(); | 1201 newBitmap.lockPixels(); |
1286 int mismatchingPixels = 0; | 1202 int mismatchingPixels = 0; |
1287 static const int maxMismatchesToReport = 50; | 1203 static const int maxMismatchesToReport = 50; |
1288 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { | 1204 for (int bitmapY = 0; bitmapY < rect.height(); ++bitmapY) { |
1289 int layerY = bitmapY + rect.y(); | 1205 int layerY = bitmapY + rect.y(); |
1290 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { | 1206 for (int bitmapX = 0; bitmapX < rect.width(); ++bitmapX) { |
1291 int layerX = bitmapX + rect.x(); | 1207 int layerX = bitmapX + rect.x(); |
1292 SkColor oldPixel = oldBitmap.getColor(bitmapX, bitmapY); | 1208 SkColor oldPixel = oldBitmap.getColor(bitmapX, bitmapY); |
1293 SkColor newPixel = newBitmap.getColor(bitmapX, bitmapY); | 1209 SkColor newPixel = newBitmap.getColor(bitmapX, bitmapY); |
1294 if (pixelsDiffer(oldPixel, newPixel) && !tracking.paintInvalidationR
egionSinceLastPaint.contains(IntPoint(layerX, layerY))) { | 1210 if (pixelsDiffer(oldPixel, newPixel) && !tracking->rasterInvalidatio
nRegionSinceLastPaint.contains(IntPoint(layerX, layerY))) { |
1295 if (mismatchingPixels < maxMismatchesToReport) { | 1211 if (mismatchingPixels < maxMismatchesToReport) { |
1296 UnderPaintInvalidation underPaintInvalidation = { layerX, la
yerY, oldPixel, newPixel }; | 1212 UnderPaintInvalidation underPaintInvalidation = { layerX, la
yerY, oldPixel, newPixel }; |
1297 tracking.underPaintInvalidations.append(underPaintInvalidati
on); | 1213 tracking->underPaintInvalidations.append(underPaintInvalidat
ion); |
1298 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << layerX << "," << layerY << " old:" << std::hex << oldPixel << "
new:" << newPixel; | 1214 LOG(ERROR) << debugName() << " Uninvalidated old/new pixels
mismatch at " << layerX << "," << layerY << " old:" << std::hex << oldPixel << "
new:" << newPixel; |
1299 } else if (mismatchingPixels == maxMismatchesToReport) { | 1215 } else if (mismatchingPixels == maxMismatchesToReport) { |
1300 LOG(ERROR) << "and more..."; | 1216 LOG(ERROR) << "and more..."; |
1301 } | 1217 } |
1302 ++mismatchingPixels; | 1218 ++mismatchingPixels; |
1303 *newBitmap.getAddr32(bitmapX, bitmapY) = SkColorSetARGB(0xFF, 0x
A0, 0, 0); // Dark red. | 1219 *newBitmap.getAddr32(bitmapX, bitmapY) = SkColorSetARGB(0xFF, 0x
A0, 0, 0); // Dark red. |
1304 } else { | 1220 } else { |
1305 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT; | 1221 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT; |
1306 } | 1222 } |
1307 } | 1223 } |
(...skipping 17 matching lines...) Expand all Loading... |
1325 { | 1241 { |
1326 if (!layer) { | 1242 if (!layer) { |
1327 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1243 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1328 return; | 1244 return; |
1329 } | 1245 } |
1330 | 1246 |
1331 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1247 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1332 fprintf(stderr, "%s\n", output.utf8().data()); | 1248 fprintf(stderr, "%s\n", output.utf8().data()); |
1333 } | 1249 } |
1334 #endif | 1250 #endif |
OLD | NEW |