[Skia] Remove 8-bit to 8-bit image path
Removes obsolete code path for drawing 8-bit images, as Skia now
supports this operation. This change also introduces minor anti-aliasing
differences due to issues like pdfium:1856.
Fixed: pdfium:1976
Change-Id: I30ea5bc5b1d11aa0207d53e66db860b0e986090c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103871
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
diff --git a/DEPS b/DEPS
index e66ab93..fb20d07 100644
--- a/DEPS
+++ b/DEPS
@@ -140,7 +140,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': '4d6dd6a870949fcca68fc689f12a8d093f55ab74',
+ 'pdfium_tests_revision': '14a56b4fbdda976f1d1686f0c2dcfc1497e4547d',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling resultdb
# and whatever else without interference from each other.
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 2e048c5..c2da0aa 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -45,7 +45,6 @@
#include "core/fxge/text_char_pos.h"
#include "third_party/base/check.h"
#include "third_party/base/check_op.h"
-#include "third_party/base/cxx17_backports.h"
#include "third_party/base/notreached.h"
#include "third_party/base/numerics/safe_conversions.h"
#include "third_party/base/ptr_util.h"
@@ -2180,49 +2179,26 @@
SkPaint paint;
SetBitmapPaint(pSource->IsMaskFormat(), !m_FillOptions.aliased_path,
bitmap_alpha, argb, blend_type, &paint);
- // TODO(caryclark) Once Skia supports 8 bit src to 8 bit dst remove this
- if (m_pBitmap && m_pBitmap->GetBPP() == 8 && pSource->GetBPP() == 8) {
- SkMatrix inv;
- if (!skMatrix.invert(&inv)) {
- return false;
- }
- for (int y = 0; y < m_pBitmap->GetHeight(); ++y) {
- for (int x = 0; x < m_pBitmap->GetWidth(); ++x) {
- SkPoint src = {x + 0.5f, y + 0.5f};
- inv.mapPoints(&src, 1);
- // SkMatrix::mapPoints() can sometimes output NaN values or values
- // outside the boundary of the `skBitmap`. Therefore clamping these
- // values is necessary before getting color information within the
- // `skBitmap`.
- src.fX =
- isnan(src.fX) ? 0.5f : pdfium::clamp(src.fX, 0.5f, width - 0.5f);
- src.fY =
- isnan(src.fY) ? 0.5f : pdfium::clamp(src.fY, 0.5f, height - 0.5f);
- m_pBitmap->SetPixel(x, y, skBitmap.getColor(src.fX, src.fY));
- }
+ bool use_interpolate_bilinear = options.bInterpolateBilinear;
+ if (!use_interpolate_bilinear) {
+ float dest_width = ceilf(matrix.GetXUnit());
+ float dest_height = ceilf(matrix.GetYUnit());
+ if (pdfium::base::IsValueInRangeForNumericType<int>(dest_width) &&
+ pdfium::base::IsValueInRangeForNumericType<int>(dest_height)) {
+ use_interpolate_bilinear = CStretchEngine::UseInterpolateBilinear(
+ options, static_cast<int>(dest_width),
+ static_cast<int>(dest_height), width, height);
}
- } else {
- bool use_interpolate_bilinear = options.bInterpolateBilinear;
- if (!use_interpolate_bilinear) {
- float dest_width = ceilf(matrix.GetXUnit());
- float dest_height = ceilf(matrix.GetYUnit());
- if (pdfium::base::IsValueInRangeForNumericType<int>(dest_width) &&
- pdfium::base::IsValueInRangeForNumericType<int>(dest_height)) {
- use_interpolate_bilinear = CStretchEngine::UseInterpolateBilinear(
- options, static_cast<int>(dest_width),
- static_cast<int>(dest_height), width, height);
- }
- }
- SkSamplingOptions sampling_options;
- if (use_interpolate_bilinear) {
- sampling_options =
- SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
- }
- m_pCanvas->drawImageRect(skBitmap.asImage(),
- SkRect::MakeWH(width, height), sampling_options,
- &paint);
}
+ SkSamplingOptions sampling_options;
+ if (use_interpolate_bilinear) {
+ sampling_options =
+ SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
+ }
+
+ m_pCanvas->drawImageRect(skBitmap.asImage(), SkRect::MakeWH(width, height),
+ sampling_options, &paint);
}
DebugValidate(m_pBitmap, m_pBackdropBitmap);
return true;
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 2cbbd29..09c96bb 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -3926,12 +3926,12 @@
const char* smask_checksum = []() {
if (CFX_DefaultRenderDevice::SkiaIsDefaultRenderer())
- return "5ddf871ab737746b1b8390f0bc4ec52c";
+ return "0653a18f3bf9b4d8413a2aa10bc11c38";
return "5a3ae4a660ce919e29c42ec2258142f1";
}();
const char* no_smask_checksum = []() {
if (CFX_DefaultRenderDevice::SkiaIsDefaultRenderer())
- return "6bb3b5bd93e26f4c2e52db64a1f57686";
+ return "d568afc908d595224d804448d5d3672f";
return "67504e83f5d78214ea00efc19082c5c1";
}();
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index f5bb133..1bf5907 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -267,9 +267,6 @@
# TODO(pdfium:1863): Remove after associated bug is fixed
new_pdfsign1.pdf * * * skia
-# TODO(pdfium:1976): Remove after associated bug is fixed
-new_pdfsign4.pdf * * * skia
-
new_signature1.pdf mac * * *
new_signature2.pdf mac * * *
new_stamp4.pdf mac * * *
@@ -403,9 +400,6 @@
# TODO(pdfium:1973): Remove after associated bug is fixed
bug_1973.in * * * agg,skia
-# TODO(pdfium:1976): Remove after associated bug is fixed
-bug_1976.in * * * skia
-
# TODO(chromium:237527): Remove after associated bug is fixed
bug_237527_1.in * * * *
diff --git a/testing/resources/pixel/bug_1236_expected_skia.pdf.0.png b/testing/resources/pixel/bug_1236_expected_skia.pdf.0.png
index abe6b46..248125f 100644
--- a/testing/resources/pixel/bug_1236_expected_skia.pdf.0.png
+++ b/testing/resources/pixel/bug_1236_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/bug_1395648_expected_skia.pdf.0.png b/testing/resources/pixel/bug_1395648_expected_skia.pdf.0.png
index 6af289a..80a944b 100644
--- a/testing/resources/pixel/bug_1395648_expected_skia.pdf.0.png
+++ b/testing/resources/pixel/bug_1395648_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/matte_expected_skia.pdf.0.png b/testing/resources/pixel/matte_expected_skia.pdf.0.png
index 8350349..bdab404 100644
--- a/testing/resources/pixel/matte_expected_skia.pdf.0.png
+++ b/testing/resources/pixel/matte_expected_skia.pdf.0.png
Binary files differ