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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 bool GraphicsLayer::hasTrackedPaintInvalidations() const | 585 bool GraphicsLayer::hasTrackedPaintInvalidations() const |
586 { | 586 { |
587 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 587 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); |
588 if (it != paintInvalidationTrackingMap().end()) | 588 if (it != paintInvalidationTrackingMap().end()) |
589 return !it->value.trackedPaintInvalidations.isEmpty(); | 589 return !it->value.trackedPaintInvalidations.isEmpty(); |
590 return false; | 590 return false; |
591 } | 591 } |
592 | 592 |
593 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) | 593 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
t IntRect& rect, PaintInvalidationReason reason) |
594 { | 594 { |
595 // The caller must check isTrackingOrCheckingPaintInvalidations() before cal
ling this method | 595 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) |
596 // to avoid constructing the rect unnecessarily. | 596 return; |
597 DCHECK(isTrackingOrCheckingPaintInvalidations()); | |
598 | 597 |
599 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; | 598 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; |
600 // Omit the entry for trackObjectPaintInvalidation() if the last entry is fo
r the same client. | |
601 // This is to avoid duplicated entries for setNeedsDisplayInRect() and track
ObjectPaintInvalidation(). | |
602 if (rect.isEmpty() && !tracking.trackedPaintInvalidations.isEmpty() && track
ing.trackedPaintInvalidations.last().client == &client) | |
603 return; | |
604 | |
605 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; | 599 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; |
606 tracking.trackedPaintInvalidations.append(info); | 600 tracking.trackedPaintInvalidations.append(info); |
607 | 601 |
608 #if DCHECK_IS_ON() | 602 #if DCHECK_IS_ON() |
609 if (!rect.isEmpty() && RuntimeEnabledFeatures::slimmingPaintUnderInvalidatio
nCheckingEnabled()) { | 603 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
{ |
610 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. | 604 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. |
611 IntRect r = rect; | 605 IntRect r = rect; |
612 r.inflate(1); | 606 r.inflate(1); |
613 tracking.paintInvalidationRegionSinceLastPaint.unite(r); | 607 tracking.paintInvalidationRegionSinceLastPaint.unite(r); |
614 } | 608 } |
615 #endif | 609 #endif |
616 } | 610 } |
617 | 611 |
618 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) | 612 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) |
619 { | 613 { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 return array; | 701 return array; |
708 } | 702 } |
709 | 703 |
710 static String pointerAsString(const void* ptr) | 704 static String pointerAsString(const void* ptr) |
711 { | 705 { |
712 TextStream ts; | 706 TextStream ts; |
713 ts << ptr; | 707 ts << ptr; |
714 return ts.release(); | 708 return ts.release(); |
715 } | 709 } |
716 | 710 |
717 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, Rend
eringContextMap& renderingContextMap) const | 711 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags) cons
t |
| 712 { |
| 713 RenderingContextMap renderingContextMap; |
| 714 return layerTreeAsJSONInternal(flags, renderingContextMap); |
| 715 } |
| 716 |
| 717 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlags fla
gs, RenderingContextMap& renderingContextMap) const |
718 { | 718 { |
719 RefPtr<JSONObject> json = JSONObject::create(); | 719 RefPtr<JSONObject> json = JSONObject::create(); |
720 | 720 |
721 if (flags & LayerTreeIncludesDebugInfo) { | 721 if (flags & LayerTreeIncludesDebugInfo) |
722 json->setString("this", pointerAsString(this)); | 722 json->setString("this", pointerAsString(this)); |
723 json->setString("debugName", m_client->debugName(this)); | 723 |
724 } | 724 json->setString("name", debugName()); |
725 | 725 |
726 if (m_position != FloatPoint()) | 726 if (m_position != FloatPoint()) |
727 json->setArray("position", pointAsJSONArray(m_position)); | 727 json->setArray("position", pointAsJSONArray(m_position)); |
728 | 728 |
729 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) | 729 if (m_hasTransformOrigin && m_transformOrigin != FloatPoint3D(m_size.width()
* 0.5f, m_size.height() * 0.5f, 0)) |
730 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); | 730 json->setArray("transformOrigin", pointAsJSONArray(m_transformOrigin)); |
731 | 731 |
732 if (m_size != IntSize()) | 732 if (m_size != IntSize()) |
733 json->setArray("bounds", sizeAsJSONArray(m_size)); | 733 json->setArray("bounds", sizeAsJSONArray(m_size)); |
734 | 734 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 if (flags & LayerTreeIncludesDebugInfo) | 770 if (flags & LayerTreeIncludesDebugInfo) |
771 json->setString("client", pointerAsString(m_client)); | 771 json->setString("client", pointerAsString(m_client)); |
772 | 772 |
773 if (m_backgroundColor.alpha()) | 773 if (m_backgroundColor.alpha()) |
774 json->setString("backgroundColor", m_backgroundColor.nameForLayoutTreeAs
Text()); | 774 json->setString("backgroundColor", m_backgroundColor.nameForLayoutTreeAs
Text()); |
775 | 775 |
776 if (!m_transform.isIdentity()) | 776 if (!m_transform.isIdentity()) |
777 json->setArray("transform", transformAsJSONArray(m_transform)); | 777 json->setArray("transform", transformAsJSONArray(m_transform)); |
778 | 778 |
779 if (m_replicaLayer) | 779 if (m_replicaLayer) |
780 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, r
enderingContextMap)); | 780 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSONInternal(
flags, renderingContextMap)); |
781 | 781 |
782 if (m_replicatedLayer) | 782 if (m_replicatedLayer) |
783 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); | 783 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ?
pointerAsString(m_replicatedLayer) : ""); |
784 | 784 |
785 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); | 785 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f
ind(this); |
786 if (it != paintInvalidationTrackingMap().end()) { | 786 if (it != paintInvalidationTrackingMap().end()) { |
787 if (flags & LayerTreeIncludesPaintInvalidations) { | 787 if (flags & LayerTreeIncludesPaintInvalidations) { |
788 Vector<PaintInvalidationInfo>& infos = it->value.trackedPaintInvalid
ations; | 788 Vector<PaintInvalidationInfo>& infos = it->value.trackedPaintInvalid
ations; |
789 if (!infos.isEmpty()) { | 789 if (!infos.isEmpty()) { |
790 std::sort(infos.begin(), infos.end(), &comparePaintInvalidationI
nfo); | 790 std::sort(infos.begin(), infos.end(), &comparePaintInvalidationI
nfo); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { | 854 for (size_t i = 0; i < kNumberOfSquashingDisallowedReasons; ++i) { |
855 if (m_debugInfo.getSquashingDisallowedReasons() & kSquashingDisallow
edReasonStringMap[i].reason) | 855 if (m_debugInfo.getSquashingDisallowedReasons() & kSquashingDisallow
edReasonStringMap[i].reason) |
856 squashingDisallowedReasonsJSON->pushString(debug ? kSquashingDis
allowedReasonStringMap[i].description : kSquashingDisallowedReasonStringMap[i].s
hortName); | 856 squashingDisallowedReasonsJSON->pushString(debug ? kSquashingDis
allowedReasonStringMap[i].description : kSquashingDisallowedReasonStringMap[i].s
hortName); |
857 } | 857 } |
858 json->setArray("squashingDisallowedReasons", squashingDisallowedReasonsJ
SON); | 858 json->setArray("squashingDisallowedReasons", squashingDisallowedReasonsJ
SON); |
859 } | 859 } |
860 | 860 |
861 if (m_children.size()) { | 861 if (m_children.size()) { |
862 RefPtr<JSONArray> childrenJSON = JSONArray::create(); | 862 RefPtr<JSONArray> childrenJSON = JSONArray::create(); |
863 for (size_t i = 0; i < m_children.size(); i++) | 863 for (size_t i = 0; i < m_children.size(); i++) |
864 childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, rende
ringContextMap)); | 864 childrenJSON->pushObject(m_children[i]->layerTreeAsJSONInternal(flag
s, renderingContextMap)); |
865 json->setArray("children", childrenJSON); | 865 json->setArray("children", childrenJSON); |
866 } | 866 } |
867 | 867 |
868 return json; | 868 return json; |
869 } | 869 } |
870 | 870 |
871 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const | 871 String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
872 { | 872 { |
873 RenderingContextMap renderingContextMap; | 873 return layerTreeAsJSON(flags)->toPrettyJSONString(); |
874 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); | |
875 return json->toPrettyJSONString(); | |
876 } | 874 } |
877 | 875 |
878 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) | 876 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) |
879 { | 877 { |
880 return webLayer ? webLayer->ccLayer() : nullptr; | 878 return webLayer ? webLayer->ccLayer() : nullptr; |
881 } | 879 } |
882 | 880 |
883 String GraphicsLayer::debugName(cc::Layer* layer) const | 881 String GraphicsLayer::debugName(cc::Layer* layer) const |
884 { | 882 { |
885 String name; | 883 String name; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 if (m_isRootForIsolatedGroup == isolated) | 1094 if (m_isRootForIsolatedGroup == isolated) |
1097 return; | 1095 return; |
1098 m_isRootForIsolatedGroup = isolated; | 1096 m_isRootForIsolatedGroup = isolated; |
1099 platformLayer()->setIsRootForIsolatedGroup(isolated); | 1097 platformLayer()->setIsRootForIsolatedGroup(isolated); |
1100 } | 1098 } |
1101 | 1099 |
1102 void GraphicsLayer::setContentsNeedsDisplay() | 1100 void GraphicsLayer::setContentsNeedsDisplay() |
1103 { | 1101 { |
1104 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { | 1102 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { |
1105 contentsLayer->invalidate(); | 1103 contentsLayer->invalidate(); |
1106 if (isTrackingOrCheckingPaintInvalidations()) | 1104 trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull); |
1107 trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull)
; | |
1108 } | 1105 } |
1109 } | 1106 } |
1110 | 1107 |
1111 void GraphicsLayer::setNeedsDisplay() | 1108 void GraphicsLayer::setNeedsDisplay() |
1112 { | 1109 { |
1113 if (!drawsContent()) | 1110 if (!drawsContent()) |
1114 return; | 1111 return; |
1115 | 1112 |
1116 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. | 1113 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. |
1117 m_layer->layer()->invalidate(); | 1114 m_layer->layer()->invalidate(); |
1118 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1115 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1119 m_linkHighlights[i]->invalidate(); | 1116 m_linkHighlights[i]->invalidate(); |
1120 getPaintController().invalidateAll(); | 1117 getPaintController().invalidateAll(); |
1121 | 1118 |
1122 if (isTrackingOrCheckingPaintInvalidations()) | 1119 trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)),
PaintInvalidationFull); |
1123 trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size
)), PaintInvalidationFull); | |
1124 } | 1120 } |
1125 | 1121 |
1126 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) | 1122 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) |
1127 { | 1123 { |
1128 if (!drawsContent()) | 1124 if (!drawsContent()) |
1129 return; | 1125 return; |
1130 | 1126 |
1131 m_layer->layer()->invalidateRect(rect); | 1127 m_layer->layer()->invalidateRect(rect); |
1132 if (firstPaintInvalidationTrackingEnabled()) | 1128 if (firstPaintInvalidationTrackingEnabled()) |
1133 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); | 1129 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); |
1134 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1130 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
1135 m_linkHighlights[i]->invalidate(); | 1131 m_linkHighlights[i]->invalidate(); |
1136 | 1132 |
1137 if (isTrackingOrCheckingPaintInvalidations()) | 1133 trackPaintInvalidation(client, rect, invalidationReason); |
1138 trackPaintInvalidation(client, rect, invalidationReason); | |
1139 } | |
1140 | |
1141 void GraphicsLayer::displayItemClientWasInvalidated(const DisplayItemClient& dis
playItemClient, PaintInvalidationReason invalidationReason) | |
1142 { | |
1143 if (!drawsContent()) | |
1144 return; | |
1145 | |
1146 getPaintController().displayItemClientWasInvalidated(displayItemClient); | |
1147 | |
1148 if (isTrackingOrCheckingPaintInvalidations()) | |
1149 trackPaintInvalidation(displayItemClient, IntRect(), invalidationReason)
; | |
1150 } | 1134 } |
1151 | 1135 |
1152 void GraphicsLayer::setContentsRect(const IntRect& rect) | 1136 void GraphicsLayer::setContentsRect(const IntRect& rect) |
1153 { | 1137 { |
1154 if (rect == m_contentsRect) | 1138 if (rect == m_contentsRect) |
1155 return; | 1139 return; |
1156 | 1140 |
1157 m_contentsRect = rect; | 1141 m_contentsRect = rect; |
1158 updateContentsRect(); | 1142 updateContentsRect(); |
1159 } | 1143 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 { | 1369 { |
1386 if (!layer) { | 1370 if (!layer) { |
1387 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1371 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
1388 return; | 1372 return; |
1389 } | 1373 } |
1390 | 1374 |
1391 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1375 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
1392 fprintf(stderr, "%s\n", output.utf8().data()); | 1376 fprintf(stderr, "%s\n", output.utf8().data()); |
1393 } | 1377 } |
1394 #endif | 1378 #endif |
OLD | NEW |