Bug 1593170. Avoid useless painting work in queued up rects to paint by ignoring new rects that are already covered. r=mattwoodrow
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 18 Nov 2019 11:26:45 +0000
changeset 502490 285e9108032ffb6cd62fe7d587ef97c1a86d8d41
parent 502489 ddcfa0a1fa00353cb74f5b237a9652bce8398b45
child 502491 0dc7546c4a8a75dda043edc312305a6ceba0ad53
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1593170
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593170. Avoid useless painting work in queued up rects to paint by ignoring new rects that are already covered. r=mattwoodrow I don't think this is strictly necessary but it lets us avoid a bunch of useless work, especially with webrender where these rects are always the full window size. Differential Revision: https://phabricator.services.mozilla.com/D51346
layout/tools/reftest/reftest-content.js
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -645,19 +645,36 @@ function WaitForTestEnd(contentRootEleme
     function AfterPaintListener(event) {
         LogInfo("AfterPaintListener in " + event.target.document.location.href);
         if (event.target.document != currentDoc) {
             // ignore paint events for subframes or old documents in the window.
             // Invalidation in subframes will cause invalidation in the toplevel document anyway.
             return;
         }
 
+        // true if rectA contains rectB
+        function Contains(rectA, rectB) {
+            return (rectA.left <= rectB.left && rectB.right <= rectA.right && rectA.top <= rectB.top && rectB.bottom <= rectA.bottom);
+        }
+        // true if some rect in rectList contains rect
+        function ContainedIn(rectList, rect) {
+            for (let i = 0; i < rectList.length; ++i) {
+                if (Contains(rectList[i], rect)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
         updateCanvasPending = true;
         for (let i = 0; i < event.clientRects.length; ++i) {
             let r = event.clientRects[i];
+            if (ContainedIn(updateCanvasRects, r)) {
+                continue;
+            }
 
             // Copy the rect; it's content and we are chrome, which means if the
             // document goes away (and it can in some crashtests) our reference
             // to it will be turned into a dead wrapper that we can't acccess.
             updateCanvasRects.push({ left: r.left, top: r.top, right: r.right, bottom: r.bottom });
         }
 
         if (waitingForAnAfterPaint) {