| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "pageint.h" | 8 #include "pageint.h" |
| 9 | 9 |
| 10 CPDF_Pattern::CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix) : | 10 CPDF_Pattern::CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix) : |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 } else { | 77 } else { |
| 78 m_pShadingObj = pPatternObj; | 78 m_pShadingObj = pPatternObj; |
| 79 } | 79 } |
| 80 m_ShadingType = 0; | 80 m_ShadingType = 0; |
| 81 m_pCS = NULL; | 81 m_pCS = NULL; |
| 82 m_nFuncs = 0; | 82 m_nFuncs = 0; |
| 83 for (int i = 0; i < 4; i ++) { | 83 for (int i = 0; i < 4; i ++) { |
| 84 m_pFunctions[i] = NULL; | 84 m_pFunctions[i] = NULL; |
| 85 } | 85 } |
| 86 m_pCountedCS = NULL; |
| 86 } | 87 } |
| 87 CPDF_ShadingPattern::~CPDF_ShadingPattern() | 88 CPDF_ShadingPattern::~CPDF_ShadingPattern() |
| 88 { | 89 { |
| 89 Clear(); | 90 Clear(); |
| 90 } | 91 } |
| 91 void CPDF_ShadingPattern::Clear() | 92 void CPDF_ShadingPattern::Clear() |
| 92 { | 93 { |
| 93 for (int i = 0; i < m_nFuncs; i ++) { | 94 for (int i = 0; i < m_nFuncs; i ++) { |
| 94 if (m_pFunctions[i]) { | 95 if (m_pFunctions[i]) { |
| 95 delete m_pFunctions[i]; | 96 delete m_pFunctions[i]; |
| 96 } | 97 } |
| 97 m_pFunctions[i] = NULL; | 98 m_pFunctions[i] = NULL; |
| 98 } | 99 } |
| 99 CPDF_ColorSpace* pCS = m_pCS; | 100 CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->m_Obj : NULL; |
| 100 if (!m_bForceClear && pCS && m_pDocument) { | 101 if (pCS && m_pDocument) { |
| 101 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); | 102 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); |
| 102 } | 103 } |
| 103 m_ShadingType = 0; | 104 m_ShadingType = 0; |
| 104 m_pCS = NULL; | 105 m_pCS = NULL; |
| 106 m_pCountedCS = NULL; |
| 105 m_nFuncs = 0; | 107 m_nFuncs = 0; |
| 106 } | 108 } |
| 107 FX_BOOL CPDF_ShadingPattern::Load() | 109 FX_BOOL CPDF_ShadingPattern::Load() |
| 108 { | 110 { |
| 109 if (m_ShadingType != 0) { | 111 if (m_ShadingType != 0) { |
| 110 return TRUE; | 112 return TRUE; |
| 111 } | 113 } |
| 112 CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : N
ULL; | 114 CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : N
ULL; |
| 113 if (pShadingDict == NULL) { | 115 if (pShadingDict == NULL) { |
| 114 return FALSE; | 116 return FALSE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 134 m_pFunctions[0] = CPDF_Function::Load(pFunc); | 136 m_pFunctions[0] = CPDF_Function::Load(pFunc); |
| 135 m_nFuncs = 1; | 137 m_nFuncs = 1; |
| 136 } | 138 } |
| 137 } | 139 } |
| 138 CPDF_Object* pCSObj = pShadingDict->GetElementValue(FX_BSTRC("ColorSpace")); | 140 CPDF_Object* pCSObj = pShadingDict->GetElementValue(FX_BSTRC("ColorSpace")); |
| 139 if (pCSObj == NULL) { | 141 if (pCSObj == NULL) { |
| 140 return FALSE; | 142 return FALSE; |
| 141 } | 143 } |
| 142 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); | 144 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); |
| 143 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); | 145 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); |
| 146 if (m_pCS) { |
| 147 m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray()); |
| 148 } |
| 144 m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType")); | 149 m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType")); |
| 145 return TRUE; | 150 return TRUE; |
| 146 } | 151 } |
| 147 FX_BOOL CPDF_ShadingPattern::Reload() | 152 FX_BOOL CPDF_ShadingPattern::Reload() |
| 148 { | 153 { |
| 149 Clear(); | 154 Clear(); |
| 150 return Load(); | 155 return Load(); |
| 151 } | 156 } |
| 152 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream, CPDF_Function** pFunc
s, int nFuncs, CPDF_ColorSpace* pCS) | 157 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream, CPDF_Function** pFunc
s, int nFuncs, CPDF_ColorSpace* pCS) |
| 153 { | 158 { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 286 } |
| 282 } | 287 } |
| 283 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color
_count); | 288 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color
_count); |
| 284 if (bGouraud) { | 289 if (bGouraud) { |
| 285 stream.m_BitStream.ByteAlign(); | 290 stream.m_BitStream.ByteAlign(); |
| 286 } | 291 } |
| 287 } | 292 } |
| 288 rect.Transform(pMatrix); | 293 rect.Transform(pMatrix); |
| 289 return rect; | 294 return rect; |
| 290 } | 295 } |
| OLD | NEW |