summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp56
-rw-r--r--core/fpdfdoc/cpvt_generateap.h1
4 files changed, 60 insertions, 1 deletions
diff --git a/DEPS b/DEPS
index 197a6567a2..340ddd8dc2 100644
--- a/DEPS
+++ b/DEPS
@@ -14,7 +14,7 @@ vars = {
'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271',
'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038',
'icu_revision': 'a5f86adbb0a58d04c035a5d1228747b1823cd485',
- 'pdfium_tests_revision': '71d1f2286ceb33bc71cb1aab6824ab6631757d94',
+ 'pdfium_tests_revision': '4119f8ed4e89156e646c3fd235b61718da5e9b45',
'skia_revision': '96206a96f357cd30b60d1b1aa98e4e3a8f9b97f1',
'tools_memory_revision': '427f10475e1a8d72424c29d00bf689122b738e5d',
'trace_event_revision': '54b8455be9505c2cb0cf5c26bb86739c236471aa',
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index ce84df1ee0..bff9131b46 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -25,6 +25,8 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument)
CPVT_GenerateAP::GenerateCircleAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "Highlight")
CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, m_pAnnotDict);
+ else if (m_sSubtype == "Ink")
+ CPVT_GenerateAP::GenerateInkAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "Square")
CPVT_GenerateAP::GenerateSquareAP(m_pDocument, m_pAnnotDict);
else if (m_sSubtype == "Squiggly")
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 5cf96f211f..f15869b130 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -718,6 +718,62 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc,
return true;
}
+bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
+ CPDF_Dictionary* pAnnotDict) {
+ // If AP dictionary exists, we use the appearance defined in the
+ // existing AP dictionary.
+ if (pAnnotDict->KeyExist("AP"))
+ return false;
+
+ FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict);
+ bool bIsStroke = fBorderWidth > 0;
+
+ if (!bIsStroke)
+ return false;
+
+ CPDF_Array* pInkList = pAnnotDict->GetArrayBy("InkList");
+ if (!pInkList || pInkList->IsEmpty())
+ return false;
+
+ CFX_ByteTextBuf sAppStream;
+ CFX_ByteString sExtGSDictName = "GS";
+ sAppStream << "/" << sExtGSDictName << " gs ";
+
+ sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
+ CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
+ PaintOperation::STROKE);
+
+ sAppStream << fBorderWidth << " w ";
+ sAppStream << GetDashPatternString(*pAnnotDict);
+
+ // Set inflated rect as a new rect because paths near the border with large
+ // width should not be clipped to the original rect.
+ CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
+ rect.Inflate(fBorderWidth / 2, fBorderWidth / 2);
+ pAnnotDict->SetAtRect("Rect", rect);
+
+ for (size_t i = 0; i < pInkList->GetCount(); i++) {
+ CPDF_Array* pInkCoordList = pInkList->GetArrayAt(i);
+ if (!pInkCoordList || pInkCoordList->GetCount() < 2)
+ continue;
+
+ sAppStream << pInkCoordList->GetNumberAt(0) << " "
+ << pInkCoordList->GetNumberAt(1) << " m ";
+
+ for (size_t j = 0; j < pInkCoordList->GetCount() - 1; j += 2) {
+ sAppStream << pInkCoordList->GetNumberAt(j) << " "
+ << pInkCoordList->GetNumberAt(j + 1) << " l ";
+ }
+
+ sAppStream << "S\n";
+ }
+
+ CPDF_Dictionary* pExtGStateDict =
+ GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
+ GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict);
+ return true;
+}
+
bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
// If AP dictionary exists, we use the appearance defined in the
diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h
index a81bea276a..e36693901b 100644
--- a/core/fpdfdoc/cpvt_generateap.h
+++ b/core/fpdfdoc/cpvt_generateap.h
@@ -31,6 +31,7 @@ class CPVT_GenerateAP {
CPDF_Dictionary* pAnnotDict);
static bool GenerateHighlightAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
+ static bool GenerateInkAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
static bool GenerateListBoxAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict);
static bool GenerateSquareAP(CPDF_Document* pDoc,