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) |
11 m_pPatternObj(NULL), m_PatternType(PATTERN_TILING), m_pDocument(NULL), m_pCo
lor(NULL) | 11 : m_pPatternObj(NULL), |
12 { | 12 m_PatternType(PATTERN_TILING), |
13 if (pParentMatrix) { | 13 m_pDocument(NULL), |
14 m_ParentMatrix = *pParentMatrix; | 14 m_pColor(NULL) { |
15 } | 15 if (pParentMatrix) { |
| 16 m_ParentMatrix = *pParentMatrix; |
| 17 } |
16 } | 18 } |
17 | 19 |
18 CPDF_Pattern::~CPDF_Pattern() | 20 CPDF_Pattern::~CPDF_Pattern() { |
19 { | 21 if (m_pColor) { |
20 if (m_pColor) { | 22 m_pColor->SetValue(NULL, NULL, 0); |
21 m_pColor->SetValue(NULL, NULL, 0); | 23 m_pColor = NULL; |
22 m_pColor = NULL; | 24 } |
23 } | 25 } |
24 } | 26 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, |
25 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, CPDF_Object* pPatter
nObj, const CFX_AffineMatrix* parentMatrix) : | 27 CPDF_Object* pPatternObj, |
26 CPDF_Pattern(parentMatrix) | 28 const CFX_AffineMatrix* parentMatrix) |
27 { | 29 : CPDF_Pattern(parentMatrix) { |
28 m_PatternType = PATTERN_TILING; | 30 m_PatternType = PATTERN_TILING; |
29 m_pPatternObj = pPatternObj; | 31 m_pPatternObj = pPatternObj; |
30 m_pDocument = pDoc; | 32 m_pDocument = pDoc; |
| 33 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); |
| 34 ASSERT(pDict != NULL); |
| 35 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); |
| 36 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; |
| 37 if (parentMatrix) { |
| 38 m_Pattern2Form.Concat(*parentMatrix); |
| 39 } |
| 40 m_pForm = NULL; |
| 41 } |
| 42 CPDF_TilingPattern::~CPDF_TilingPattern() { |
| 43 if (m_pForm) { |
| 44 delete m_pForm; |
| 45 m_pForm = NULL; |
| 46 } |
| 47 } |
| 48 FX_BOOL CPDF_TilingPattern::Load() { |
| 49 if (m_pForm != NULL) { |
| 50 return TRUE; |
| 51 } |
| 52 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); |
| 53 if (pDict == NULL) { |
| 54 return FALSE; |
| 55 } |
| 56 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; |
| 57 m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("XStep"))); |
| 58 m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("YStep"))); |
| 59 if (m_pPatternObj->GetType() != PDFOBJ_STREAM) { |
| 60 return FALSE; |
| 61 } |
| 62 CPDF_Stream* pStream = (CPDF_Stream*)m_pPatternObj; |
| 63 m_pForm = FX_NEW CPDF_Form(m_pDocument, NULL, pStream); |
| 64 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL); |
| 65 m_BBox = pDict->GetRect(FX_BSTRC("BBox")); |
| 66 return TRUE; |
| 67 } |
| 68 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, |
| 69 CPDF_Object* pPatternObj, |
| 70 FX_BOOL bShading, |
| 71 const CFX_AffineMatrix* parentMatrix) |
| 72 : CPDF_Pattern(parentMatrix) { |
| 73 m_PatternType = PATTERN_SHADING; |
| 74 m_pPatternObj = bShading ? NULL : pPatternObj; |
| 75 m_pDocument = pDoc; |
| 76 m_bShadingObj = bShading; |
| 77 if (!bShading) { |
31 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); | 78 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); |
32 ASSERT(pDict != NULL); | 79 ASSERT(pDict != NULL); |
33 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); | 80 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); |
34 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; | 81 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading")); |
35 if (parentMatrix) { | 82 if (parentMatrix) { |
36 m_Pattern2Form.Concat(*parentMatrix); | 83 m_Pattern2Form.Concat(*parentMatrix); |
37 } | 84 } |
38 m_pForm = NULL; | 85 } else { |
39 } | 86 m_pShadingObj = pPatternObj; |
40 CPDF_TilingPattern::~CPDF_TilingPattern() | 87 } |
41 { | 88 m_ShadingType = 0; |
42 if (m_pForm) { | 89 m_pCS = NULL; |
43 delete m_pForm; | 90 m_nFuncs = 0; |
44 m_pForm = NULL; | 91 for (int i = 0; i < 4; i++) { |
45 } | 92 m_pFunctions[i] = NULL; |
46 } | 93 } |
47 FX_BOOL CPDF_TilingPattern::Load() | 94 } |
48 { | 95 CPDF_ShadingPattern::~CPDF_ShadingPattern() { |
49 if (m_pForm != NULL) { | 96 Clear(); |
50 return TRUE; | 97 } |
51 } | 98 void CPDF_ShadingPattern::Clear() { |
52 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); | 99 for (int i = 0; i < m_nFuncs; i++) { |
53 if (pDict == NULL) { | 100 if (m_pFunctions[i]) { |
54 return FALSE; | 101 delete m_pFunctions[i]; |
55 } | 102 } |
56 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; | 103 m_pFunctions[i] = NULL; |
57 m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("XStep"))); | 104 } |
58 m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber(FX_BSTRC("YStep"))); | 105 CPDF_ColorSpace* pCS = m_pCS; |
59 if (m_pPatternObj->GetType() != PDFOBJ_STREAM) { | 106 if (pCS && m_pDocument) { |
60 return FALSE; | 107 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); |
61 } | 108 } |
62 CPDF_Stream* pStream = (CPDF_Stream*)m_pPatternObj; | 109 m_ShadingType = 0; |
63 m_pForm = FX_NEW CPDF_Form(m_pDocument, NULL, pStream); | 110 m_pCS = NULL; |
64 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL); | 111 m_nFuncs = 0; |
65 m_BBox = pDict->GetRect(FX_BSTRC("BBox")); | 112 } |
| 113 FX_BOOL CPDF_ShadingPattern::Load() { |
| 114 if (m_ShadingType != 0) { |
66 return TRUE; | 115 return TRUE; |
67 } | 116 } |
68 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, CPDF_Object* pPatt
ernObj, FX_BOOL bShading, const CFX_AffineMatrix* parentMatrix) : CPDF_Pattern(p
arentMatrix) | 117 CPDF_Dictionary* pShadingDict = |
69 { | 118 m_pShadingObj ? m_pShadingObj->GetDict() : NULL; |
70 m_PatternType = PATTERN_SHADING; | 119 if (pShadingDict == NULL) { |
71 m_pPatternObj = bShading ? NULL : pPatternObj; | 120 return FALSE; |
72 m_pDocument = pDoc; | 121 } |
73 m_bShadingObj = bShading; | 122 if (m_nFuncs) { |
74 if (!bShading) { | 123 for (int i = 0; i < m_nFuncs; i++) |
75 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); | 124 if (m_pFunctions[i]) { |
76 ASSERT(pDict != NULL); | 125 delete m_pFunctions[i]; |
77 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); | 126 } |
78 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading")); | 127 m_nFuncs = 0; |
79 if (parentMatrix) { | 128 } |
80 m_Pattern2Form.Concat(*parentMatrix); | 129 CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function")); |
81 } | 130 if (pFunc) { |
| 131 if (pFunc->GetType() == PDFOBJ_ARRAY) { |
| 132 m_nFuncs = ((CPDF_Array*)pFunc)->GetCount(); |
| 133 if (m_nFuncs > 4) { |
| 134 m_nFuncs = 4; |
| 135 } |
| 136 for (int i = 0; i < m_nFuncs; i++) { |
| 137 m_pFunctions[i] = |
| 138 CPDF_Function::Load(((CPDF_Array*)pFunc)->GetElementValue(i)); |
| 139 } |
82 } else { | 140 } else { |
83 m_pShadingObj = pPatternObj; | 141 m_pFunctions[0] = CPDF_Function::Load(pFunc); |
84 } | 142 m_nFuncs = 1; |
85 m_ShadingType = 0; | 143 } |
86 m_pCS = NULL; | 144 } |
87 m_nFuncs = 0; | 145 CPDF_Object* pCSObj = pShadingDict->GetElementValue(FX_BSTRC("ColorSpace")); |
88 for (int i = 0; i < 4; i ++) { | 146 if (pCSObj == NULL) { |
89 m_pFunctions[i] = NULL; | 147 return FALSE; |
90 } | 148 } |
91 } | 149 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); |
92 CPDF_ShadingPattern::~CPDF_ShadingPattern() | 150 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); |
93 { | 151 m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType")); |
94 Clear(); | 152 return TRUE; |
95 } | 153 } |
96 void CPDF_ShadingPattern::Clear() | 154 FX_BOOL CPDF_ShadingPattern::Reload() { |
97 { | 155 Clear(); |
98 for (int i = 0; i < m_nFuncs; i ++) { | 156 return Load(); |
99 if (m_pFunctions[i]) { | 157 } |
100 delete m_pFunctions[i]; | 158 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream, |
101 } | 159 CPDF_Function** pFuncs, |
102 m_pFunctions[i] = NULL; | 160 int nFuncs, |
103 } | 161 CPDF_ColorSpace* pCS) { |
104 CPDF_ColorSpace* pCS = m_pCS; | 162 m_Stream.LoadAllData(pShadingStream); |
105 if (pCS && m_pDocument) { | 163 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); |
106 m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray()); | 164 m_pFuncs = pFuncs; |
107 } | 165 m_nFuncs = nFuncs; |
108 m_ShadingType = 0; | 166 m_pCS = pCS; |
109 m_pCS = NULL; | 167 CPDF_Dictionary* pDict = pShadingStream->GetDict(); |
110 m_nFuncs = 0; | 168 m_nCoordBits = pDict->GetInteger(FX_BSTRC("BitsPerCoordinate")); |
111 } | 169 m_nCompBits = pDict->GetInteger(FX_BSTRC("BitsPerComponent")); |
112 FX_BOOL CPDF_ShadingPattern::Load() | 170 m_nFlagBits = pDict->GetInteger(FX_BSTRC("BitsPerFlag")); |
113 { | 171 if (!m_nCoordBits || !m_nCompBits) { |
114 if (m_ShadingType != 0) { | 172 return FALSE; |
115 return TRUE; | 173 } |
116 } | 174 int nComps = pCS->CountComponents(); |
117 CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : N
ULL; | 175 if (nComps > 8) { |
118 if (pShadingDict == NULL) { | 176 return FALSE; |
119 return FALSE; | 177 } |
120 } | 178 m_nComps = nFuncs ? 1 : nComps; |
121 if (m_nFuncs) { | 179 if (((int)m_nComps < 0) || m_nComps > 8) { |
122 for (int i = 0; i < m_nFuncs; i ++) | 180 return FALSE; |
123 if (m_pFunctions[i]) { | 181 } |
124 delete m_pFunctions[i]; | 182 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1; |
125 } | 183 m_CompMax = (1 << m_nCompBits) - 1; |
126 m_nFuncs = 0; | 184 CPDF_Array* pDecode = pDict->GetArray(FX_BSTRC("Decode")); |
127 } | 185 if (pDecode == NULL || pDecode->GetCount() != 4 + m_nComps * 2) { |
128 CPDF_Object* pFunc = pShadingDict->GetElementValue(FX_BSTRC("Function")); | 186 return FALSE; |
129 if (pFunc) { | 187 } |
130 if (pFunc->GetType() == PDFOBJ_ARRAY) { | 188 m_xmin = pDecode->GetNumber(0); |
131 m_nFuncs = ((CPDF_Array*)pFunc)->GetCount(); | 189 m_xmax = pDecode->GetNumber(1); |
132 if (m_nFuncs > 4) { | 190 m_ymin = pDecode->GetNumber(2); |
133 m_nFuncs = 4; | 191 m_ymax = pDecode->GetNumber(3); |
134 } | 192 for (FX_DWORD i = 0; i < m_nComps; i++) { |
135 for (int i = 0; i < m_nFuncs; i ++) { | 193 m_ColorMin[i] = pDecode->GetNumber(i * 2 + 4); |
136 m_pFunctions[i] = CPDF_Function::Load(((CPDF_Array*)pFunc)->GetE
lementValue(i)); | 194 m_ColorMax[i] = pDecode->GetNumber(i * 2 + 5); |
137 } | 195 } |
138 } else { | 196 return TRUE; |
139 m_pFunctions[0] = CPDF_Function::Load(pFunc); | 197 } |
140 m_nFuncs = 1; | 198 FX_DWORD CPDF_MeshStream::GetFlag() { |
141 } | 199 return m_BitStream.GetBits(m_nFlagBits) & 0x03; |
142 } | 200 } |
143 CPDF_Object* pCSObj = pShadingDict->GetElementValue(FX_BSTRC("ColorSpace")); | 201 void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) { |
144 if (pCSObj == NULL) { | 202 if (m_nCoordBits == 32) { |
145 return FALSE; | 203 x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * |
146 } | 204 (m_xmax - m_xmin) / (double)m_CoordMax); |
147 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); | 205 y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * |
148 m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL); | 206 (m_ymax - m_ymin) / (double)m_CoordMax); |
149 m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType")); | 207 } else { |
150 return TRUE; | 208 x = m_xmin + |
151 } | 209 m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax; |
152 FX_BOOL CPDF_ShadingPattern::Reload() | 210 y = m_ymin + |
153 { | 211 m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax; |
154 Clear(); | 212 } |
155 return Load(); | 213 } |
156 } | 214 void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) { |
157 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream, CPDF_Function** pFunc
s, int nFuncs, CPDF_ColorSpace* pCS) | 215 FX_DWORD i; |
158 { | 216 FX_FLOAT color_value[8]; |
159 m_Stream.LoadAllData(pShadingStream); | 217 for (i = 0; i < m_nComps; i++) { |
160 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); | 218 color_value[i] = m_ColorMin[i] + |
161 m_pFuncs = pFuncs; | 219 m_BitStream.GetBits(m_nCompBits) * |
162 m_nFuncs = nFuncs; | 220 (m_ColorMax[i] - m_ColorMin[i]) / m_CompMax; |
163 m_pCS = pCS; | 221 } |
164 CPDF_Dictionary* pDict = pShadingStream->GetDict(); | 222 if (m_nFuncs) { |
165 m_nCoordBits = pDict->GetInteger(FX_BSTRC("BitsPerCoordinate")); | 223 static const int kMaxResults = 8; |
166 m_nCompBits = pDict->GetInteger(FX_BSTRC("BitsPerComponent")); | 224 FX_FLOAT result[kMaxResults]; |
167 m_nFlagBits = pDict->GetInteger(FX_BSTRC("BitsPerFlag")); | 225 int nResults; |
168 if (!m_nCoordBits || !m_nCompBits) { | 226 FXSYS_memset32(result, 0, sizeof(result)); |
169 return FALSE; | 227 for (FX_DWORD i = 0; i < m_nFuncs; i++) { |
170 } | 228 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) { |
171 int nComps = pCS->CountComponents(); | 229 m_pFuncs[i]->Call(color_value, 1, result, nResults); |
172 if (nComps > 8) { | 230 } |
173 return FALSE; | 231 } |
174 } | 232 m_pCS->GetRGB(result, r, g, b); |
175 m_nComps = nFuncs ? 1 : nComps; | 233 } else { |
176 if (((int)m_nComps < 0) || m_nComps > 8) { | 234 m_pCS->GetRGB(color_value, r, g, b); |
177 return FALSE; | 235 } |
178 } | 236 } |
179 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1; | 237 FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex, |
180 m_CompMax = (1 << m_nCompBits) - 1; | 238 CFX_AffineMatrix* pObject2Bitmap) { |
181 CPDF_Array* pDecode = pDict->GetArray(FX_BSTRC("Decode")); | 239 FX_DWORD flag = GetFlag(); |
182 if (pDecode == NULL || pDecode->GetCount() != 4 + m_nComps * 2) { | 240 GetCoords(vertex.x, vertex.y); |
183 return FALSE; | 241 pObject2Bitmap->Transform(vertex.x, vertex.y); |
184 } | 242 GetColor(vertex.r, vertex.g, vertex.b); |
185 m_xmin = pDecode->GetNumber(0); | 243 m_BitStream.ByteAlign(); |
186 m_xmax = pDecode->GetNumber(1); | 244 return flag; |
187 m_ymin = pDecode->GetNumber(2); | 245 } |
188 m_ymax = pDecode->GetNumber(3); | 246 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, |
189 for (FX_DWORD i = 0; i < m_nComps; i ++) { | 247 int count, |
190 m_ColorMin[i] = pDecode->GetNumber(i * 2 + 4); | 248 CFX_AffineMatrix* pObject2Bitmap) { |
191 m_ColorMax[i] = pDecode->GetNumber(i * 2 + 5); | 249 for (int i = 0; i < count; i++) { |
192 } | 250 if (m_BitStream.IsEOF()) { |
193 return TRUE; | 251 return FALSE; |
194 } | 252 } |
195 FX_DWORD CPDF_MeshStream::GetFlag() | 253 GetCoords(vertex[i].x, vertex[i].y); |
196 { | 254 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); |
197 return m_BitStream.GetBits(m_nFlagBits) & 0x03; | 255 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); |
198 } | |
199 void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) | |
200 { | |
201 if (m_nCoordBits == 32) { | |
202 x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_
xmin) / (double)m_CoordMax); | |
203 y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_
ymin) / (double)m_CoordMax); | |
204 } else { | |
205 x = m_xmin + m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_C
oordMax; | |
206 y = m_ymin + m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_C
oordMax; | |
207 } | |
208 } | |
209 void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) | |
210 { | |
211 FX_DWORD i; | |
212 FX_FLOAT color_value[8]; | |
213 for (i = 0; i < m_nComps; i ++) { | |
214 color_value[i] = m_ColorMin[i] + m_BitStream.GetBits(m_nCompBits) * (m_C
olorMax[i] - m_ColorMin[i]) / m_CompMax; | |
215 } | |
216 if (m_nFuncs) { | |
217 static const int kMaxResults = 8; | |
218 FX_FLOAT result[kMaxResults]; | |
219 int nResults; | |
220 FXSYS_memset32(result, 0, sizeof(result)); | |
221 for (FX_DWORD i = 0; i < m_nFuncs; i ++) { | |
222 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) { | |
223 m_pFuncs[i]->Call(color_value, 1, result, nResults); | |
224 } | |
225 } | |
226 m_pCS->GetRGB(result, r, g, b); | |
227 } else { | |
228 m_pCS->GetRGB(color_value, r, g, b); | |
229 } | |
230 } | |
231 FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex, CFX_AffineMatrix* p
Object2Bitmap) | |
232 { | |
233 FX_DWORD flag = GetFlag(); | |
234 GetCoords(vertex.x, vertex.y); | |
235 pObject2Bitmap->Transform(vertex.x, vertex.y); | |
236 GetColor(vertex.r, vertex.g, vertex.b); | |
237 m_BitStream.ByteAlign(); | 256 m_BitStream.ByteAlign(); |
238 return flag; | 257 } |
239 } | 258 return TRUE; |
240 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, int count, CFX_Af
fineMatrix* pObject2Bitmap) | 259 } |
241 { | 260 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, |
242 for (int i = 0; i < count; i ++) { | 261 int type, |
243 if (m_BitStream.IsEOF()) { | 262 const CFX_AffineMatrix* pMatrix, |
244 return FALSE; | 263 CPDF_Function** pFuncs, |
245 } | 264 int nFuncs, |
246 GetCoords(vertex[i].x, vertex[i].y); | 265 CPDF_ColorSpace* pCS) { |
247 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); | 266 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM || |
248 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); | 267 pFuncs == NULL || pCS == NULL) { |
249 m_BitStream.ByteAlign(); | 268 return CFX_FloatRect(0, 0, 0, 0); |
250 } | 269 } |
251 return TRUE; | 270 CPDF_MeshStream stream; |
252 } | 271 if (!stream.Load(pStream, pFuncs, nFuncs, pCS)) { |
253 CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream, int type, const CFX_AffineMa
trix* pMatrix, | 272 return CFX_FloatRect(0, 0, 0, 0); |
254 CPDF_Function** pFuncs, int nFuncs, CPDF_ColorSpac
e* pCS) | 273 } |
255 { | 274 CFX_FloatRect rect; |
256 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM || pFuncs == NULL
|| pCS == NULL) { | 275 FX_BOOL bStarted = FALSE; |
257 return CFX_FloatRect(0, 0, 0, 0); | 276 FX_BOOL bGouraud = type == 4 || type == 5; |
258 } | 277 int full_point_count = type == 7 ? 16 : (type == 6 ? 12 : 1); |
259 CPDF_MeshStream stream; | 278 int full_color_count = (type == 6 || type == 7) ? 4 : 1; |
260 if (!stream.Load(pStream, pFuncs, nFuncs, pCS)) { | 279 while (!stream.m_BitStream.IsEOF()) { |
261 return CFX_FloatRect(0, 0, 0, 0); | 280 FX_DWORD flag; |
262 } | 281 if (type != 5) { |
263 CFX_FloatRect rect; | 282 flag = stream.GetFlag(); |
264 FX_BOOL bStarted = FALSE; | 283 } |
265 FX_BOOL bGouraud = type == 4 || type == 5; | 284 int point_count = full_point_count, color_count = full_color_count; |
266 int full_point_count = type == 7 ? 16 : (type == 6 ? 12 : 1); | 285 if (!bGouraud && flag) { |
267 int full_color_count = (type == 6 || type == 7) ? 4 : 1; | 286 point_count -= 4; |
268 while (!stream.m_BitStream.IsEOF()) { | 287 color_count -= 2; |
269 FX_DWORD flag; | 288 } |
270 if (type != 5) { | 289 for (int i = 0; i < point_count; i++) { |
271 flag = stream.GetFlag(); | 290 FX_FLOAT x, y; |
272 } | 291 stream.GetCoords(x, y); |
273 int point_count = full_point_count, color_count = full_color_count; | 292 if (bStarted) { |
274 if (!bGouraud && flag) { | 293 rect.UpdateRect(x, y); |
275 point_count -= 4; | 294 } else { |
276 color_count -= 2; | 295 rect.InitRect(x, y); |
277 } | 296 bStarted = TRUE; |
278 for (int i = 0; i < point_count; i ++) { | 297 } |
279 FX_FLOAT x, y; | 298 } |
280 stream.GetCoords(x, y); | 299 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * |
281 if (bStarted) { | 300 color_count); |
282 rect.UpdateRect(x, y); | 301 if (bGouraud) { |
283 } else { | 302 stream.m_BitStream.ByteAlign(); |
284 rect.InitRect(x, y); | 303 } |
285 bStarted = TRUE; | 304 } |
286 } | 305 rect.Transform(pMatrix); |
287 } | 306 return rect; |
288 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * color
_count); | 307 } |
289 if (bGouraud) { | |
290 stream.m_BitStream.ByteAlign(); | |
291 } | |
292 } | |
293 rect.Transform(pMatrix); | |
294 return rect; | |
295 } | |
OLD | NEW |