[m87 merge] Reduce 3d Engine Work for Steady State Video Playback

When DirectCompositionChildSurfaceWin::EnqueuePendingFrame is called if
swap_rect_ is non-empty a d3d11 query is created resulting in 3d engine
work.

Due to an optimization in DirectRenderer::DrawFrame (see
https://source.chromium.org/chromium/chromium/src/+/master:components/v
iz/service/display/direct_renderer.cc;drc=be67975e8044611cc91a8dc5f138e
bd6cf67bbe1;l=402) we are not however currently clearing swap_rect_ by
calling DirectCompositionChildSurfaceWin::SetDrawRectangle with an
empty rect when there is no damage to the root.

As a result after the first SetDrawRectangle call 3d engine work is
performed for each queued frame.

To help reduce the amount of 3d engine work we'll reset swap_rect_ at
the end of SwapBuffers;  allowing the d3d11 query to be skipped until
the next new SetDrawRectangle occurs.

(cherry picked from commit b005a9a89d99c78df4c2d99f0a67a7b72e532910)

Bug: 1133916
Change-Id: I84ccf81d18a8e45e1ce871484a763c20e5bb6418
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443489
Commit-Queue: William Carr <[email protected]>
Reviewed-by: Sunny Sachanandani <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#812886}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461056
Commit-Queue: Sunny Sachanandani <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#205}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/ui/gl/direct_composition_child_surface_win.cc b/ui/gl/direct_composition_child_surface_win.cc
index 84c9cec37..ee62906 100644
--- a/ui/gl/direct_composition_child_surface_win.cc
+++ b/ui/gl/direct_composition_child_surface_win.cc
@@ -260,6 +260,11 @@
                                     ? gfx::SwapResult::SWAP_ACK
                                     : gfx::SwapResult::SWAP_FAILED;
   EnqueuePendingFrame(std::move(callback));
+
+  // Reset swap_rect_ since SetDrawRectangle may not be called when the root
+  // damage rect is empty.
+  swap_rect_ = gfx::Rect();
+
   return swap_result;
 }