From 8a5e15d7b16c1c2a99b013fc4f68597cedab4fcf Mon Sep 17 00:00:00 2001 From: thestig Date: Mon, 21 Nov 2016 14:54:29 -0800 Subject: Make CPDF_ImageObject::m_Matrix private. Review-Url: https://codereview.chromium.org/2514263003 --- core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 8 ++++---- core/fpdfapi/font/cpdf_type3char.cpp | 2 +- core/fpdfapi/page/cpdf_imageobject.h | 4 +++- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 +- core/fpdfapi/render/fpdf_render_image.cpp | 5 ++--- fpdfsdk/fpdfeditimg.cpp | 10 ++++------ 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index cabd2c391c..a65d564141 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -19,7 +19,7 @@ namespace { -CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, CFX_Matrix& matrix) { +CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, const CFX_Matrix& matrix) { ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " << matrix.e << " " << matrix.f; return ar; @@ -84,11 +84,11 @@ CFX_ByteString CPDF_PageContentGenerator::RealizeResource( void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf* buf, CPDF_ImageObject* pImageObj) { - if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || - (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { + if ((pImageObj->matrix().a == 0 && pImageObj->matrix().b == 0) || + (pImageObj->matrix().c == 0 && pImageObj->matrix().d == 0)) { return; } - *buf << "q " << pImageObj->m_Matrix << " cm "; + *buf << "q " << pImageObj->matrix() << " cm "; CPDF_Image* pImage = pImageObj->GetImage(); if (pImage->IsInline()) diff --git a/core/fpdfapi/font/cpdf_type3char.cpp b/core/fpdfapi/font/cpdf_type3char.cpp index a4df2cc146..e5b7450a0a 100644 --- a/core/fpdfapi/font/cpdf_type3char.cpp +++ b/core/fpdfapi/font/cpdf_type3char.cpp @@ -28,7 +28,7 @@ bool CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) { if (!pPageObj->IsImage()) return false; - m_ImageMatrix = pPageObj->AsImage()->m_Matrix; + m_ImageMatrix = pPageObj->AsImage()->matrix(); std::unique_ptr pSource( pPageObj->AsImage()->GetImage()->LoadDIBSource()); if (pSource) diff --git a/core/fpdfapi/page/cpdf_imageobject.h b/core/fpdfapi/page/cpdf_imageobject.h index fd99d3d612..2bb1e8233d 100644 --- a/core/fpdfapi/page/cpdf_imageobject.h +++ b/core/fpdfapi/page/cpdf_imageobject.h @@ -32,11 +32,13 @@ class CPDF_ImageObject : public CPDF_PageObject { void SetOwnedImage(std::unique_ptr pImage); void SetUnownedImage(CPDF_Image* pImage); - CFX_Matrix m_Matrix; + void set_matrix(const CFX_Matrix& matrix) { m_Matrix = matrix; } + const CFX_Matrix& matrix() const { return m_Matrix; } private: void Release(); + CFX_Matrix m_Matrix; CPDF_Image* m_pImage; bool m_pImageOwned; }; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 6ddd278e27..107ab1ccaa 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -848,7 +848,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImageObject( CFX_Matrix ImageMatrix = m_pCurStates->m_CTM; ImageMatrix.Concat(m_mtContentToUser); - pImageObj->m_Matrix = ImageMatrix; + pImageObj->set_matrix(ImageMatrix); pImageObj->CalcBoundingBox(); CPDF_ImageObject* pRet = pImageObj.get(); diff --git a/core/fpdfapi/render/fpdf_render_image.cpp b/core/fpdfapi/render/fpdf_render_image.cpp index cf5f97bab8..b95828c0cc 100644 --- a/core/fpdfapi/render/fpdf_render_image.cpp +++ b/core/fpdfapi/render/fpdf_render_image.cpp @@ -378,11 +378,10 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { return false; } - m_ImageMatrix = m_pImageObject->m_Matrix; + m_ImageMatrix = m_pImageObject->matrix(); m_ImageMatrix.Concat(*pObj2Device); - if (StartLoadDIBSource()) { + if (StartLoadDIBSource()) return true; - } return StartRenderDIBSource(); } diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp index e256f85c0f..acd53d3b07 100644 --- a/fpdfsdk/fpdfeditimg.cpp +++ b/fpdfsdk/fpdfeditimg.cpp @@ -55,12 +55,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, return false; CPDF_ImageObject* pImgObj = reinterpret_cast(image_object); - pImgObj->m_Matrix.a = static_cast(a); - pImgObj->m_Matrix.b = static_cast(b); - pImgObj->m_Matrix.c = static_cast(c); - pImgObj->m_Matrix.d = static_cast(d); - pImgObj->m_Matrix.e = static_cast(e); - pImgObj->m_Matrix.f = static_cast(f); + pImgObj->set_matrix( + CFX_Matrix(static_cast(a), static_cast(b), + static_cast(c), static_cast(d), + static_cast(e), static_cast(f))); pImgObj->CalcBoundingBox(); return true; } -- cgit v1.2.3