iHD: Re-apply "VP-Explicitly-initialize-maxSrcRect-of-VphalRenderer."

This CL re-applies the aforementioned patch. That patch was originally
introduced by CL:2173244. It was removed in CL:2269975 with the
intention to re-apply it in its own CL to allow for bisectability.

The patch is needed because it's upstream starting on
intel-media-20.2.pre2 [1].

Note that I regenerated the .patch by cherry picking from upstream
instead of using the file previously checked into Chrome OS.

[1] https://github.com/intel/media-driver/commit/07a818120af884fefb6a0a4e5894a150aa5447cb

BUG=b:159825228
TEST=emerge-eve x11-libs/libva-intel-media-driver
TEST=See CL:2173244 for functional testing (I did not repeat it)

Cq-Depend: chromium:2278035
Change-Id: I288489b572a6cb790fed428b5985bf4d41945e3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2278036
Tested-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Miguel Casas <mcasas@chromium.org>
diff --git a/x11-libs/libva-intel-media-driver/files/0003-VP-Explicitly-initialize-maxSrcRect-of-VphalRenderer.patch b/x11-libs/libva-intel-media-driver/files/0003-VP-Explicitly-initialize-maxSrcRect-of-VphalRenderer.patch
new file mode 100644
index 0000000..afb33b0
--- /dev/null
+++ b/x11-libs/libva-intel-media-driver/files/0003-VP-Explicitly-initialize-maxSrcRect-of-VphalRenderer.patch
@@ -0,0 +1,65 @@
+From 06651724ed461ab48490a68d53fa95008fa871f8 Mon Sep 17 00:00:00 2001
+From: Yu Kang Ku <yu.kang.ku@intel.com>
+Date: Wed, 22 Apr 2020 22:26:48 -0700
+Subject: [PATCH 3/5] [VP] Explicitly initialize maxSrcRect of VphalRenderer
+
+The maxSrcRect member keeps track of the maximum rectangle
+among a set of source surfaces.  There is a need to
+explicitly re-initialize this member in VphalState::Render
+prior to calling the main render function.  This is so that
+the maxSrcRect value for the last set of surfaces does not
+get re-used for the current set of surfaces.
+
+This fixes https://github.com/intel/media-driver/issues/905.
+
+(cherry picked from commit 07a818120af884fefb6a0a4e5894a150aa5447cb)
+---
+ media_driver/agnostic/common/vp/hal/vphal.cpp     |  5 +++++
+ .../agnostic/common/vp/hal/vphal_renderer.h       | 15 +++++++++++++++
+ 2 files changed, 20 insertions(+)
+
+diff --git a/media_driver/agnostic/common/vp/hal/vphal.cpp b/media_driver/agnostic/common/vp/hal/vphal.cpp
+index ed3fc7e3..f7cefa0c 100755
+--- a/media_driver/agnostic/common/vp/hal/vphal.cpp
++++ b/media_driver/agnostic/common/vp/hal/vphal.cpp
+@@ -562,6 +562,11 @@ MOS_STATUS VphalState::Render(
+     VPHAL_PUBLIC_CHK_NULL(pcRenderParams);
+     RenderParams    = *pcRenderParams;
+ 
++    // Explicitly initialize the maxSrcRect of VphalRenderer
++    // so that the maxSrcRect for the last set of surfaces does not get
++    // re-used for the current set of surfaces.
++    m_renderer->InitMaxSrcRect();
++
+     if (VpHal_IsAvsSampleForMultiStreamsEnabled(pcRenderParams))
+     {
+         eStatus = VpHal_RenderWithAvsForMultiStreams(m_renderer, pcRenderParams);
+diff --git a/media_driver/agnostic/common/vp/hal/vphal_renderer.h b/media_driver/agnostic/common/vp/hal/vphal_renderer.h
+index c7931558..193b7c5f 100644
+--- a/media_driver/agnostic/common/vp/hal/vphal_renderer.h
++++ b/media_driver/agnostic/common/vp/hal/vphal_renderer.h
+@@ -302,6 +302,21 @@ public:
+     //!
+     virtual MOS_STATUS UpdateRenderGpuContext(MOS_GPU_CONTEXT renderGpuContext);
+ 
++    //!
++    //! \brief    Explicitly initialize the maxSrcRect member
++    //! \details  The maxSrcRect member keeps track of the maximum rectangle
++    //!           among a set of source surfaces.  There is a need to
++    //!           explicitly re-initialize this member in VphalState::Render
++    //!           prior to calling the main render function.  This is so that
++    //!           the maxSrcRect value for the last set of surfaces does not
++    //!           get re-used for the current set of surfaces.
++    //! \return   void
++    //!
++    void InitMaxSrcRect()
++    {
++        maxSrcRect = {0, 0, 0, 0};
++    }
++
+ protected:
+     //!
+     //! \brief    Prepare input surface list for top level render processing
+-- 
+2.26.2
+
diff --git a/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1-r3.ebuild b/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1-r4.ebuild
similarity index 100%
rename from x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1-r3.ebuild
rename to x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1-r4.ebuild
diff --git a/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1.ebuild b/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1.ebuild
index 00a35f2..fe61c7c 100644
--- a/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1.ebuild
+++ b/x11-libs/libva-intel-media-driver/libva-intel-media-driver-20.1.1.ebuild
@@ -24,6 +24,7 @@
 PATCHES=(
 	"${FILESDIR}"/0001-Encoder-VP8-GEN9-GEN10-GEN11-Ensure-forced_lf_adjust.patch
 	"${FILESDIR}"/0002-Disable-IPC-usage.patch
+	"${FILESDIR}"/0003-VP-Explicitly-initialize-maxSrcRect-of-VphalRenderer.patch
 )
 
 src_configure() {