Replace bool in CPDF_StreamContentParser::AddPathObject() with enum.
Make it more obvious what the parameter means.
Change-Id: I70e803bab059de7ec1c260eb25132b7521442a0b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81994
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index ef2c28b..8100e71 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -552,20 +552,20 @@
void CPDF_StreamContentParser::Handle_CloseFillStrokePath() {
Handle_ClosePath();
- AddPathObject(CFX_FillRenderOptions::FillType::kWinding, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kWinding, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_FillStrokePath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kWinding, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kWinding, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() {
AddPathPointAndClose(m_PathStart, CFX_Path::Point::Type::kLine);
- AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_EOFillStrokePath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
@@ -862,15 +862,15 @@
}
void CPDF_StreamContentParser::Handle_FillPath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kWinding, false);
+ AddPathObject(CFX_FillRenderOptions::FillType::kWinding, RenderType::kFill);
}
void CPDF_StreamContentParser::Handle_FillPathOld() {
- AddPathObject(CFX_FillRenderOptions::FillType::kWinding, false);
+ AddPathObject(CFX_FillRenderOptions::FillType::kWinding, RenderType::kFill);
}
void CPDF_StreamContentParser::Handle_EOFillPath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, false);
+ AddPathObject(CFX_FillRenderOptions::FillType::kEvenOdd, RenderType::kFill);
}
void CPDF_StreamContentParser::Handle_SetGray_Fill() {
@@ -962,7 +962,7 @@
void CPDF_StreamContentParser::Handle_MarkPlace() {}
void CPDF_StreamContentParser::Handle_EndPath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, false);
+ AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, RenderType::kFill);
}
void CPDF_StreamContentParser::Handle_SaveGraphState() {
@@ -1017,11 +1017,11 @@
void CPDF_StreamContentParser::Handle_CloseStrokePath() {
Handle_ClosePath();
- AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_StrokePath() {
- AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, true);
+ AddPathObject(CFX_FillRenderOptions::FillType::kNoFill, RenderType::kStroke);
}
void CPDF_StreamContentParser::Handle_SetColor_Fill() {
@@ -1451,7 +1451,7 @@
void CPDF_StreamContentParser::AddPathObject(
CFX_FillRenderOptions::FillType fill_type,
- bool bStroke) {
+ RenderType render_type) {
std::vector<CFX_Path::Point> path_points;
path_points.swap(m_PathPoints);
CFX_FillRenderOptions::FillType path_clip_type = m_PathClipType;
@@ -1482,6 +1482,7 @@
}
CFX_Matrix matrix = m_pCurStates->m_CTM * m_mtContentToUser;
+ bool bStroke = render_type == RenderType::kStroke;
if (bStroke || fill_type != CFX_FillRenderOptions::FillType::kNoFill) {
auto pPathObj = std::make_unique<CPDF_PathObject>(GetCurrentStreamIndex());
pPathObj->set_stroke(bStroke);
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 977fedc..a23f6df 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -68,6 +68,8 @@
static ByteStringView FindValueAbbreviationForTesting(ByteStringView abbr);
private:
+ enum class RenderType : bool { kFill = false, kStroke = true };
+
struct ContentParam {
enum Type { OBJECT = 0, NUMBER, NAME };
@@ -113,7 +115,8 @@
void AddPathPointAndClose(const CFX_PointF& point,
CFX_Path::Point::Type type);
void AddPathRect(float x, float y, float w, float h);
- void AddPathObject(CFX_FillRenderOptions::FillType fill_type, bool bStroke);
+ void AddPathObject(CFX_FillRenderOptions::FillType fill_type,
+ RenderType render_type);
CPDF_ImageObject* AddImage(RetainPtr<CPDF_Stream> pStream);
CPDF_ImageObject* AddImage(uint32_t streamObjNum);
CPDF_ImageObject* AddImage(const RetainPtr<CPDF_Image>& pImage);