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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return !it->value.isEmpty(); 542 return !it->value.isEmpty();
543 return false; 543 return false;
544 } 544 }
545 545
546 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons t FloatRect& rect, PaintInvalidationReason reason) 546 void GraphicsLayer::trackPaintInvalidation(const DisplayItemClient& client, cons t FloatRect& rect, PaintInvalidationReason reason)
547 { 547 {
548 // The caller must check isTrackingPaintInvalidations() before calling this method 548 // The caller must check isTrackingPaintInvalidations() before calling this method
549 // to avoid constructing the rect unnecessarily. 549 // to avoid constructing the rect unnecessarily.
550 ASSERT(isTrackingPaintInvalidations()); 550 ASSERT(isTrackingPaintInvalidations());
551 551
552 Vector<PaintInvalidationInfo>& infos = paintInvalidationTrackingMap().add(th is, Vector<PaintInvalidationInfo>()).storedValue->value;
553 // Omit the entry for invalidateDisplayItemClient() if the last entry is for the same client.
554 // This is to avoid duplicated entries for setNeedsDisplayInRect() and inval idateDisplayItemClient().
555 if (rect.isEmpty() && !infos.isEmpty() && infos.last().client == &client)
556 return;
557
552 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason }; 558 PaintInvalidationInfo info = { &client, client.debugName(), rect, reason };
553 paintInvalidationTrackingMap().add(this, Vector<PaintInvalidationInfo>()).st oredValue->value.append(info); 559 infos.append(info);
554 } 560 }
555 561
556 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P aintInvalidationInfo& b) 562 static bool comparePaintInvalidationInfo(const PaintInvalidationInfo& a, const P aintInvalidationInfo& b)
557 { 563 {
558 return codePointCompareLessThan(a.clientDebugName, b.clientDebugName); 564 // Sort by rect first, bigger rects before smaller ones.
565 if (a.rect.width() != b.rect.width())
566 return a.rect.width() > b.rect.width();
567 if (a.rect.height() != b.rect.height())
568 return a.rect.height() > b.rect.height();
569 if (a.rect.x() != b.rect.x())
570 return a.rect.x() > b.rect.x();
571 if (a.rect.y() != b.rect.y())
572 return a.rect.y() > b.rect.y();
573
574 // Then compare clientDebugName, in alphabetic order.
575 int nameCompareResult = codePointCompare(a.clientDebugName, b.clientDebugNam e);
576 if (nameCompareResult != 0)
577 return nameCompareResult < 0;
578
579 return a.reason < b.reason;
559 } 580 }
560 581
561 template <typename T> 582 template <typename T>
562 static PassRefPtr<JSONArray> pointAsJSONArray(const T& point) 583 static PassRefPtr<JSONArray> pointAsJSONArray(const T& point)
563 { 584 {
564 RefPtr<JSONArray> array = JSONArray::create(); 585 RefPtr<JSONArray> array = JSONArray::create();
565 array->pushNumber(point.x()); 586 array->pushNumber(point.x());
566 array->pushNumber(point.y()); 587 array->pushNumber(point.y());
567 return array; 588 return array;
568 } 589 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, r enderingContextMap)); 724 json->setObject("replicaLayer", m_replicaLayer->layerTreeAsJSON(flags, r enderingContextMap));
704 725
705 if (m_replicatedLayer) 726 if (m_replicatedLayer)
706 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ? pointerAsString(m_replicatedLayer) : ""); 727 json->setString("replicatedLayer", flags & LayerTreeIncludesDebugInfo ? pointerAsString(m_replicatedLayer) : "");
707 728
708 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f ind(this); 729 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f ind(this);
709 if (it != paintInvalidationTrackingMap().end()) { 730 if (it != paintInvalidationTrackingMap().end()) {
710 if (flags & LayerTreeIncludesPaintInvalidations) { 731 if (flags & LayerTreeIncludesPaintInvalidations) {
711 Vector<PaintInvalidationInfo>& infos = it->value; 732 Vector<PaintInvalidationInfo>& infos = it->value;
712 if (!infos.isEmpty()) { 733 if (!infos.isEmpty()) {
713 std::stable_sort(infos.begin(), infos.end(), &comparePaintInvali dationInfo); 734 std::sort(infos.begin(), infos.end(), &comparePaintInvalidationI nfo);
714 RefPtr<JSONArray> paintInvalidationsJSON = JSONArray::create(); 735 RefPtr<JSONArray> paintInvalidationsJSON = JSONArray::create();
715 const DisplayItemClient* lastDisplayItemClientWithRect = nullptr ;
716 for (auto& info : infos) { 736 for (auto& info : infos) {
717 RefPtr<JSONObject> infoJSON = JSONObject::create(); 737 RefPtr<JSONObject> infoJSON = JSONObject::create();
718 if (info.rect.isEmpty()) {
719 // Entry with empty rect is from invalidateDisplayItemCl ient().
720 // Skip the entry if the client is the same as the previ ous setNeedsDisplayInRect().
721 if (info.client == lastDisplayItemClientWithRect)
722 continue;
723 } else {
724 lastDisplayItemClientWithRect = info.client;
725 }
726 infoJSON->setString("object", info.clientDebugName); 738 infoJSON->setString("object", info.clientDebugName);
727 infoJSON->setArray("rect", rectAsJSONArray(info.rect)); 739 if (!info.rect.isEmpty())
740 infoJSON->setArray("rect", rectAsJSONArray(info.rect));
728 infoJSON->setString("reason", paintInvalidationReasonToStrin g(info.reason)); 741 infoJSON->setString("reason", paintInvalidationReasonToStrin g(info.reason));
729 paintInvalidationsJSON->pushObject(infoJSON); 742 paintInvalidationsJSON->pushObject(infoJSON);
730 } 743 }
731 json->setArray("paintInvalidations", paintInvalidationsJSON); 744 json->setArray("paintInvalidations", paintInvalidationsJSON);
732 } 745 }
733 } 746 }
734 } 747 }
735 748
736 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) { 749 if ((flags & LayerTreeIncludesPaintingPhases) && m_paintingPhase) {
737 RefPtr<JSONArray> paintingPhasesJSON = JSONArray::create(); 750 RefPtr<JSONArray> paintingPhasesJSON = JSONArray::create();
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 { 1226 {
1214 if (!layer) { 1227 if (!layer) {
1215 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1228 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1216 return; 1229 return;
1217 } 1230 }
1218 1231
1219 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1232 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1220 fprintf(stderr, "%s\n", output.utf8().data()); 1233 fprintf(stderr, "%s\n", output.utf8().data());
1221 } 1234 }
1222 #endif 1235 #endif
OLDNEW
« 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