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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_meshstream.h ('k') | core/fpdfapi/fpdf_page/cpdf_textobject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfapi/fpdf_page/cpdf_meshstream.h" 7 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h"
10 #include "core/fpdfapi/fpdf_page/pageint.h" 10 #include "core/fpdfapi/fpdf_page/pageint.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
12 12
13 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream, 13 FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream,
14 CPDF_Function** pFuncs, 14 CPDF_Function** pFuncs,
15 int nFuncs, 15 int nFuncs,
16 CPDF_ColorSpace* pCS) { 16 CPDF_ColorSpace* pCS) {
17 m_Stream.LoadAllData(pShadingStream); 17 m_Stream.LoadAllData(pShadingStream);
18 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize()); 18 m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize());
19 m_pFuncs = pFuncs; 19 m_pFuncs = pFuncs;
20 m_nFuncs = nFuncs; 20 m_nFuncs = nFuncs;
21 m_pCS = pCS; 21 m_pCS = pCS;
22 CPDF_Dictionary* pDict = pShadingStream->GetDict(); 22 CPDF_Dictionary* pDict = pShadingStream->GetDict();
23 m_nCoordBits = pDict->GetIntegerBy("BitsPerCoordinate"); 23 m_nCoordBits = pDict->GetIntegerBy("BitsPerCoordinate");
24 m_nCompBits = pDict->GetIntegerBy("BitsPerComponent"); 24 m_nCompBits = pDict->GetIntegerBy("BitsPerComponent");
25 m_nFlagBits = pDict->GetIntegerBy("BitsPerFlag"); 25 m_nFlagBits = pDict->GetIntegerBy("BitsPerFlag");
26 if (!m_nCoordBits || !m_nCompBits) 26 if (!m_nCoordBits || !m_nCompBits)
27 return FALSE; 27 return FALSE;
28 28
29 FX_DWORD nComps = pCS->CountComponents(); 29 uint32_t nComps = pCS->CountComponents();
30 if (nComps > 8) 30 if (nComps > 8)
31 return FALSE; 31 return FALSE;
32 32
33 m_nComps = nFuncs ? 1 : nComps; 33 m_nComps = nFuncs ? 1 : nComps;
34 if (((int)m_nComps < 0) || m_nComps > 8) 34 if (((int)m_nComps < 0) || m_nComps > 8)
35 return FALSE; 35 return FALSE;
36 36
37 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1; 37 m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1;
38 m_CompMax = (1 << m_nCompBits) - 1; 38 m_CompMax = (1 << m_nCompBits) - 1;
39 CPDF_Array* pDecode = pDict->GetArrayBy("Decode"); 39 CPDF_Array* pDecode = pDict->GetArrayBy("Decode");
40 if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2) 40 if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2)
41 return FALSE; 41 return FALSE;
42 42
43 m_xmin = pDecode->GetNumberAt(0); 43 m_xmin = pDecode->GetNumberAt(0);
44 m_xmax = pDecode->GetNumberAt(1); 44 m_xmax = pDecode->GetNumberAt(1);
45 m_ymin = pDecode->GetNumberAt(2); 45 m_ymin = pDecode->GetNumberAt(2);
46 m_ymax = pDecode->GetNumberAt(3); 46 m_ymax = pDecode->GetNumberAt(3);
47 for (FX_DWORD i = 0; i < m_nComps; i++) { 47 for (uint32_t i = 0; i < m_nComps; i++) {
48 m_ColorMin[i] = pDecode->GetNumberAt(i * 2 + 4); 48 m_ColorMin[i] = pDecode->GetNumberAt(i * 2 + 4);
49 m_ColorMax[i] = pDecode->GetNumberAt(i * 2 + 5); 49 m_ColorMax[i] = pDecode->GetNumberAt(i * 2 + 5);
50 } 50 }
51 return TRUE; 51 return TRUE;
52 } 52 }
53 53
54 FX_DWORD CPDF_MeshStream::GetFlag() { 54 uint32_t CPDF_MeshStream::GetFlag() {
55 return m_BitStream.GetBits(m_nFlagBits) & 0x03; 55 return m_BitStream.GetBits(m_nFlagBits) & 0x03;
56 } 56 }
57 57
58 void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) { 58 void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) {
59 if (m_nCoordBits == 32) { 59 if (m_nCoordBits == 32) {
60 x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * 60 x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
61 (m_xmax - m_xmin) / (double)m_CoordMax); 61 (m_xmax - m_xmin) / (double)m_CoordMax);
62 y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) * 62 y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
63 (m_ymax - m_ymin) / (double)m_CoordMax); 63 (m_ymax - m_ymin) / (double)m_CoordMax);
64 } else { 64 } else {
65 x = m_xmin + 65 x = m_xmin +
66 m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax; 66 m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax;
67 y = m_ymin + 67 y = m_ymin +
68 m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax; 68 m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax;
69 } 69 }
70 } 70 }
71 71
72 void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) { 72 void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) {
73 FX_DWORD i; 73 uint32_t i;
74 FX_FLOAT color_value[8]; 74 FX_FLOAT color_value[8];
75 for (i = 0; i < m_nComps; i++) { 75 for (i = 0; i < m_nComps; i++) {
76 color_value[i] = m_ColorMin[i] + 76 color_value[i] = m_ColorMin[i] +
77 m_BitStream.GetBits(m_nCompBits) * 77 m_BitStream.GetBits(m_nCompBits) *
78 (m_ColorMax[i] - m_ColorMin[i]) / m_CompMax; 78 (m_ColorMax[i] - m_ColorMin[i]) / m_CompMax;
79 } 79 }
80 if (m_nFuncs) { 80 if (m_nFuncs) {
81 static const int kMaxResults = 8; 81 static const int kMaxResults = 8;
82 FX_FLOAT result[kMaxResults]; 82 FX_FLOAT result[kMaxResults];
83 int nResults; 83 int nResults;
84 FXSYS_memset(result, 0, sizeof(result)); 84 FXSYS_memset(result, 0, sizeof(result));
85 for (FX_DWORD i = 0; i < m_nFuncs; i++) { 85 for (uint32_t i = 0; i < m_nFuncs; i++) {
86 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) { 86 if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) {
87 m_pFuncs[i]->Call(color_value, 1, result, nResults); 87 m_pFuncs[i]->Call(color_value, 1, result, nResults);
88 } 88 }
89 } 89 }
90 m_pCS->GetRGB(result, r, g, b); 90 m_pCS->GetRGB(result, r, g, b);
91 } else { 91 } else {
92 m_pCS->GetRGB(color_value, r, g, b); 92 m_pCS->GetRGB(color_value, r, g, b);
93 } 93 }
94 } 94 }
95 95
96 FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex, 96 uint32_t CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex,
97 CFX_Matrix* pObject2Bitmap) { 97 CFX_Matrix* pObject2Bitmap) {
98 FX_DWORD flag = GetFlag(); 98 uint32_t flag = GetFlag();
99 GetCoords(vertex.x, vertex.y); 99 GetCoords(vertex.x, vertex.y);
100 pObject2Bitmap->Transform(vertex.x, vertex.y); 100 pObject2Bitmap->Transform(vertex.x, vertex.y);
101 GetColor(vertex.r, vertex.g, vertex.b); 101 GetColor(vertex.r, vertex.g, vertex.b);
102 m_BitStream.ByteAlign(); 102 m_BitStream.ByteAlign();
103 return flag; 103 return flag;
104 } 104 }
105 105
106 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex, 106 FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex,
107 int count, 107 int count,
108 CFX_Matrix* pObject2Bitmap) { 108 CFX_Matrix* pObject2Bitmap) {
109 for (int i = 0; i < count; i++) { 109 for (int i = 0; i < count; i++) {
110 if (m_BitStream.IsEOF()) 110 if (m_BitStream.IsEOF())
111 return FALSE; 111 return FALSE;
112 112
113 GetCoords(vertex[i].x, vertex[i].y); 113 GetCoords(vertex[i].x, vertex[i].y);
114 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y); 114 pObject2Bitmap->Transform(vertex[i].x, vertex[i].y);
115 GetColor(vertex[i].r, vertex[i].g, vertex[i].b); 115 GetColor(vertex[i].r, vertex[i].g, vertex[i].b);
116 m_BitStream.ByteAlign(); 116 m_BitStream.ByteAlign();
117 } 117 }
118 return TRUE; 118 return TRUE;
119 } 119 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_meshstream.h ('k') | core/fpdfapi/fpdf_page/cpdf_textobject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698