Chromium Code Reviews| Index: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| index b30006bf35da357775b17372d64a5f46de03db56..19f9d52bb22252a189962a16604ce5c57dd10026 100644 |
| --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp |
| @@ -97,17 +97,16 @@ CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPair* table, |
| : CFX_ByteStringC(); |
| } |
| -CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream, |
| - ShadingType type, |
| - const CFX_Matrix& matrix, |
| - CPDF_Function** pFuncs, |
| - int nFuncs, |
| - CPDF_ColorSpace* pCS) { |
| - if (!pStream || !pFuncs || !pCS) |
| +CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading, |
| + const CFX_Matrix& matrix) { |
| + ShadingType type = pShading->GetShadingType(); |
| + CPDF_Stream* pStream = ToStream(pShading->GetShadingObject()); |
| + CPDF_ColorSpace* pCS = pShading->GetCS(); |
| + if (!pStream || !pCS) |
| return CFX_FloatRect(0, 0, 0, 0); |
| - CPDF_MeshStream stream; |
| - if (!stream.Load(pStream, pFuncs, nFuncs, pCS)) |
| + CPDF_MeshStream stream(pShading->GetFuncs(), pCS); |
| + if (!stream.Load(pStream)) |
| return CFX_FloatRect(0, 0, 0, 0); |
| CFX_FloatRect rect; |
| @@ -125,7 +124,7 @@ CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream, |
| if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading) |
| color_count = kQuadColorsPerPatch; |
| - while (!stream.m_BitStream.IsEOF()) { |
| + while (!stream.BitStream()->IsEOF()) { |
| uint32_t flag = 0; |
| if (type != kLatticeFormGouraudTriangleMeshShading) |
| flag = stream.GetFlag(); |
| @@ -146,10 +145,10 @@ CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream, |
| bStarted = true; |
| } |
| } |
| - stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * |
| - color_count); |
| + stream.BitStream()->SkipBits(stream.comps() * stream.CompBits() * |
|
Tom Sepez
2016/05/23 19:09:33
pre-existing: this multiply scares me, m_nCompBits
Lei Zhang
2016/05/23 19:26:20
Switched to FX_SAFE_UINT32.
|
| + color_count); |
| if (bGouraud) |
| - stream.m_BitStream.ByteAlign(); |
| + stream.BitStream()->ByteAlign(); |
| } |
| rect.Transform(&matrix); |
| return rect; |
| @@ -1087,7 +1086,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { |
| if (!pShading) |
| return; |
| - if (!pShading->m_bShadingObj || !pShading->Load()) |
| + if (!pShading->IsShadingObject() || !pShading->Load()) |
| return; |
| std::unique_ptr<CPDF_ShadingObject> pObj(new CPDF_ShadingObject); |
| @@ -1097,12 +1096,8 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { |
| pObj->m_Matrix.Concat(m_mtContentToUser); |
| CFX_FloatRect bbox = |
| pObj->m_ClipPath.IsNull() ? m_BBox : pObj->m_ClipPath.GetClipBox(); |
| - if (pShading->IsMeshShading()) { |
| - bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj), |
| - pShading->m_ShadingType, pObj->m_Matrix, |
| - pShading->m_pFunctions, pShading->m_nFuncs, |
| - pShading->m_pCS)); |
| - } |
| + if (pShading->IsMeshShading()) |
| + bbox.Intersect(GetShadingBBox(pShading, pObj->m_Matrix)); |
| pObj->m_Left = bbox.left; |
| pObj->m_Right = bbox.right; |
| pObj->m_Top = bbox.top; |