summaryrefslogtreecommitdiff
path: root/external/pdfium/0006-Add-FPDFPath_GetDrawMode-API.patch.1
blob: b9c9326c5f07a706518986602c343c7c8fa9d841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
From 3285732ee73e97feb3fed4da6abc41b1c705ed30 Mon Sep 17 00:00:00 2001
Date: Wed, 30 May 2018 13:30:10 +0000
Subject: [PATCH] Add FPDFPath_GetDrawMode() API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It was already possible to set the draw mode of a path object, this is
the other direction.

Change-Id: Id0ee98dd8dfe433edd0e4715fc009ad4d1625981
Reviewed-on: https://pdfium-review.googlesource.com/33010
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
---
 fpdfsdk/fpdf_edit_embeddertest.cpp |  7 +++++++
 fpdfsdk/fpdf_editpath.cpp          | 18 ++++++++++++++++++
 public/fpdf_edit.h                 | 16 ++++++++++++++--
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp
index aca2bebf8..558a8e3de 100644
--- a/fpdfsdk/fpdf_editpath.cpp
+++ b/fpdfsdk/fpdf_editpath.cpp
@@ -235,6 +235,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) {
   if (!path)
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 49018df05..2faa9ecba 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
 
@@ -899,8 +900,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
@@ -908,6 +908,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.
-- 
2.16.4