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

Unified Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp

Issue 1883723002: Sort layer tree paint invalidations by all fields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 451320eac0b3b9df4febbf2dfab8260137e1fab2..40d369468b0466df1cfff4712d2beb88238e8cd8 100644
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
@@ -549,13 +549,34 @@ void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons
// to avoid constructing the rect unnecessarily.
ASSERT(isTrackingPaintInvalidations());
+ Vector<PaintInvalidationInfo>& infos = paintInvalidationTrackingMap().add(this, Vector<PaintInvalidationInfo>()).storedValue->value;
+ // Omit the entry for invalidateDisplayItemClient() if the last entry is for the same client.
+ // This is to avoid duplicated entries for setNeedsDisplayInRect() and invalidateDisplayItemClient().
+ if (rect.isEmpty() && !infos.isEmpty() && infos.last().client == &client)
+ return;
+
PaintInvalidationInfo info = { &client, client.debugName(), rect, reason };
- paintInvalidationTrackingMap().add(this, Vector<PaintInvalidationInfo>()).storedValue->value.append(info);
+ infos.append(info);
}
static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const PaintInvalidationInfo& b)
{
- return codePointCompareLessThan(a.clientDebugName, b.clientDebugName);
+ // Sort by rect first, bigger rects before smaller ones.
+ if (a.rect.width() != b.rect.width())
+ return a.rect.width() > b.rect.width();
+ if (a.rect.height() != b.rect.height())
+ return a.rect.height() > b.rect.height();
+ if (a.rect.x() != b.rect.x())
+ return a.rect.x() > b.rect.x();
+ if (a.rect.y() != b.rect.y())
+ return a.rect.y() > b.rect.y();
+
+ // Then compare clientDebugName, in alphabetic order.
+ int nameCompareResult = codePointCompare(a.clientDebugName, b.clientDebugName);
+ if (nameCompareResult != 0)
+ return nameCompareResult < 0;
+
+ return a.reason < b.reason;
}
template <typename T>
@@ -710,21 +731,13 @@ PassRefPtr<JSONObject> GraphicsLayer::layerTreeAsJSON(LayerTreeFlags flags, Rend
if (flags & LayerTreeIncludesPaintInvalidations) {
Vector<PaintInvalidationInfo>& infos = it->value;
if (!infos.isEmpty()) {
- std::stable_sort(infos.begin(), infos.end(), &comparePaintInvalidationInfo);
+ std::sort(infos.begin(), infos.end(), &comparePaintInvalidationInfo);
RefPtr<JSONArray> paintInvalidationsJSON = JSONArray::create();
- const DisplayItemClient* lastDisplayItemClientWithRect = nullptr;
for (auto& info : infos) {
RefPtr<JSONObject> infoJSON = JSONObject::create();
- if (info.rect.isEmpty()) {
- // Entry with empty rect is from invalidateDisplayItemClient().
- // Skip the entry if the client is the same as the previous setNeedsDisplayInRect().
- if (info.client == lastDisplayItemClientWithRect)
- continue;
- } else {
- lastDisplayItemClientWithRect = info.client;
- }
infoJSON->setString("object", info.clientDebugName);
- infoJSON->setArray("rect", rectAsJSONArray(info.rect));
+ if (!info.rect.isEmpty())
+ infoJSON->setArray("rect", rectAsJSONArray(info.rect));
infoJSON->setString("reason", paintInvalidationReasonToString(info.reason));
paintInvalidationsJSON->pushObject(infoJSON);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698