From 1313ca08f7156898acf09e893e3f0e20d2d85424 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 24 Oct 2018 18:38:57 +0000 Subject: Make CPDF_PathObject::m_bStroke private. Remove some setters on newly constructed objects, since |m_bStroke| is already initialized to false. Change-Id: I8d04efec997226fb86091566eea96604f18680aa Reviewed-on: https://pdfium-review.googlesource.com/c/44511 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 6 +++--- core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp | 6 ++---- core/fpdfapi/page/cpdf_pathobject.h | 5 ++++- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 5 ++--- fpdfsdk/fpdf_editpath.cpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 1aca4bb8cf..a6a9412de4 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -395,11 +395,11 @@ void CPDF_PageContentGenerator::ProcessPath(std::ostringstream* buf, } } if (pPathObj->m_FillType == 0) - *buf << (pPathObj->m_bStroke ? " S" : " n"); + *buf << (pPathObj->stroke() ? " S" : " n"); else if (pPathObj->m_FillType == FXFILL_WINDING) - *buf << (pPathObj->m_bStroke ? " B" : " f"); + *buf << (pPathObj->stroke() ? " B" : " f"); else if (pPathObj->m_FillType == FXFILL_ALTERNATE) - *buf << (pPathObj->m_bStroke ? " B*" : " f*"); + *buf << (pPathObj->stroke() ? " B*" : " f*"); *buf << " Q\n"; } diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index 249dd8ef0d..75fd0f62ff 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -53,7 +53,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { auto pPathObj = pdfium::MakeUnique(); pPathObj->m_Path.AppendRect(10, 5, 13, 30); pPathObj->m_FillType = FXFILL_ALTERNATE; - pPathObj->m_bStroke = true; + pPathObj->set_stroke(true); auto pTestPage = pdfium::MakeRetain(nullptr, nullptr, false); CPDF_PageContentGenerator generator(pTestPage.Get()); @@ -68,7 +68,6 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { false); pPathObj->m_Path.AppendPoint(CFX_PointF(0, 3.78f), FXPT_TYPE::LineTo, true); pPathObj->m_FillType = 0; - pPathObj->m_bStroke = false; buf.str(""); TestProcessPath(&generator, &buf, pPathObj.get()); @@ -97,7 +96,6 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { pPathObj->m_Path.AppendPoint(CFX_PointF(12, 13.64f), FXPT_TYPE::BezierTo, true); pPathObj->m_FillType = FXFILL_WINDING; - pPathObj->m_bStroke = false; auto pTestPage = pdfium::MakeRetain(nullptr, nullptr, false); CPDF_PageContentGenerator generator(pTestPage.Get()); @@ -116,7 +114,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { pPathObj->m_Path.AppendPoint(CFX_PointF(3, 4), FXPT_TYPE::LineTo, false); pPathObj->m_Path.AppendPoint(CFX_PointF(5, 6), FXPT_TYPE::LineTo, true); pPathObj->m_FillType = FXFILL_WINDING; - pPathObj->m_bStroke = true; + pPathObj->set_stroke(true); static const std::vector rgb = {0.5f, 0.7f, 0.35f}; CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h index dd4cd55a79..9067147410 100644 --- a/core/fpdfapi/page/cpdf_pathobject.h +++ b/core/fpdfapi/page/cpdf_pathobject.h @@ -27,14 +27,17 @@ class CPDF_PathObject final : public CPDF_PageObject { void CalcBoundingBox(); + bool stroke() const { return m_bStroke; } + void set_stroke(bool stroke) { m_bStroke = stroke; } + const CFX_Matrix& matrix() const { return m_Matrix; } void set_matrix(const CFX_Matrix& matrix) { m_Matrix = matrix; } CPDF_Path m_Path; int m_FillType = 0; - bool m_bStroke = false; private: + bool m_bStroke = false; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 03e87ce37d..fb7459d92e 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -1475,9 +1475,9 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { if (bStroke || FillType) { auto pPathObj = pdfium::MakeUnique(GetCurrentStreamIndex()); - pPathObj->m_bStroke = bStroke; pPathObj->m_FillType = FillType; pPathObj->m_Path = Path; + pPathObj->set_stroke(bStroke); pPathObj->set_matrix(matrix); SetGraphicStates(pPathObj.get(), true, false, true); pPathObj->CalcBoundingBox(); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 6b17e09642..e6623b4166 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1244,7 +1244,7 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, const CFX_Matrix& mtObj2Device) { int FillType = pPathObj->m_FillType; - bool bStroke = pPathObj->m_bStroke; + bool bStroke = pPathObj->stroke(); ProcessPathPattern(pPathObj, mtObj2Device, &FillType, &bStroke); if (FillType == 0 && !bStroke) return true; @@ -1968,7 +1968,6 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, CPDF_PathObject path; std::vector> pCopy; pCopy.push_back(std::unique_ptr(textobj->Clone())); - path.m_bStroke = false; path.m_FillType = FXFILL_WINDING; path.m_ClipPath.AppendTexts(&pCopy); path.m_ColorState = textobj->m_ColorState; @@ -2007,8 +2006,8 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_Origin.x, charpos.m_Origin.y)); path.m_Path.Append(pPath, &matrix); - path.m_bStroke = bStroke; path.m_FillType = bFill ? FXFILL_WINDING : 0; + path.set_stroke(bStroke); path.set_matrix(*pTextMatrix); path.CalcBoundingBox(); ProcessPath(&path, mtObj2Device); diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp index c412eef2d0..81bdcb6e21 100644 --- a/fpdfsdk/fpdf_editpath.cpp +++ b/fpdfsdk/fpdf_editpath.cpp @@ -215,7 +215,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, pPathObj->m_FillType = FXFILL_WINDING; else pPathObj->m_FillType = 0; - pPathObj->m_bStroke = stroke != 0; + pPathObj->set_stroke(!!stroke); pPathObj->SetDirty(true); return true; } @@ -234,7 +234,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, else *fillmode = FPDF_FILLMODE_NONE; - *stroke = pPathObj->m_bStroke; + *stroke = pPathObj->stroke(); return true; } -- cgit v1.2.3