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

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

Issue 1923153002: CPDF_Document::LoadPattern() and friends always have a valid matrix. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@clean_doc2
Patch Set: rebase Created 4 years, 7 months 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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfapi/fpdf_page/pageint.h"
8
9 #include <algorithm>
10
11 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
12 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
13 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
18
19 namespace {
20
21 const int kSingleCoordinatePair = 1;
22 const int kTensorCoordinatePairs = 16;
23 const int kCoonsCoordinatePairs = 12;
24
25 const int kSingleColorPerPatch = 1;
26 const int kQuadColorsPerPatch = 4;
27
28 } // namespace
29
30
31
32 CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
33 ShadingType type,
34 const CFX_Matrix* pMatrix,
35 CPDF_Function** pFuncs,
36 int nFuncs,
37 CPDF_ColorSpace* pCS) {
38 if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
39 return CFX_FloatRect(0, 0, 0, 0);
40
41 CPDF_MeshStream stream;
42 if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
43 return CFX_FloatRect(0, 0, 0, 0);
44
45 CFX_FloatRect rect;
46 bool bStarted = false;
47 bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
48 type == kLatticeFormGouraudTriangleMeshShading;
49
50 int point_count = kSingleCoordinatePair;
51 if (type == kTensorProductPatchMeshShading)
52 point_count = kTensorCoordinatePairs;
53 else if (type == kCoonsPatchMeshShading)
54 point_count = kCoonsCoordinatePairs;
55
56 int color_count = kSingleColorPerPatch;
57 if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
58 color_count = kQuadColorsPerPatch;
59
60 while (!stream.m_BitStream.IsEOF()) {
61 uint32_t flag = 0;
62 if (type != kLatticeFormGouraudTriangleMeshShading)
63 flag = stream.GetFlag();
64
65 if (!bGouraud && flag) {
66 point_count -= 4;
67 color_count -= 2;
68 }
69
70 for (int i = 0; i < point_count; i++) {
71 FX_FLOAT x, y;
72 stream.GetCoords(x, y);
73 if (bStarted) {
74 rect.UpdateRect(x, y);
75 } else {
76 rect.InitRect(x, y);
77 bStarted = TRUE;
78 }
79 }
80 stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
81 color_count);
82 if (bGouraud)
83 stream.m_BitStream.ByteAlign();
84 }
85 rect.Transform(pMatrix);
86 return rect;
87 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp ('k') | core/fpdfapi/fpdf_page/include/cpdf_form.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698