| 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 if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) | 595 // The caller must check isTrackingOrCheckingPaintInvalidations() before cal
ling this method |
| 596 // to avoid constructing the rect unnecessarily. |
| 597 DCHECK(isTrackingOrCheckingPaintInvalidations()); |
| 598 |
| 599 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) |
| 596 return; | 603 return; |
| 597 | 604 |
| 598 PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(thi
s, PaintInvalidationTracking()).storedValue->value; | |
| 599 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; | 605 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; |
| 600 tracking.trackedPaintInvalidations.append(info); | 606 tracking.trackedPaintInvalidations.append(info); |
| 601 | 607 |
| 602 #if DCHECK_IS_ON() | 608 #if DCHECK_IS_ON() |
| 603 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
{ | 609 if (!rect.isEmpty() && RuntimeEnabledFeatures::slimmingPaintUnderInvalidatio
nCheckingEnabled()) { |
| 604 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. | 610 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint
invalidation rect. |
| 605 IntRect r = rect; | 611 IntRect r = rect; |
| 606 r.inflate(1); | 612 r.inflate(1); |
| 607 tracking.paintInvalidationRegionSinceLastPaint.unite(r); | 613 tracking.paintInvalidationRegionSinceLastPaint.unite(r); |
| 608 } | 614 } |
| 609 #endif | 615 #endif |
| 610 } | 616 } |
| 611 | 617 |
| 612 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) | 618 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P
aintInvalidationInfo& b) |
| 613 { | 619 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 return array; | 707 return array; |
| 702 } | 708 } |
| 703 | 709 |
| 704 static String pointerAsString(const void* ptr) | 710 static String pointerAsString(const void* ptr) |
| 705 { | 711 { |
| 706 TextStream ts; | 712 TextStream ts; |
| 707 ts << ptr; | 713 ts << ptr; |
| 708 return ts.release(); | 714 return ts.release(); |
| 709 } | 715 } |
| 710 | 716 |
| 711 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags) cons
t | 717 PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, Rend
eringContextMap& renderingContextMap) const |
| 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 | 723 json->setString("debugName", m_client->debugName(this)); |
| 724 json->setString("name", debugName()); | 724 } |
| 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->layerTreeAsJSONInternal(
flags, renderingContextMap)); | 780 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, r
enderingContextMap)); |
| 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]->layerTreeAsJSONInternal(flag
s, renderingContextMap)); | 864 childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, rende
ringContextMap)); |
| 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 return layerTreeAsJSON(flags)->toPrettyJSONString(); | 873 RenderingContextMap renderingContextMap; |
| 874 RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); |
| 875 return json->toPrettyJSONString(); |
| 874 } | 876 } |
| 875 | 877 |
| 876 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) | 878 static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) |
| 877 { | 879 { |
| 878 return webLayer ? webLayer->ccLayer() : nullptr; | 880 return webLayer ? webLayer->ccLayer() : nullptr; |
| 879 } | 881 } |
| 880 | 882 |
| 881 String GraphicsLayer::debugName(cc::Layer* layer) const | 883 String GraphicsLayer::debugName(cc::Layer* layer) const |
| 882 { | 884 { |
| 883 String name; | 885 String name; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 if (m_isRootForIsolatedGroup == isolated) | 1096 if (m_isRootForIsolatedGroup == isolated) |
| 1095 return; | 1097 return; |
| 1096 m_isRootForIsolatedGroup = isolated; | 1098 m_isRootForIsolatedGroup = isolated; |
| 1097 platformLayer()->setIsRootForIsolatedGroup(isolated); | 1099 platformLayer()->setIsRootForIsolatedGroup(isolated); |
| 1098 } | 1100 } |
| 1099 | 1101 |
| 1100 void GraphicsLayer::setContentsNeedsDisplay() | 1102 void GraphicsLayer::setContentsNeedsDisplay() |
| 1101 { | 1103 { |
| 1102 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { | 1104 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { |
| 1103 contentsLayer->invalidate(); | 1105 contentsLayer->invalidate(); |
| 1104 trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull); | 1106 if (isTrackingOrCheckingPaintInvalidations()) |
| 1107 trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull)
; |
| 1105 } | 1108 } |
| 1106 } | 1109 } |
| 1107 | 1110 |
| 1108 void GraphicsLayer::setNeedsDisplay() | 1111 void GraphicsLayer::setNeedsDisplay() |
| 1109 { | 1112 { |
| 1110 if (!drawsContent()) | 1113 if (!drawsContent()) |
| 1111 return; | 1114 return; |
| 1112 | 1115 |
| 1113 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. | 1116 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursiv
ely does so. |
| 1114 m_layer->layer()->invalidate(); | 1117 m_layer->layer()->invalidate(); |
| 1115 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1118 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 1116 m_linkHighlights[i]->invalidate(); | 1119 m_linkHighlights[i]->invalidate(); |
| 1117 getPaintController().invalidateAll(); | 1120 getPaintController().invalidateAll(); |
| 1118 | 1121 |
| 1119 trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)),
PaintInvalidationFull); | 1122 if (isTrackingOrCheckingPaintInvalidations()) |
| 1123 trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size
)), PaintInvalidationFull); |
| 1120 } | 1124 } |
| 1121 | 1125 |
| 1122 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) | 1126 void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidation
Reason invalidationReason, const DisplayItemClient& client) |
| 1123 { | 1127 { |
| 1124 if (!drawsContent()) | 1128 if (!drawsContent()) |
| 1125 return; | 1129 return; |
| 1126 | 1130 |
| 1127 m_layer->layer()->invalidateRect(rect); | 1131 m_layer->layer()->invalidateRect(rect); |
| 1128 if (firstPaintInvalidationTrackingEnabled()) | 1132 if (firstPaintInvalidationTrackingEnabled()) |
| 1129 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); | 1133 m_debugInfo.appendAnnotatedInvalidateRect(rect, invalidationReason); |
| 1130 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1134 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 1131 m_linkHighlights[i]->invalidate(); | 1135 m_linkHighlights[i]->invalidate(); |
| 1132 | 1136 |
| 1133 trackPaintInvalidation(client, rect, invalidationReason); | 1137 if (isTrackingOrCheckingPaintInvalidations()) |
| 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)
; |
| 1134 } | 1150 } |
| 1135 | 1151 |
| 1136 void GraphicsLayer::setContentsRect(const IntRect& rect) | 1152 void GraphicsLayer::setContentsRect(const IntRect& rect) |
| 1137 { | 1153 { |
| 1138 if (rect == m_contentsRect) | 1154 if (rect == m_contentsRect) |
| 1139 return; | 1155 return; |
| 1140 | 1156 |
| 1141 m_contentsRect = rect; | 1157 m_contentsRect = rect; |
| 1142 updateContentsRect(); | 1158 updateContentsRect(); |
| 1143 } | 1159 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 { | 1385 { |
| 1370 if (!layer) { | 1386 if (!layer) { |
| 1371 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); | 1387 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); |
| 1372 return; | 1388 return; |
| 1373 } | 1389 } |
| 1374 | 1390 |
| 1375 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); | 1391 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); |
| 1376 fprintf(stderr, "%s\n", output.utf8().data()); | 1392 fprintf(stderr, "%s\n", output.utf8().data()); |
| 1377 } | 1393 } |
| 1378 #endif | 1394 #endif |
| OLD | NEW |