Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2018)

Unified Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 2232553002: Generate default AP stream for ink annotation. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Generate default AP stream for ink annotation. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpvt_generateap.cpp
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 5cf96f211f27aaf2d97a93417a13ba82669e3317..f15869b13004d4021c5f15f9b30ac76a566abf83 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
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698