Bug 1593170. Avoid useless painting work in queued up rects to paint by ignoring new rects that are already covered. r=mattwoodrow
☠☠ backed out by bdca724cf3a2 ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 18 Nov 2019 00:45:46 +0000
changeset 502364 a10072d821e51e633d96a86120595e37a49429c2
parent 502363 80bd8cadf835988a4ea48084d80cf47eb4aa5b24
child 502365 d511975b764e8f5e97c4511dc39c9aa103e30793
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) {