summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp7
-rw-r--r--fpdfsdk/fpdf_editpath.cpp18
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c1
-rw-r--r--public/fpdf_edit.h16
4 files changed, 40 insertions, 2 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 458ae0022a..f9b165c28d 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -241,6 +241,13 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) {
// Fill rectangle with red and insert to the page
EXPECT_TRUE(FPDFPath_SetFillColor(red_rect, 255, 0, 0, 255));
EXPECT_TRUE(FPDFPath_SetDrawMode(red_rect, FPDF_FILLMODE_ALTERNATE, 0));
+
+ int fillmode = FPDF_FILLMODE_NONE;
+ FPDF_BOOL stroke = true;
+ EXPECT_TRUE(FPDFPath_GetDrawMode(red_rect, &fillmode, &stroke));
+ EXPECT_EQ(FPDF_FILLMODE_ALTERNATE, fillmode);
+ EXPECT_FALSE(stroke);
+
FPDFPage_InsertObject(page, red_rect);
{
ScopedFPDFBitmap page_bitmap = RenderPageWithFlags(page, nullptr, 0);
diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp
index a5873ef67d..7f00b85d7b 100644
--- a/fpdfsdk/fpdf_editpath.cpp
+++ b/fpdfsdk/fpdf_editpath.cpp
@@ -218,6 +218,24 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
return true;
}
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path,
+ int* fillmode,
+ FPDF_BOOL* stroke) {
+ auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
+ if (!pPathObj || !fillmode || !stroke)
+ return false;
+
+ if (pPathObj->m_FillType == FXFILL_ALTERNATE)
+ *fillmode = FPDF_FILLMODE_ALTERNATE;
+ else if (pPathObj->m_FillType == FXFILL_WINDING)
+ *fillmode = FPDF_FILLMODE_WINDING;
+ else
+ *fillmode = FPDF_FILLMODE_NONE;
+
+ *stroke = pPathObj->m_bStroke;
+ return true;
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path,
int line_join) {
auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path);
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 1e746cde33..dd97a6e330 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -181,6 +181,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPath_BezierTo);
CHK(FPDFPath_Close);
CHK(FPDFPath_CountSegments);
+ CHK(FPDFPath_GetDrawMode);
CHK(FPDFPath_GetFillColor);
CHK(FPDFPath_GetPathSegment);
CHK(FPDFPath_GetStrokeColor);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index c950e2fa72..8cb97eed15 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -48,6 +48,7 @@
#define FPDF_SEGMENT_BEZIERTO 1
#define FPDF_SEGMENT_MOVETO 2
+#define FPDF_FILLMODE_NONE 0
#define FPDF_FILLMODE_ALTERNATE 1
#define FPDF_FILLMODE_WINDING 2
@@ -920,8 +921,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path);
// Set the drawing mode of a path.
//
// path - the handle to the path object.
-// fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for
-// winding.
+// fillmode - the filling mode to be set: one of the FPDF_FILLMODE_* flags.
// stroke - a boolean specifying if the path should be stroked or not.
//
// Returns TRUE on success
@@ -929,6 +929,18 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
int fillmode,
FPDF_BOOL stroke);
+// Experimental API.
+// Get the drawing mode of a path.
+//
+// path - the handle to the path object.
+// fillmode - the filling mode of the path: one of the FPDF_FILLMODE_* flags.
+// stroke - a boolean specifying if the path is stroked or not.
+//
+// Returns TRUE on success
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path,
+ int* fillmode,
+ FPDF_BOOL* stroke);
+
// Create a new text object using one of the standard PDF fonts.
//
// document - handle to the document.