summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-24 17:30:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-24 17:30:11 +0000
commitcd11df62b64655c24d44a65b2a76d723fc214077 (patch)
tree8a8ce4ed1e627c65a7c384c929d52e17975b9930
parent57360839a2eeecc8e32e326994f8853099ccd2fa (diff)
downloadpdfium-cd11df62b64655c24d44a65b2a76d723fc214077.tar.xz
Implement FPDFPageObj_GetLineCap().
Add unit tests for FPDFPageObj_[GS]etLineCap(). BUG=pdfium:1186 Change-Id: I3df907713a8846fd7481300c5caf102293f381ba Reviewed-on: https://pdfium-review.googlesource.com/c/44516 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-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.
//