[Skia] Flush cached drawings before bitmap composition.

Bitmap composition is required when an ExtGState exists in the stream,
which contains extra information such as blend modes, transparency,
etc. The ExtGState information should be strictly used during
CompositeDIBitmap() call without interfering with the drawing commands
which have already been cached.

This CL makes sure all cached drawing commands are flushed before
the CompositeDIBitmap() call for both Skia and SkiaPaths. So that
the incoming ExtGState info won't cause unwanted interference to the
existing cached drawing commands in SkiaState.

Improvements from this change:
[1] Fixes pixel and corpus tests: 3bigpreview.pdf, bug_883026.pdf,
    bug_1847.in.
[2] Fixes the embedder test: FPDFProgressiveRenderEmbedderTest.
    RenderHighlightWithColorSchemeAndConvertFillToStroke
[3] Improves the Skia rendering result for 1_10_watermark.pdf
    (crbug.com/pdfium/1796), which now no longer have a missing
    character. But this test is still rendered in the wrong color.

Bug: pdfium:1847,pdfium:1806,pdfium:1796,pdfium:1787,pdfium:1500
Change-Id: If98468ddc002828f00508ac793e5e640b98dbc5a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95252
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
diff --git a/DEPS b/DEPS
index 011f17f..a2b8e9d 100644
--- a/DEPS
+++ b/DEPS
@@ -119,7 +119,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling pdfium_tests
   # and whatever else without interference from each other.
-  'pdfium_tests_revision': 'f8618ab41dab1dd983f4c805f5b191b8ca36fd54',
+  'pdfium_tests_revision': '8f2345db3e4c6a9b3203ea1de5817aefcd1ba58e',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling skia
   # and whatever else without interference from each other.
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 87cb293..86c7244 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -698,10 +698,12 @@
   bitmap_render.SetFormResource(pFormResource);
   bitmap_render.Initialize(nullptr, nullptr);
   bitmap_render.ProcessObjectNoClip(pPageObj, new_matrix);
-#if defined(_SKIA_SUPPORT_PATHS_)
+#if defined(_SKIA_SUPPORT_PATHS_) || defined(_SKIA_SUPPORT_)
   bitmap_device.Flush(true);
+#if defined(_SKIA_SUPPORT_PATHS_)
   bitmap->UnPreMultiply();
-#endif
+#endif  // defined(_SKIA_SUPPORT_PATHS_)
+#endif  // defined(_SKIA_SUPPORT_PATHS_) || defined(_SKIA_SUPPORT_)
   m_bStopped = bitmap_render.m_bStopped;
   if (pSMaskDict) {
     CFX_Matrix smask_matrix =
diff --git a/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp b/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
index 12ccc43..ca98f85 100644
--- a/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
+++ b/core/fpdfapi/render/fpdf_progressive_render_embeddertest.cpp
@@ -401,16 +401,8 @@
                                  kContentWithHighlightFillChecksum);
 }
 
-// TODO(crbug.com/pdfium/1847): Fix this test and enable.
-#if defined(_SKIA_SUPPORT_)
-#define MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke \
-  DISABLED_RenderHighlightWithColorSchemeAndConvertFillToStroke
-#else
-#define MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke \
-  RenderHighlightWithColorSchemeAndConvertFillToStroke
-#endif
 TEST_F(FPDFProgressiveRenderEmbedderTest,
-       MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke) {
+       RenderHighlightWithColorSchemeAndConvertFillToStroke) {
   // Test rendering of highlight with forced color and converting fill to
   // stroke. The highlight should be rendered as a stroke of the rect.
   //
@@ -418,7 +410,10 @@
   // path since highlights have Multiply blend mode, while the other path has
   // Normal blend mode.
 
-#if defined(_SKIA_SUPPORT_PATHS_)
+#if defined(_SKIA_SUPPORT_)
+  static constexpr char kMD5ContentWithHighlight[] =
+      "772246195d18f75d40a22bee913c098f";
+#elif defined(_SKIA_SUPPORT_PATHS_)
   static constexpr char kMD5ContentWithHighlight[] =
       "eff6eef2409ef5fbf4612bf6af42e0a0";
 #else
@@ -429,7 +424,7 @@
   static constexpr char kMD5ContentWithHighlight[] =
       "3dd8c02f5c06bac85e0d2c8bf37d1dc4";
 #endif  // BUILDFLAG(IS_APPLE)
-#endif  // defined(_SKIA_SUPPORT_PATHS_)
+#endif
 
   ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf"));
 
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 0d7ecb5..3cd74d4 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -52,9 +52,6 @@
 3_interpolate_image.pdf mac * * *
 3bigpreview.pdf mac * * *
 
-# TODO(pdfium:1787): Remove after associated bug is fixed
-3bigpreview.pdf * * * skia
-
 4_35.pdf mac * * *
 4_39.pdf mac * * *
 5.1.pdf mac * * *
@@ -130,9 +127,6 @@
 bug_0_width_line.pdf mac * * *
 bug_440132.pdf mac * * *
 
-# TODO(pdfium:1806): Remove after associated bug is fixed
-bug_883026.pdf * * * skia
-
 bug_white_space.pdf mac * * *
 calcorderindex_test.pdf * * * *
 calculate_average.pdf mac * * *
@@ -431,9 +425,6 @@
 # TODO(pdfium:1723): Remove after associated bug is fixed
 bug_1723.in * * * *
 
-# TODO(pdfium:1847): Remove after associated bug is fixed
-bug_1847.in * * * skia
-
 # TODO(chromium:237527): Remove after associated bug is fixed
 bug_237527_1.in * * * *