Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp

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

Powered by Google App Engine
This is Rietveld 408576698