| 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 16 matching lines...) Expand all Loading... |
| 27 ASSERT(pDict != NULL); | 27 ASSERT(pDict != NULL); |
| 28 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); | 28 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); |
| 29 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; | 29 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; |
| 30 if (parentMatrix) { | 30 if (parentMatrix) { |
| 31 m_Pattern2Form.Concat(*parentMatrix); | 31 m_Pattern2Form.Concat(*parentMatrix); |
| 32 } | 32 } |
| 33 m_pForm = NULL; | 33 m_pForm = NULL; |
| 34 } | 34 } |
| 35 CPDF_TilingPattern::~CPDF_TilingPattern() | 35 CPDF_TilingPattern::~CPDF_TilingPattern() |
| 36 { | 36 { |
| 37 if (m_pForm) { | 37 delete m_pForm; |
| 38 delete m_pForm; | 38 m_pForm = NULL; |
| 39 m_pForm = NULL; | |
| 40 } | |
| 41 } | 39 } |
| 42 FX_BOOL CPDF_TilingPattern::Load() | 40 FX_BOOL CPDF_TilingPattern::Load() |
| 43 { | 41 { |
| 44 if (m_pForm != NULL) { | 42 if (m_pForm != NULL) { |
| 45 return TRUE; | 43 return TRUE; |
| 46 } | 44 } |
| 47 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); | 45 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); |
| 48 if (pDict == NULL) { | 46 if (pDict == NULL) { |
| 49 return FALSE; | 47 return FALSE; |
| 50 } | 48 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 m_pCountedCS = NULL; | 84 m_pCountedCS = NULL; |
| 87 } | 85 } |
| 88 CPDF_ShadingPattern::~CPDF_ShadingPattern() | 86 CPDF_ShadingPattern::~CPDF_ShadingPattern() |
| 89 { | 87 { |
| 90 Clear(); | 88 Clear(); |
| 91 } | 89 } |
| 92 void CPDF_ShadingPattern::Clear() | 90 void CPDF_ShadingPattern::Clear() |
| 93 { | 91 { |
| 94 for (int i = 0; i < m_nFuncs; i ++) { | 92 for (int i = 0; i < m_nFuncs; i ++) { |
| 95 if (m_pFunctions[i]) { | 93 delete m_pFunctions[i]; |
| 96 delete m_pFunctions[i]; | |
| 97 } | |
| 98 m_pFunctions[i] = NULL; | 94 m_pFunctions[i] = NULL; |
| 99 } | 95 } |
| 100 CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : NULL; | 96 CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : NULL; |
| 101 if (pCS && m_pDocument) { | 97 if (pCS && m_pDocument) { |
| 102 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); | 98 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); |
| 103 } | 99 } |
| 104 m_ShadingType = 0; | 100 m_ShadingType = 0; |
| 105 m_pCS = NULL; | 101 m_pCS = NULL; |
| 106 m_pCountedCS = NULL; | 102 m_pCountedCS = NULL; |
| 107 m_nFuncs = 0; | 103 m_nFuncs = 0; |
| 108 } | 104 } |
| 109 FX_BOOL CPDF_ShadingPattern::Load() | 105 FX_BOOL CPDF_ShadingPattern::Load() |
| 110 { | 106 { |
| 111 if (m_ShadingType != 0) { | 107 if (m_ShadingType != 0) { |
| 112 return TRUE; | 108 return TRUE; |
| 113 } | 109 } |
| 114 CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : N
ULL; | 110 CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : N
ULL; |
| 115 if (pShadingDict == NULL) { | 111 if (pShadingDict == NULL) { |
| 116 return FALSE; | 112 return FALSE; |
| 117 } | 113 } |
| 118 if (m_nFuncs) { | 114 if (m_nFuncs) { |
| 119 for (int i = 0; i < m_nFuncs; i ++) | 115 for (int i = 0; i < m_nFuncs; i ++) |
| 120 if (m_pFunctions[i]) { | 116 delete m_pFunctions[i]; |
| 121 delete m_pFunctions[i]; | |
| 122 } | |
| 123 m_nFuncs = 0; | 117 m_nFuncs = 0; |
| 124 } | 118 } |
| 125 CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function")); | 119 CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function")); |
| 126 if (pFunc) { | 120 if (pFunc) { |
| 127 if (pFunc->GetType() == PDFOBJ_ARRAY) { | 121 if (pFunc->GetType() == PDFOBJ_ARRAY) { |
| 128 m_nFuncs = ((CPDF_Array*)pFunc)->GetCount(); | 122 m_nFuncs = ((CPDF_Array*)pFunc)->GetCount(); |
| 129 if (m_nFuncs > 4) { | 123 if (m_nFuncs > 4) { |
| 130 m_nFuncs = 4; | 124 m_nFuncs = 4; |
| 131 } | 125 } |
| 132 for (int i = 0; i < m_nFuncs; i ++) { | 126 for (int i = 0; i < m_nFuncs; i ++) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 280 } |
| 287 } | 281 } |
| 288 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color
_count); | 282 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color
_count); |
| 289 if (bGouraud) { | 283 if (bGouraud) { |
| 290 stream.m_BitStream.ByteAlign(); | 284 stream.m_BitStream.ByteAlign(); |
| 291 } | 285 } |
| 292 } | 286 } |
| 293 rect.Transform(pMatrix); | 287 rect.Transform(pMatrix); |
| 294 return rect; | 288 return rect; |
| 295 } | 289 } |
| OLD | NEW |