Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "pageint.h" 7 #include "pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_page.h" 9 #include "core/include/fpdfapi/fpdf_page.h"
10 10
11 namespace { 11 namespace {
12 12
13 const int kSingleCoordinatePair = 1; 13 const int kSingleCoordinatePair = 1;
14 const int kTensorCoordinatePairs = 16; 14 const int kTensorCoordinatePairs = 16;
15 const int kCoonsCoordinatePairs = 12; 15 const int kCoonsCoordinatePairs = 12;
16 16
17 const int kSingleColorPerPatch = 1; 17 const int kSingleColorPerPatch = 1;
18 const int kQuadColorsPerPatch = 4; 18 const int kQuadColorsPerPatch = 4;
19 19
20 ShadingType ToShadingType(int type) { 20 ShadingType ToShadingType(int type) {
21 return (type > static_cast<int>(kInvalidShading) && 21 return (type > static_cast<int>(kInvalidShading) &&
22 type < static_cast<int>(kMaxShading)) 22 type < static_cast<int>(kMaxShading))
23 ? static_cast<ShadingType>(type) 23 ? static_cast<ShadingType>(type)
24 : kInvalidShading; 24 : kInvalidShading;
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 CPDF_Pattern::CPDF_Pattern(const CFX_AffineMatrix* pParentMatrix) 29 CPDF_Pattern::CPDF_Pattern(const CFX_Matrix* pParentMatrix)
30 : m_pPatternObj(NULL), 30 : m_pPatternObj(NULL),
31 m_PatternType(PATTERN_TILING), 31 m_PatternType(PATTERN_TILING),
32 m_pDocument(NULL), 32 m_pDocument(NULL),
33 m_bForceClear(FALSE) { 33 m_bForceClear(FALSE) {
34 if (pParentMatrix) { 34 if (pParentMatrix) {
35 m_ParentMatrix = *pParentMatrix; 35 m_ParentMatrix = *pParentMatrix;
36 } 36 }
37 } 37 }
38 CPDF_Pattern::~CPDF_Pattern() {} 38 CPDF_Pattern::~CPDF_Pattern() {}
39 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, 39 CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
40 CPDF_Object* pPatternObj, 40 CPDF_Object* pPatternObj,
41 const CFX_AffineMatrix* parentMatrix) 41 const CFX_Matrix* parentMatrix)
42 : CPDF_Pattern(parentMatrix) { 42 : CPDF_Pattern(parentMatrix) {
43 m_PatternType = PATTERN_TILING; 43 m_PatternType = PATTERN_TILING;
44 m_pPatternObj = pPatternObj; 44 m_pPatternObj = pPatternObj;
45 m_pDocument = pDoc; 45 m_pDocument = pDoc;
46 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); 46 CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
47 ASSERT(pDict != NULL); 47 ASSERT(pDict != NULL);
48 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); 48 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix"));
49 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1; 49 m_bColored = pDict->GetInteger(FX_BSTRC("PaintType")) == 1;
50 if (parentMatrix) { 50 if (parentMatrix) {
51 m_Pattern2Form.Concat(*parentMatrix); 51 m_Pattern2Form.Concat(*parentMatrix);
(...skipping 21 matching lines...) Expand all
73 return FALSE; 73 return FALSE;
74 74
75 m_pForm = new CPDF_Form(m_pDocument, NULL, pStream); 75 m_pForm = new CPDF_Form(m_pDocument, NULL, pStream);
76 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL); 76 m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL);
77 m_BBox = pDict->GetRect(FX_BSTRC("BBox")); 77 m_BBox = pDict->GetRect(FX_BSTRC("BBox"));
78 return TRUE; 78 return TRUE;
79 } 79 }
80 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, 80 CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
81 CPDF_Object* pPatternObj, 81 CPDF_Object* pPatternObj,
82 FX_BOOL bShading, 82 FX_BOOL bShading,
83 const CFX_AffineMatrix* parentMatrix) 83 const CFX_Matrix* parentMatrix)
84 : CPDF_Pattern(parentMatrix) { 84 : CPDF_Pattern(parentMatrix) {
85 m_PatternType = PATTERN_SHADING; 85 m_PatternType = PATTERN_SHADING;
86 m_pPatternObj = bShading ? NULL : pPatternObj; 86 m_pPatternObj = bShading ? NULL : pPatternObj;
87 m_pDocument = pDoc; 87 m_pDocument = pDoc;
88 m_bShadingObj = bShading; 88 m_bShadingObj = bShading;
89 if (!bShading) { 89 if (!bShading) {
90 CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); 90 CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
91 ASSERT(pDict != NULL); 91 ASSERT(pDict != NULL);
92 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix")); 92 m_Pattern2Form = pDict->GetMatrix(FX_BSTRC("Matrix"));
93 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading")); 93 m_pShadingObj = pDict->GetElementValue(FX_BSTRC("Shading"));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) { 246 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) {
247 m_pFuncs[i]->Call(color_value, 1, result, nResults); 247 m_pFuncs[i]->Call(color_value, 1, result, nResults);
248 } 248 }
249 } 249 }
250 m_pCS->GetRGB(result, r, g, b); 250 m_pCS->GetRGB(result, r, g, b);
251 } else { 251 } else {
252 m_pCS->GetRGB(color_value, r, g, b); 252 m_pCS->GetRGB(color_value, r, g, b);
253 } 253 }
254 } 254 }
255 FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex, 255 FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex,
256 CFX_AffineMatrix* pObject2Bitmap) { 256 CFX_Matrix* pObject2Bitmap) {
257 FX_DWORD flag = GetFlag(); 257 FX_DWORD flag = GetFlag();
258 GetCoords(vertex.x, vertex.y); 258 GetCoords(vertex.x, vertex.y);
259 pObject2Bitmap->Transform(vertex.x, vertex.y); 259 pObject2Bitmap->Transform(vertex.x, vertex.y);
260 GetColor(vertex.r, vertex.g, vertex.b); 260 GetColor(vertex.r, vertex.g, vertex.b);
261 m_BitStream.ByteAlign(); 261 m_BitStream.ByteAlign();
262 return flag; 262 return flag;
263 } 263 }
264 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, 264 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex,
265 int count, 265 int count,
266 CFX_AffineMatrix* pObject2Bitmap) { 266 CFX_Matrix* pObject2Bitmap) {
267 for (int i = 0; i < count; i++) { 267 for (int i = 0; i < count; i++) {
268 if (m_BitStream.IsEOF()) { 268 if (m_BitStream.IsEOF()) {
269 return FALSE; 269 return FALSE;
270 } 270 }
271 GetCoords(vertex[i].x, vertex[i].y); 271 GetCoords(vertex[i].x, vertex[i].y);
272 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); 272 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y);
273 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); 273 GetColor(vertex[i].r, vertex[i].g, vertex[i].b);
274 m_BitStream.ByteAlign(); 274 m_BitStream.ByteAlign();
275 } 275 }
276 return TRUE; 276 return TRUE;
277 } 277 }
278 278
279 CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream, 279 CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
280 ShadingType type, 280 ShadingType type,
281 const CFX_AffineMatrix* pMatrix, 281 const CFX_Matrix* pMatrix,
282 CPDF_Function** pFuncs, 282 CPDF_Function** pFuncs,
283 int nFuncs, 283 int nFuncs,
284 CPDF_ColorSpace* pCS) { 284 CPDF_ColorSpace* pCS) {
285 if (!pStream || !pStream->IsStream() || !pFuncs || !pCS) 285 if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
286 return CFX_FloatRect(0, 0, 0, 0); 286 return CFX_FloatRect(0, 0, 0, 0);
287 287
288 CPDF_MeshStream stream; 288 CPDF_MeshStream stream;
289 if (!stream.Load(pStream, pFuncs, nFuncs, pCS)) 289 if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
290 return CFX_FloatRect(0, 0, 0, 0); 290 return CFX_FloatRect(0, 0, 0, 0);
291 291
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 } 326 }
327 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits * 327 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
328 color_count); 328 color_count);
329 if (bGouraud) 329 if (bGouraud)
330 stream.m_BitStream.ByteAlign(); 330 stream.m_BitStream.ByteAlign();
331 } 331 }
332 rect.Transform(pMatrix); 332 rect.Transform(pMatrix);
333 return rect; 333 return rect;
334 } 334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698