summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_edit_unittest.cpp27
-rw-r--r--fpdfsdk/fpdf_editpage.cpp6
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c1
-rw-r--r--public/fpdf_edit.h10
4 files changed, 44 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_unittest.cpp b/fpdfsdk/fpdf_edit_unittest.cpp
index 7171f306dc..499a65596f 100644
--- a/fpdfsdk/fpdf_edit_unittest.cpp
+++ b/fpdfsdk/fpdf_edit_unittest.cpp
@@ -39,3 +39,30 @@ TEST_F(PDFEditTest, LineJoin) {
FPDFPageObj_Destroy(path);
}
+
+TEST_F(PDFEditTest, LineCap) {
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, -1));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, FPDF_LINECAP_BUTT));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, FPDF_LINECAP_ROUND));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, FPDF_LINECAP_PROJECTING_SQUARE));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, 3));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(nullptr, 1000));
+
+ FPDF_PAGEOBJECT path = FPDFPageObj_CreateNewPath(0, 0);
+ EXPECT_EQ(FPDF_LINECAP_BUTT, FPDFPageObj_GetLineCap(path));
+
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(path, -1));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(path, 3));
+ EXPECT_FALSE(FPDFPageObj_SetLineCap(path, 1000));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineCap(path, FPDF_LINECAP_PROJECTING_SQUARE));
+ EXPECT_EQ(FPDF_LINECAP_PROJECTING_SQUARE, FPDFPageObj_GetLineCap(path));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineCap(path, FPDF_LINECAP_ROUND));
+ EXPECT_EQ(FPDF_LINECAP_ROUND, FPDFPageObj_GetLineCap(path));
+
+ EXPECT_TRUE(FPDFPageObj_SetLineCap(path, FPDF_LINECAP_BUTT));
+ EXPECT_EQ(FPDF_LINECAP_BUTT, FPDFPageObj_GetLineCap(path));
+
+ FPDFPageObj_Destroy(path);
+}
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 27767465b3..9026c72a4e 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -818,6 +818,12 @@ FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join) {
return true;
}
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFPageObj_GetLineCap(FPDF_PAGEOBJECT page_object) {
+ auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
+ return pPageObj ? pPageObj->m_GraphState.GetLineCap() : -1;
+}
+
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
auto* pPageObj = CPDFPageObjectFromFPDFPageObject(page_object);
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index eb66e14c37..f1a509b3fc 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -157,6 +157,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPageObj_Destroy);
CHK(FPDFPageObj_GetBounds);
CHK(FPDFPageObj_GetFillColor);
+ CHK(FPDFPageObj_GetLineCap);
CHK(FPDFPageObj_GetLineJoin);
CHK(FPDFPageObj_GetMark);
CHK(FPDFPageObj_GetStrokeColor);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 4babd7ea3a..42c654c3de 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -868,6 +868,16 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object,
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join);
+// Get the line cap of |page_object|.
+//
+// page_object - handle to a page object.
+//
+// Returns the line cap, or -1 on failure.
+// Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND,
+// FPDF_LINECAP_PROJECTING_SQUARE
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFPageObj_GetLineCap(FPDF_PAGEOBJECT page_object);
+
// DEPRECATED as of May 2018. This API will be removed in the future. Please
// use FPDFPageObj_SetLineCap instead.
//