Index: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
index 7572bd3b716dd3e9dd9e32d8defa9598ab1300ca..3d2fdd1d2060905c0099679bde7b0861d2531d36 100644 |
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
@@ -592,15 +592,21 @@ |
void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, const IntRect& rect, PaintInvalidationReason reason) |
{ |
- if (!isTrackingOrCheckingPaintInvalidations() || rect.isEmpty()) |
- return; |
+ // The caller must check isTrackingOrCheckingPaintInvalidations() before calling this method |
+ // to avoid constructing the rect unnecessarily. |
+ DCHECK(isTrackingOrCheckingPaintInvalidations()); |
PaintInvalidationTracking& tracking = paintInvalidationTrackingMap().add(this, PaintInvalidationTracking()).storedValue->value; |
+ // Omit the entry for trackObjectPaintInvalidation() if the last entry is for the same client. |
+ // This is to avoid duplicated entries for setNeedsDisplayInRect() and trackObjectPaintInvalidation(). |
+ if (rect.isEmpty() && !tracking.trackedPaintInvalidations.isEmpty() && tracking.trackedPaintInvalidations.last().client == &client) |
+ return; |
+ |
PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; |
tracking.trackedPaintInvalidations.append(info); |
#if DCHECK_IS_ON() |
- if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { |
+ if (!rect.isEmpty() && RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { |
// TODO(crbug.com/496260): Some antialiasing effects overflows the paint invalidation rect. |
IntRect r = rect; |
r.inflate(1); |
@@ -708,20 +714,14 @@ |
return ts.release(); |
} |
-PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags) const |
-{ |
- RenderingContextMap renderingContextMap; |
- return layerTreeAsJSONInternal(flags, renderingContextMap); |
-} |
- |
-PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSONInternal(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const |
+PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, RenderingContextMap& renderingContextMap) const |
{ |
RefPtr<JSONObject> json = JSONObject::create(); |
- if (flags & LayerTreeIncludesDebugInfo) |
+ if (flags & LayerTreeIncludesDebugInfo) { |
json->setString("this", pointerAsString(this)); |
- |
- json->setString("name", debugName()); |
+ json->setString("debugName", m_client->debugName(this)); |
+ } |
if (m_position != FloatPoint()) |
json->setArray("position", pointAsJSONArray(m_position)); |
@@ -777,7 +777,7 @@ |
json->setArray("transform", transformAsJSONArray(m_transform)); |
if (m_replicaLayer) |
- json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSONInternal(flags, renderingContextMap)); |
+ json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, renderingContextMap)); |
if (m_replicatedLayer) |
json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ? pointerAsString(m_replicatedLayer) : ""); |
@@ -861,7 +861,7 @@ |
if (m_children.size()) { |
RefPtr<JSONArray> childrenJSON = JSONArray::create(); |
for (size_t i = 0; i < m_children.size(); i++) |
- childrenJSON->pushObject(m_children[i]->layerTreeAsJSONInternal(flags, renderingContextMap)); |
+ childrenJSON->pushObject(m_children[i]->layerTreeAsJSON(flags, renderingContextMap)); |
json->setArray("children", childrenJSON); |
} |
@@ -870,7 +870,9 @@ |
String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const |
{ |
- return layerTreeAsJSON(flags)->toPrettyJSONString(); |
+ RenderingContextMap renderingContextMap; |
+ RefPtr<JSONObject> json = layerTreeAsJSON(flags, renderingContextMap); |
+ return json->toPrettyJSONString(); |
} |
static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) |
@@ -1101,7 +1103,8 @@ |
{ |
if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { |
contentsLayer->invalidate(); |
- trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull); |
+ if (isTrackingOrCheckingPaintInvalidations()) |
+ trackPaintInvalidation(*this, m_contentsRect, PaintInvalidationFull); |
} |
} |
@@ -1116,7 +1119,8 @@ |
m_linkHighlights[i]->invalidate(); |
getPaintController().invalidateAll(); |
- trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)), PaintInvalidationFull); |
+ if (isTrackingOrCheckingPaintInvalidations()) |
+ trackPaintInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)), PaintInvalidationFull); |
} |
void GraphicsLayer::setNeedsDisplayInRect(const IntRect& rect, PaintInvalidationReason invalidationReason, const DisplayItemClient& client) |
@@ -1130,7 +1134,19 @@ |
for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
m_linkHighlights[i]->invalidate(); |
- trackPaintInvalidation(client, rect, invalidationReason); |
+ if (isTrackingOrCheckingPaintInvalidations()) |
+ trackPaintInvalidation(client, rect, invalidationReason); |
+} |
+ |
+void GraphicsLayer::displayItemClientWasInvalidated(const DisplayItemClient& displayItemClient, PaintInvalidationReason invalidationReason) |
+{ |
+ if (!drawsContent()) |
+ return; |
+ |
+ getPaintController().displayItemClientWasInvalidated(displayItemClient); |
+ |
+ if (isTrackingOrCheckingPaintInvalidations()) |
+ trackPaintInvalidation(displayItemClient, IntRect(), invalidationReason); |
} |
void GraphicsLayer::setContentsRect(const IntRect& rect) |