| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" | 7 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" |
| 10 #include "core/fpdfapi/fpdf_page/pageint.h" | 10 #include "core/fpdfapi/fpdf_page/pageint.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 m_ymin(0), | 103 m_ymin(0), |
| 104 m_ymax(0) { | 104 m_ymax(0) { |
| 105 memset(&m_ColorMin, 0, sizeof(m_ColorMin)); | 105 memset(&m_ColorMin, 0, sizeof(m_ColorMin)); |
| 106 memset(&m_ColorMax, 0, sizeof(m_ColorMax)); | 106 memset(&m_ColorMax, 0, sizeof(m_ColorMax)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool CPDF_MeshStream::Load() { | 109 bool CPDF_MeshStream::Load() { |
| 110 m_Stream.LoadAllData(m_pShadingStream); | 110 m_Stream.LoadAllData(m_pShadingStream); |
| 111 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); | 111 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); |
| 112 CPDF_Dictionary* pDict = m_pShadingStream->GetDict(); | 112 CPDF_Dictionary* pDict = m_pShadingStream->GetDict(); |
| 113 m_nCoordBits = pDict->GetIntegerBy("BitsPerCoordinate"); | 113 m_nCoordBits = pDict->GetIntegerFor("BitsPerCoordinate"); |
| 114 m_nComponentBits = pDict->GetIntegerBy("BitsPerComponent"); | 114 m_nComponentBits = pDict->GetIntegerFor("BitsPerComponent"); |
| 115 if (ShouldCheckBPC(m_type)) { | 115 if (ShouldCheckBPC(m_type)) { |
| 116 if (!IsValidBitsPerCoordinate(m_nCoordBits)) | 116 if (!IsValidBitsPerCoordinate(m_nCoordBits)) |
| 117 return false; | 117 return false; |
| 118 if (!IsValidBitsPerComponent(m_nComponentBits)) | 118 if (!IsValidBitsPerComponent(m_nComponentBits)) |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 m_nFlagBits = pDict->GetIntegerBy("BitsPerFlag"); | 122 m_nFlagBits = pDict->GetIntegerFor("BitsPerFlag"); |
| 123 if (ShouldCheckBitsPerFlag(m_type) && !IsValidBitsPerFlag(m_nFlagBits)) | 123 if (ShouldCheckBitsPerFlag(m_type) && !IsValidBitsPerFlag(m_nFlagBits)) |
| 124 return false; | 124 return false; |
| 125 | 125 |
| 126 uint32_t nComponents = m_pCS->CountComponents(); | 126 uint32_t nComponents = m_pCS->CountComponents(); |
| 127 if (nComponents > kMaxComponents) | 127 if (nComponents > kMaxComponents) |
| 128 return false; | 128 return false; |
| 129 | 129 |
| 130 m_nComponents = m_funcs.empty() ? nComponents : 1; | 130 m_nComponents = m_funcs.empty() ? nComponents : 1; |
| 131 CPDF_Array* pDecode = pDict->GetArrayBy("Decode"); | 131 CPDF_Array* pDecode = pDict->GetArrayFor("Decode"); |
| 132 if (!pDecode || pDecode->GetCount() != 4 + m_nComponents * 2) | 132 if (!pDecode || pDecode->GetCount() != 4 + m_nComponents * 2) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 m_xmin = pDecode->GetNumberAt(0); | 135 m_xmin = pDecode->GetNumberAt(0); |
| 136 m_xmax = pDecode->GetNumberAt(1); | 136 m_xmax = pDecode->GetNumberAt(1); |
| 137 m_ymin = pDecode->GetNumberAt(2); | 137 m_ymin = pDecode->GetNumberAt(2); |
| 138 m_ymax = pDecode->GetNumberAt(3); | 138 m_ymax = pDecode->GetNumberAt(3); |
| 139 for (uint32_t i = 0; i < m_nComponents; ++i) { | 139 for (uint32_t i = 0; i < m_nComponents; ++i) { |
| 140 m_ColorMin[i] = pDecode->GetNumberAt(i * 2 + 4); | 140 m_ColorMin[i] = pDecode->GetNumberAt(i * 2 + 4); |
| 141 m_ColorMax[i] = pDecode->GetNumberAt(i * 2 + 5); | 141 m_ColorMax[i] = pDecode->GetNumberAt(i * 2 + 5); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if (m_BitStream.IsEOF()) | 208 if (m_BitStream.IsEOF()) |
| 209 return FALSE; | 209 return FALSE; |
| 210 | 210 |
| 211 GetCoords(vertex[i].x, vertex[i].y); | 211 GetCoords(vertex[i].x, vertex[i].y); |
| 212 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); | 212 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); |
| 213 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); | 213 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); |
| 214 m_BitStream.ByteAlign(); | 214 m_BitStream.ByteAlign(); |
| 215 } | 215 } |
| 216 return TRUE; | 216 return TRUE; |
| 217 } | 217 } |
| OLD | NEW |