diff options
author | thestig <thestig@chromium.org> | 2016-06-01 13:45:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-01 13:45:03 -0700 |
commit | acef5fe15d16868768989ba53639b7a7cad6fad3 (patch) | |
tree | 8f70ba1c7afa8cdd84a322f907f8729cfb836a71 /core/fpdfapi/fpdf_render | |
parent | 8abd7a2bbfef51ca6dc8a3462c067e5d2c46200e (diff) | |
download | pdfium-acef5fe15d16868768989ba53639b7a7cad6fad3.tar.xz |
Validate the BitsPerFlag entry in shading dictionaries.
BUG=616248
Review-Url: https://codereview.chromium.org/2020183004
Diffstat (limited to 'core/fpdfapi/fpdf_render')
-rw-r--r-- | core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 754394da70..7896f83459 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -411,8 +411,9 @@ void DrawFreeGouraudShading( int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); - CPDF_MeshStream stream(funcs, pCS); - if (!stream.Load(pShadingStream)) + CPDF_MeshStream stream(kFreeFormGouraudTriangleMeshShading, funcs, + pShadingStream, pCS); + if (!stream.Load()) return; CPDF_MeshVertex triangle[3]; @@ -450,8 +451,9 @@ void DrawLatticeGouraudShading( if (row_verts < 2) return; - CPDF_MeshStream stream(funcs, pCS); - if (!stream.Load(pShadingStream)) + CPDF_MeshStream stream(kLatticeFormGouraudTriangleMeshShading, funcs, + pShadingStream, pCS); + if (!stream.Load()) return; std::unique_ptr<CPDF_MeshVertex, FxFreeDeleter> vertex( @@ -724,24 +726,8 @@ struct CPDF_PatchDrawer { } }; -bool CheckCoonTensorPara(const CPDF_MeshStream& stream) { - uint32_t coord = stream.CoordBits(); - bool bCoordBitsValid = - (coord == 1 || coord == 2 || coord == 4 || coord == 8 || coord == 12 || - coord == 16 || coord == 24 || coord == 32); - - uint32_t comp = stream.CompBits(); - bool bCompBitsValid = (comp == 1 || comp == 2 || comp == 4 || comp == 8 || - comp == 12 || comp == 16); - - uint32_t flag = stream.FlagBits(); - bool bFlagBitsValid = (flag == 2 || flag == 4 || flag == 8); - - return bCoordBitsValid && bCompBitsValid && bFlagBitsValid; -} - void DrawCoonPatchMeshes( - FX_BOOL bTensor, + ShadingType type, CFX_DIBitmap* pBitmap, CFX_Matrix* pObject2Bitmap, CPDF_Stream* pShadingStream, @@ -750,13 +736,13 @@ void DrawCoonPatchMeshes( int fill_mode, int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); + ASSERT(type == kCoonsPatchMeshShading || + type == kTensorProductPatchMeshShading); CFX_FxgeDevice device; device.Attach(pBitmap, false, nullptr, false); - CPDF_MeshStream stream(funcs, pCS); - if (!stream.Load(pShadingStream)) - return; - if (!CheckCoonTensorPara(stream)) + CPDF_MeshStream stream(type, funcs, pShadingStream, pCS); + if (!stream.Load()) return; CPDF_PatchDrawer patch; @@ -766,11 +752,10 @@ void DrawCoonPatchMeshes( patch.path.SetPointCount(13); FX_PATHPOINT* pPoints = patch.path.GetPoints(); pPoints[0].m_Flag = FXPT_MOVETO; - for (int i = 1; i < 13; i++) { + for (int i = 1; i < 13; i++) pPoints[i].m_Flag = FXPT_BEZIERTO; - } CFX_PointF coords[16]; - int point_count = bTensor ? 16 : 12; + int point_count = type == kTensorProductPatchMeshShading ? 16 : 12; while (!stream.BitStream()->IsEOF()) { uint32_t flag = stream.GetFlag(); int iStartPoint = 0, iStartColor = 0, i = 0; @@ -934,10 +919,8 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, // The shading object can be a stream or a dictionary. We do not handle // the case of dictionary at the moment. if (CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) { - DrawCoonPatchMeshes( - pPattern->GetShadingType() == kTensorProductPatchMeshShading, - pBitmap, &FinalMatrix, pStream, funcs, pColorSpace, fill_mode, - alpha); + DrawCoonPatchMeshes(pPattern->GetShadingType(), pBitmap, &FinalMatrix, + pStream, funcs, pColorSpace, fill_mode, alpha); } } break; } |