diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-24 18:44:55 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-24 18:44:55 +0000 |
commit | 877e1e212794c6a43f6661198ac1b369fab975be (patch) | |
tree | 0aea008c19f8633dc19e91138667d49576f7523e | |
parent | 1313ca08f7156898acf09e893e3f0e20d2d85424 (diff) | |
download | pdfium-877e1e212794c6a43f6661198ac1b369fab975be.tar.xz |
Make CPDF_PathObject::m_FillType private.
Change-Id: I69436316dd4a12ebdc3f09e7db3bf25c7495a4ce
Reviewed-on: https://pdfium-review.googlesource.com/c/44512
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp | 7 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pathobject.h | 5 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/fpdf_editpath.cpp | 10 |
6 files changed, 22 insertions, 19 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index a6a9412de4..cfc8c5159a 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -394,11 +394,11 @@ void CPDF_PageContentGenerator::ProcessPath(std::ostringstream* buf, *buf << " h"; } } - if (pPathObj->m_FillType == 0) + if (pPathObj->filltype() == 0) *buf << (pPathObj->stroke() ? " S" : " n"); - else if (pPathObj->m_FillType == FXFILL_WINDING) + else if (pPathObj->filltype() == FXFILL_WINDING) *buf << (pPathObj->stroke() ? " B" : " f"); - else if (pPathObj->m_FillType == FXFILL_ALTERNATE) + else if (pPathObj->filltype() == FXFILL_ALTERNATE) *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 75fd0f62ff..f4555287d7 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -52,7 +52,7 @@ class CPDF_PageContentGeneratorTest : public testing::Test { TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(); pPathObj->m_Path.AppendRect(10, 5, 13, 30); - pPathObj->m_FillType = FXFILL_ALTERNATE; + pPathObj->set_filltype(FXFILL_ALTERNATE); pPathObj->set_stroke(true); auto pTestPage = pdfium::MakeRetain<CPDF_Page>(nullptr, nullptr, false); @@ -67,7 +67,6 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 3.78f), FXPT_TYPE::LineTo, false); pPathObj->m_Path.AppendPoint(CFX_PointF(0, 3.78f), FXPT_TYPE::LineTo, true); - pPathObj->m_FillType = 0; buf.str(""); TestProcessPath(&generator, &buf, pPathObj.get()); @@ -95,7 +94,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { false); pPathObj->m_Path.AppendPoint(CFX_PointF(12, 13.64f), FXPT_TYPE::BezierTo, true); - pPathObj->m_FillType = FXFILL_WINDING; + pPathObj->set_filltype(FXFILL_WINDING); auto pTestPage = pdfium::MakeRetain<CPDF_Page>(nullptr, nullptr, false); CPDF_PageContentGenerator generator(pTestPage.Get()); @@ -113,7 +112,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { pPathObj->m_Path.AppendPoint(CFX_PointF(1, 2), FXPT_TYPE::MoveTo, false); 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->set_filltype(FXFILL_WINDING); pPathObj->set_stroke(true); static const std::vector<float> rgb = {0.5f, 0.7f, 0.35f}; diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h index 9067147410..e6e0d19de8 100644 --- a/core/fpdfapi/page/cpdf_pathobject.h +++ b/core/fpdfapi/page/cpdf_pathobject.h @@ -27,6 +27,9 @@ class CPDF_PathObject final : public CPDF_PageObject { void CalcBoundingBox(); + int filltype() const { return m_FillType; } + void set_filltype(int filltype) { m_FillType = filltype; } + bool stroke() const { return m_bStroke; } void set_stroke(bool stroke) { m_bStroke = stroke; } @@ -34,9 +37,9 @@ class CPDF_PathObject final : public CPDF_PageObject { void set_matrix(const CFX_Matrix& matrix) { m_Matrix = matrix; } CPDF_Path m_Path; - int m_FillType = 0; private: + int m_FillType = 0; 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 fb7459d92e..245a2852bc 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -1475,8 +1475,8 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { if (bStroke || FillType) { auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(GetCurrentStreamIndex()); - pPathObj->m_FillType = FillType; pPathObj->m_Path = Path; + pPathObj->set_filltype(FillType); pPathObj->set_stroke(bStroke); pPathObj->set_matrix(matrix); SetGraphicStates(pPathObj.get(), true, false, true); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index e6623b4166..7bd2d7cd22 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1243,7 +1243,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; + int FillType = pPathObj->filltype(); bool bStroke = pPathObj->stroke(); ProcessPathPattern(pPathObj, mtObj2Device, &FillType, &bStroke); if (FillType == 0 && !bStroke) @@ -1424,7 +1424,7 @@ bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), &path_matrix, graphState.GetObject()); } - int fill_mode = pPathObj->m_FillType; + int fill_mode = pPathObj->filltype(); if (m_Options.HasFlag(RENDER_NOPATHSMOOTH)) { fill_mode |= FXFILL_NOPATHSMOOTH; } @@ -1965,10 +1965,11 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, bool bFill, bool bStroke) { if (!bStroke) { - CPDF_PathObject path; std::vector<std::unique_ptr<CPDF_TextObject>> pCopy; pCopy.push_back(std::unique_ptr<CPDF_TextObject>(textobj->Clone())); - path.m_FillType = FXFILL_WINDING; + + CPDF_PathObject path; + path.set_filltype(FXFILL_WINDING); path.m_ClipPath.AppendTexts(&pCopy); path.m_ColorState = textobj->m_ColorState; path.m_GeneralState = textobj->m_GeneralState; @@ -2006,7 +2007,7 @@ 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_FillType = bFill ? FXFILL_WINDING : 0; + path.set_filltype(bFill ? FXFILL_WINDING : 0); path.set_stroke(bStroke); path.set_matrix(*pTextMatrix); path.CalcBoundingBox(); diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp index 81bdcb6e21..b6926a2492 100644 --- a/fpdfsdk/fpdf_editpath.cpp +++ b/fpdfsdk/fpdf_editpath.cpp @@ -210,11 +210,11 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, return false; if (fillmode == FPDF_FILLMODE_ALTERNATE) - pPathObj->m_FillType = FXFILL_ALTERNATE; + pPathObj->set_filltype(FXFILL_ALTERNATE); else if (fillmode == FPDF_FILLMODE_WINDING) - pPathObj->m_FillType = FXFILL_WINDING; + pPathObj->set_filltype(FXFILL_WINDING); else - pPathObj->m_FillType = 0; + pPathObj->set_filltype(0); pPathObj->set_stroke(!!stroke); pPathObj->SetDirty(true); return true; @@ -227,9 +227,9 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetDrawMode(FPDF_PAGEOBJECT path, if (!pPathObj || !fillmode || !stroke) return false; - if (pPathObj->m_FillType == FXFILL_ALTERNATE) + if (pPathObj->filltype() == FXFILL_ALTERNATE) *fillmode = FPDF_FILLMODE_ALTERNATE; - else if (pPathObj->m_FillType == FXFILL_WINDING) + else if (pPathObj->filltype() == FXFILL_WINDING) *fillmode = FPDF_FILLMODE_WINDING; else *fillmode = FPDF_FILLMODE_NONE; |