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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Utils.cpp

Issue 1552583002: Remove header files that only have includes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 11 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 | « fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Wnd.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 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 "fpdfsdk/include/pdfwindow/PDFWindow.h"
8 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h" 7 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" 8 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" 9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
11 10
12 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) 11 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
13 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) 12 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
14 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) 13 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
15 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) 14 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
16 15
17 /* ---------------------------- CPWL_Utils ------------------------------ */
18
19 CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, 16 CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
20 int32_t nCount) { 17 int32_t nCount) {
21 CFX_ByteTextBuf csAP; 18 CFX_ByteTextBuf csAP;
22 19
23 for (int32_t i = 0; i < nCount; i++) { 20 for (int32_t i = 0; i < nCount; i++) {
24 switch (pPathData[i].type) { 21 switch (pPathData[i].type) {
25 case PWLPT_MOVETO: 22 case PWLPT_MOVETO:
26 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n"; 23 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
27 break; 24 break;
28 case PWLPT_LINETO: 25 case PWLPT_LINETO:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { 126 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
130 wrRet.EndPos = wr1.EndPos; 127 wrRet.EndPos = wr1.EndPos;
131 } else { 128 } else {
132 wrRet.EndPos = wr2.EndPos; 129 wrRet.EndPos = wr2.EndPos;
133 } 130 }
134 131
135 return wrRet; 132 return wrRet;
136 } 133 }
137 134
138 CFX_ByteString CPWL_Utils::GetAP_Check(const CPDF_Rect& crBBox) { 135 CFX_ByteString CPWL_Utils::GetAP_Check(const CPDF_Rect& crBBox) {
139 CFX_ByteTextBuf csAP; 136 const FX_FLOAT fWidth = crBBox.right - crBBox.left;
137 const FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
140 138
141 FX_FLOAT fWidth = crBBox.right - crBBox.left; 139 CPWL_Point pts[8][3] = {{CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f),
142 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; 140 CPWL_Point(0.29f, 0.40f)},
141 {CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f),
142 CPWL_Point(0.31f, 0.28f)},
143 {CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f),
144 CPWL_Point(0.77f, 0.67f)},
145 {CPWL_Point(0.76f, 0.68f), CPWL_Point(0.78f, 0.69f),
146 CPWL_Point(0.76f, 0.75f)},
147 {CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f),
148 CPWL_Point(0.68f, 0.75f)},
149 {CPWL_Point(0.68f, 0.74f), CPWL_Point(0.68f, 0.74f),
150 CPWL_Point(0.44f, 0.47f)},
151 {CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f),
152 CPWL_Point(0.41f, 0.58f)},
153 {CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
154 CPWL_Point(0.30f, 0.56f)}};
143 155
144 const int32_t num = 8; 156 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
157 for (size_t j = 0; j < FX_ArraySize(pts[0]); ++j) {
158 pts[i][j].x *= fWidth;
Tom Sepez 2016/01/05 17:52:14 nit: maybe an infix expression like pts[i][j].x =
Lei Zhang 2016/01/06 00:40:34 Done.
159 pts[i][j].x += crBBox.left;
145 160
Tom Sepez 2016/01/05 17:52:14 nit: no blank line here.
Lei Zhang 2016/01/06 00:40:34 Done.
146 CPWL_Point pts[num * 3] = {// 1 161 pts[i][j].y *= fHeight;
147 CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f), 162 pts[i][j].y += crBBox.bottom;
148 CPWL_Point(0.29f, 0.40f), 163 }
149
150 // 2
151 CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f),
152 CPWL_Point(0.31f, 0.28f),
153
154 // 3
155 CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f),
156 CPWL_Point(0.77f, 0.67f),
157
158 // 4
159 CPWL_Point(0.76f, 0.68f), CPWL_Point(0.78f, 0.69f),
160 CPWL_Point(0.76f, 0.75f),
161
162 // 5
163 CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f),
164 CPWL_Point(0.68f, 0.75f),
165
166 // 6
167 CPWL_Point(0.68f, 0.74f), CPWL_Point(0.68f, 0.74f),
168 CPWL_Point(0.44f, 0.47f),
169
170 // 7
171 CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f),
172 CPWL_Point(0.41f, 0.58f),
173
174 // 8
175 CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
176 CPWL_Point(0.30f, 0.56f)};
177
178 for (int32_t j = 0; j < num * 3; j++) {
179 pts[j].x *= fWidth;
180 pts[j].x += crBBox.left;
181
182 pts[j].y *= fHeight;
183 pts[j].y += crBBox.bottom;
184 } 164 }
185 165
186 csAP << pts[0].x << " " << pts[0].y << " m\n"; 166 CFX_ByteTextBuf csAP;
167 csAP << pts[0][0].x << " " << pts[0][0].y << " m\n";
187 168
188 for (int32_t i = 0; i < num; i++) { 169 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
189 int32_t nCur = i * 3; 170 size_t nNext = i < FX_ArraySize(pts) - 1 ? i + 1 : 0;
190 int32_t n1 = i * 3 + 1;
191 int32_t n2 = i * 3 + 2;
192 int32_t nNext = (i < num - 1 ? (i + 1) * 3 : 0);
193 171
194 FX_FLOAT px1 = pts[n1].x - pts[nCur].x; 172 FX_FLOAT px1 = pts[i][1].x - pts[i][0].x;
195 FX_FLOAT py1 = pts[n1].y - pts[nCur].y; 173 FX_FLOAT py1 = pts[i][1].y - pts[i][0].y;
196 FX_FLOAT px2 = pts[n2].x - pts[nNext].x; 174 FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x;
197 FX_FLOAT py2 = pts[n2].y - pts[nNext].y; 175 FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y;
198 176
199 csAP << pts[nCur].x + px1 * PWL_BEZIER << " " 177 csAP << pts[i][0].x + px1 * PWL_BEZIER << " "
200 << pts[nCur].y + py1 * PWL_BEZIER << " " 178 << pts[i][0].y + py1 * PWL_BEZIER << " "
201 << pts[nNext].x + px2 * PWL_BEZIER << " " 179 << pts[nNext][0].x + px2 * PWL_BEZIER << " "
202 << pts[nNext].y + py2 * PWL_BEZIER << " " << pts[nNext].x << " " 180 << pts[nNext][0].y + py2 * PWL_BEZIER << " " << pts[nNext][0].x << " "
203 << pts[nNext].y << " c\n"; 181 << pts[nNext][0].y << " c\n";
204 } 182 }
205 183
206 return csAP.GetByteString(); 184 return csAP.GetByteString();
207 } 185 }
208 186
209 CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect& crBBox) { 187 CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect& crBBox) {
210 CFX_ByteTextBuf csAP; 188 CFX_ByteTextBuf csAP;
211 189
212 FX_FLOAT fWidth = crBBox.right - crBBox.left; 190 FX_FLOAT fWidth = crBBox.right - crBBox.left;
213 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; 191 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 else 2309 else
2332 GetPathDataFromArray(path, PathArray, 30); 2310 GetPathDataFromArray(path, PathArray, 30);
2333 } 2311 }
2334 2312
2335 void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, 2313 void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData,
2336 CFX_PathData& path, 2314 CFX_PathData& path,
2337 const CPDF_Rect& crBBox, 2315 const CPDF_Rect& crBBox,
2338 const PWL_PATH_TYPE type) { 2316 const PWL_PATH_TYPE type) {
2339 FX_FLOAT fWidth = crBBox.right - crBBox.left; 2317 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2340 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; 2318 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
2341 // FX_FLOAT fcatercorner = (FX_FLOAT)sqrt(fWidth*fWidth + fHeight*fHeight);
2342 CPWL_Point center_point(crBBox.left + fWidth / 2, 2319 CPWL_Point center_point(crBBox.left + fWidth / 2,
2343 crBBox.bottom + fHeight / 2); 2320 crBBox.bottom + fHeight / 2);
2344 2321
2345 CPWL_PathData PathArray[] = { 2322 CPWL_PathData PathArray[] = {
2346 CPWL_PathData( 2323 CPWL_PathData(
2347 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f), 2324 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
2348 PWLPT_MOVETO), 2325 PWLPT_MOVETO),
2349 CPWL_PathData( 2326 CPWL_PathData(
2350 CPWL_Point(center_point.x + fWidth * 0.3f, 2327 CPWL_Point(center_point.x + fWidth * 0.3f,
2351 center_point.y + fHeight / 10.0f + fWidth * 0.3f), 2328 center_point.y + fHeight / 10.0f + fWidth * 0.3f),
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 break; 3678 break;
3702 case COLORTYPE_RGB: 3679 case COLORTYPE_RGB:
3703 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, 3680 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
3704 fColor1, fColor2, fColor3); 3681 fColor1, fColor2, fColor3);
3705 break; 3682 break;
3706 } 3683 }
3707 break; 3684 break;
3708 } 3685 }
3709 nColorType = other_nColorType; 3686 nColorType = other_nColorType;
3710 } 3687 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Wnd.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698