Remove usage of FXFILL_WINDING and FXFILL_ALTERNATE in CPDF_ClipPath.
To migrate from using integers (0, FXFILL_WINDING and FXFILL_ALTERNATE)
as fill types to using CFX_FillRenderOptions::FillType, this CL makes
the following changes:
1. For CPDF_ClipPath::AppendPath(), change the type of paramter |type|
from uint8_t to CFX_FillRenderOptions::FillType.
2. Change CPDF_ClipPath::GetClipType()'s return value type to
CFX_FillRenderOptions::FillType.
Bug: pdfium:1531
Change-Id: Iaf00e4c8f358b5495d3bbb0a867a294961444160
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71512
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp
index 53b602d..03699dd 100644
--- a/core/fpdfapi/page/cpdf_clippath.cpp
+++ b/core/fpdfapi/page/cpdf_clippath.cpp
@@ -26,7 +26,7 @@
return m_Ref.GetObject()->m_PathAndTypeList[i].first;
}
-uint8_t CPDF_ClipPath::GetClipType(size_t i) const {
+CFX_FillRenderOptions::FillType CPDF_ClipPath::GetClipType(size_t i) const {
return m_Ref.GetObject()->m_PathAndTypeList[i].second;
}
@@ -74,7 +74,9 @@
return rect;
}
-void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
+void CPDF_ClipPath::AppendPath(CPDF_Path path,
+ CFX_FillRenderOptions::FillType type,
+ bool bAutoMerge) {
PathData* pData = m_Ref.GetPrivateCopy();
if (!pData->m_PathAndTypeList.empty() && bAutoMerge) {
const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first;
diff --git a/core/fpdfapi/page/cpdf_clippath.h b/core/fpdfapi/page/cpdf_clippath.h
index 3f81a50..c18c07f 100644
--- a/core/fpdfapi/page/cpdf_clippath.h
+++ b/core/fpdfapi/page/cpdf_clippath.h
@@ -14,6 +14,7 @@
#include "core/fpdfapi/page/cpdf_path.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/shared_copy_on_write.h"
+#include "core/fxge/cfx_fillrenderoptions.h"
class CPDF_TextObject;
@@ -35,11 +36,13 @@
size_t GetPathCount() const;
CPDF_Path GetPath(size_t i) const;
- uint8_t GetClipType(size_t i) const;
+ CFX_FillRenderOptions::FillType GetClipType(size_t i) const;
size_t GetTextCount() const;
CPDF_TextObject* GetText(size_t i) const;
CFX_FloatRect GetClipBox() const;
- void AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge);
+ void AppendPath(CPDF_Path path,
+ CFX_FillRenderOptions::FillType type,
+ bool bAutoMerge);
void AppendTexts(std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts);
void CopyClipPath(const CPDF_ClipPath& that);
void Transform(const CFX_Matrix& matrix);
@@ -51,7 +54,8 @@
RetainPtr<PathData> Clone() const;
- using PathAndTypeData = std::pair<CPDF_Path, uint8_t>;
+ using PathAndTypeData =
+ std::pair<CPDF_Path, CFX_FillRenderOptions::FillType>;
std::vector<PathAndTypeData> m_PathAndTypeList;
std::vector<std::unique_ptr<CPDF_TextObject>> m_TextList;
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 439c9a3..b8f2fb9 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -19,7 +19,7 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/pauseindicator_iface.h"
-#include "core/fxge/render_defines.h"
+#include "core/fxge/cfx_fillrenderoptions.h"
CPDF_ContentParser::CPDF_ContentParser(CPDF_Page* pPage)
: m_CurrentStage(Stage::kGetContent), m_pObjectHolder(pPage) {
@@ -86,8 +86,8 @@
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath.HasRef()) {
- m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
- true);
+ m_pParser->GetCurStates()->m_ClipPath.AppendPath(
+ ClipPath, CFX_FillRenderOptions::FillType::kWinding, true);
}
if (pForm->GetTransparency().IsGroup()) {
CPDF_GeneralState* pState = &m_pParser->GetCurStates()->m_GeneralState;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index c7c9d32..51f590c 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -36,7 +36,6 @@
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_graphstatedata.h"
-#include "core/fxge/render_defines.h"
#include "third_party/base/logging.h"
#include "third_party/base/span.h"
#include "third_party/base/stl_util.h"
@@ -1385,11 +1384,11 @@
}
void CPDF_StreamContentParser::Handle_Clip() {
- m_PathClipType = FXFILL_WINDING;
+ m_PathClipType = CFX_FillRenderOptions::FillType::kWinding;
}
void CPDF_StreamContentParser::Handle_EOClip() {
- m_PathClipType = FXFILL_ALTERNATE;
+ m_PathClipType = CFX_FillRenderOptions::FillType::kEvenOdd;
}
void CPDF_StreamContentParser::Handle_CurveTo_13() {
@@ -1443,17 +1442,18 @@
void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
std::vector<FX_PATHPOINT> path_points;
path_points.swap(m_PathPoints);
- uint8_t path_clip_type = m_PathClipType;
- m_PathClipType = 0;
+ CFX_FillRenderOptions::FillType path_clip_type = m_PathClipType;
+ m_PathClipType = CFX_FillRenderOptions::FillType::kNoFill;
if (path_points.empty())
return;
if (path_points.size() == 1) {
- if (path_clip_type) {
+ if (path_clip_type != CFX_FillRenderOptions::FillType::kNoFill) {
CPDF_Path path;
path.AppendRect(0, 0, 0, 0);
- m_pCurStates->m_ClipPath.AppendPath(path, FXFILL_WINDING, true);
+ m_pCurStates->m_ClipPath.AppendPath(
+ path, CFX_FillRenderOptions::FillType::kWinding, true);
}
return;
}
@@ -1480,7 +1480,7 @@
pPathObj->CalcBoundingBox();
m_pObjectHolder->AppendPageObject(std::move(pPathObj));
}
- if (path_clip_type) {
+ if (path_clip_type != CFX_FillRenderOptions::FillType::kNoFill) {
if (!matrix.IsIdentity())
path.Transform(matrix);
m_pCurStates->m_ClipPath.AppendPath(path, path_clip_type, true);
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index f9b4da2..89fd2f8 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -17,6 +17,7 @@
#include "core/fxcrt/fx_number.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxge/cfx_fillrenderoptions.h"
#include "core/fxge/cfx_pathdata.h"
class CPDF_AllStates;
@@ -222,7 +223,8 @@
float m_PathStartY = 0.0f;
float m_PathCurrentX = 0.0f;
float m_PathCurrentY = 0.0f;
- uint8_t m_PathClipType = 0;
+ CFX_FillRenderOptions::FillType m_PathClipType =
+ CFX_FillRenderOptions::FillType::kNoFill;
ByteString m_LastImageName;
RetainPtr<CPDF_Image> m_pLastImage;
bool m_bColored = false;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 35685b4..f8c6130 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -521,7 +521,7 @@
} else {
m_pDevice->SetClip_PathFill(
pPathData, &mtObj2Device,
- CFX_FillRenderOptions(GetFillType(ClipPath.GetClipType(i))));
+ CFX_FillRenderOptions(ClipPath.GetClipType(i)));
}
}
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 8e18086..0d3132f 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -21,8 +21,8 @@
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "core/fxge/cfx_fillrenderoptions.h"
#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/render_defines.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "third_party/base/span.h"
#include "third_party/base/stl_util.h"
@@ -367,7 +367,8 @@
Path.AppendRect(left, bottom, right, top);
auto pNewClipPath = std::make_unique<CPDF_ClipPath>();
- pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, false);
+ pNewClipPath->AppendPath(Path, CFX_FillRenderOptions::FillType::kEvenOdd,
+ false);
// Caller takes ownership.
return FPDFClipPathFromCPDFClipPath(pNewClipPath.release());
@@ -398,10 +399,12 @@
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
- if (pClipPath->GetClipType(i) == FXFILL_WINDING)
+ if (pClipPath->GetClipType(i) ==
+ CFX_FillRenderOptions::FillType::kWinding) {
strClip << "W n\n";
- else
+ } else {
strClip << "W* n\n";
+ }
}
}
CPDF_Document* pDoc = pPage->GetDocument();