[Skia] Fix issue that a dot annotation is not rendered
An ink dot annotation is considered as an unclosed path with 2
identical points. For Skia/SkiaPaths, SkCanvas::drawPath() won't draw
such paths even if the paint has a non-zero width.
This CL adds a check whether such a path represents a point and use
SkCanvas::drawPoint() API to render it.
Bug: pdfium:1803
Change-Id: I1e554a32781288096d7c5f25e2249f1b68ad0a3b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100030
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
diff --git a/DEPS b/DEPS
index 2b404fe..b9ffe4b 100644
--- a/DEPS
+++ b/DEPS
@@ -130,7 +130,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': '05eb5c64b289383a16ef67c95b97ac3b2a627949',
+ 'pdfium_tests_revision': '62ba3e144cf4c387e0fe043a2e9dc2ebfb4778f3',
# 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 f5359d8..a13e0cc 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -366,6 +366,20 @@
fill == SkPathFillType::kInverseEvenOdd;
}
+bool IsPathAPoint(const SkPath& path) {
+ if (path.isEmpty())
+ return false;
+
+ if (path.countPoints() == 1)
+ return true;
+
+ for (int i = 0; i < path.countPoints() - 1; ++i) {
+ if (path.getPoint(i) != path.getPoint(i + 1))
+ return false;
+ }
+ return true;
+}
+
SkPath BuildPath(const CFX_Path& path) {
SkPath sk_path;
pdfium::span<const CFX_Path::Point> points = path.GetPoints();
@@ -920,8 +934,13 @@
#if defined(_SKIA_SUPPORT_PATHS_)
m_pDriver->PreMultiply();
#endif
- DebugShowSkiaDrawPath(m_pDriver.Get(), skCanvas, skPaint, m_skPath);
- skCanvas->drawPath(m_skPath, skPaint);
+ if (!m_skPath.isLastContourClosed() && IsPathAPoint(m_skPath)) {
+ DCHECK_GE(m_skPath.countPoints(), 1);
+ skCanvas->drawPoint(m_skPath.getPoint(0), skPaint);
+ } else {
+ DebugShowSkiaDrawPath(m_pDriver.Get(), skCanvas, skPaint, m_skPath);
+ skCanvas->drawPath(m_skPath, skPaint);
+ }
}
m_drawIndex = INT_MAX;
m_type = Accumulator::kNone;
@@ -2189,8 +2208,13 @@
#if defined(_SKIA_SUPPORT_PATHS_)
m_pBitmap->PreMultiply();
#endif
- DebugShowSkiaDrawPath(this, m_pCanvas, skPaint, skPath);
- m_pCanvas->drawPath(skPath, skPaint);
+ if (!skPath.isLastContourClosed() && IsPathAPoint(skPath)) {
+ DCHECK_GE(skPath.countPoints(), 1);
+ m_pCanvas->drawPoint(skPath.getPoint(0), skPaint);
+ } else {
+ DebugShowSkiaDrawPath(this, m_pCanvas, skPaint, skPath);
+ m_pCanvas->drawPath(skPath, skPaint);
+ }
}
return true;
}
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index c9789eb..762eec9 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -140,9 +140,6 @@
annotation_highlight_long_content.pdf mac * * *
annotation_highlight_no_author.pdf mac * * *
-# TODO(pdfium:1803): Remove after associated bug is fixed
-annotation_ink_dot.pdf * * * skia,skiapaths
-
# TODO(pdfium:1871): Remove after associated bug is fixed
annotation_square_dash.pdf * * * skia,skiapaths
diff --git a/testing/resources/pixel/scrollable_widgets1_expected_skia.pdf.0.png b/testing/resources/pixel/scrollable_widgets1_expected_skia.pdf.0.png
index cd2fe05..d4c1f9d 100644
--- a/testing/resources/pixel/scrollable_widgets1_expected_skia.pdf.0.png
+++ b/testing/resources/pixel/scrollable_widgets1_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/scrollable_widgets1_expected_skiapaths.pdf.0.png b/testing/resources/pixel/scrollable_widgets1_expected_skiapaths.pdf.0.png
index 74860d9..7b142e3 100644
--- a/testing/resources/pixel/scrollable_widgets1_expected_skiapaths.pdf.0.png
+++ b/testing/resources/pixel/scrollable_widgets1_expected_skiapaths.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/scrollable_widgets2_expected_skia.pdf.0.png b/testing/resources/pixel/scrollable_widgets2_expected_skia.pdf.0.png
index eb7d992..dd9f6a1 100644
--- a/testing/resources/pixel/scrollable_widgets2_expected_skia.pdf.0.png
+++ b/testing/resources/pixel/scrollable_widgets2_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/scrollable_widgets2_expected_skiapaths.pdf.0.png b/testing/resources/pixel/scrollable_widgets2_expected_skiapaths.pdf.0.png
index 28e51ba..32c7bdc 100644
--- a/testing/resources/pixel/scrollable_widgets2_expected_skiapaths.pdf.0.png
+++ b/testing/resources/pixel/scrollable_widgets2_expected_skiapaths.pdf.0.png
Binary files differ