Chromium Code Reviews| 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 "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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 CFX_ByteTextBuf csAP; |
| 140 | 137 |
| 141 FX_FLOAT fWidth = crBBox.right - crBBox.left; | 138 FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 142 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; | 139 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
| 143 | 140 |
| 144 const int32_t num = 8; | 141 const int32_t num = 8; |
| 145 | 142 |
| 146 CPWL_Point pts[num * 3] = {// 1 | 143 CPWL_Point pts[num * 3] = { |
|
Tom Sepez
2016/01/04 20:23:12
nit: (for someday downe th road) I'd be happier if
Lei Zhang
2016/01/05 02:27:09
Done. Today is some day.
| |
| 147 CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f), | 144 CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f), |
| 148 CPWL_Point(0.29f, 0.40f), | 145 CPWL_Point(0.29f, 0.40f), CPWL_Point(0.30f, 0.33f), |
| 149 | 146 CPWL_Point(0.31f, 0.29f), CPWL_Point(0.31f, 0.28f), |
| 150 // 2 | 147 CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f), |
| 151 CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f), | 148 CPWL_Point(0.77f, 0.67f), CPWL_Point(0.76f, 0.68f), |
| 152 CPWL_Point(0.31f, 0.28f), | 149 CPWL_Point(0.78f, 0.69f), CPWL_Point(0.76f, 0.75f), |
| 153 | 150 CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f), |
| 154 // 3 | 151 CPWL_Point(0.68f, 0.75f), CPWL_Point(0.68f, 0.74f), |
| 155 CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f), | 152 CPWL_Point(0.68f, 0.74f), CPWL_Point(0.44f, 0.47f), |
| 156 CPWL_Point(0.77f, 0.67f), | 153 CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f), |
| 157 | 154 CPWL_Point(0.41f, 0.58f), CPWL_Point(0.40f, 0.60f), |
| 158 // 4 | 155 CPWL_Point(0.28f, 0.66f), CPWL_Point(0.30f, 0.56f)}; |
| 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 | 156 |
| 178 for (int32_t j = 0; j < num * 3; j++) { | 157 for (int32_t j = 0; j < num * 3; j++) { |
| 179 pts[j].x *= fWidth; | 158 pts[j].x *= fWidth; |
| 180 pts[j].x += crBBox.left; | 159 pts[j].x += crBBox.left; |
| 181 | 160 |
| 182 pts[j].y *= fHeight; | 161 pts[j].y *= fHeight; |
| 183 pts[j].y += crBBox.bottom; | 162 pts[j].y += crBBox.bottom; |
| 184 } | 163 } |
| 185 | 164 |
| 186 csAP << pts[0].x << " " << pts[0].y << " m\n"; | 165 csAP << pts[0].x << " " << pts[0].y << " m\n"; |
| (...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2331 else | 2310 else |
| 2332 GetPathDataFromArray(path, PathArray, 30); | 2311 GetPathDataFromArray(path, PathArray, 30); |
| 2333 } | 2312 } |
| 2334 | 2313 |
| 2335 void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, | 2314 void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, |
| 2336 CFX_PathData& path, | 2315 CFX_PathData& path, |
| 2337 const CPDF_Rect& crBBox, | 2316 const CPDF_Rect& crBBox, |
| 2338 const PWL_PATH_TYPE type) { | 2317 const PWL_PATH_TYPE type) { |
| 2339 FX_FLOAT fWidth = crBBox.right - crBBox.left; | 2318 FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2340 FX_FLOAT fHeight = crBBox.top - crBBox.bottom; | 2319 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, | 2320 CPWL_Point center_point(crBBox.left + fWidth / 2, |
| 2343 crBBox.bottom + fHeight / 2); | 2321 crBBox.bottom + fHeight / 2); |
| 2344 | 2322 |
| 2345 CPWL_PathData PathArray[] = { | 2323 CPWL_PathData PathArray[] = { |
| 2346 CPWL_PathData( | 2324 CPWL_PathData( |
| 2347 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f), | 2325 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f), |
| 2348 PWLPT_MOVETO), | 2326 PWLPT_MOVETO), |
| 2349 CPWL_PathData( | 2327 CPWL_PathData( |
| 2350 CPWL_Point(center_point.x + fWidth * 0.3f, | 2328 CPWL_Point(center_point.x + fWidth * 0.3f, |
| 2351 center_point.y + fHeight / 10.0f + fWidth * 0.3f), | 2329 center_point.y + fHeight / 10.0f + fWidth * 0.3f), |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3701 break; | 3679 break; |
| 3702 case COLORTYPE_RGB: | 3680 case COLORTYPE_RGB: |
| 3703 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, | 3681 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, |
| 3704 fColor1, fColor2, fColor3); | 3682 fColor1, fColor2, fColor3); |
| 3705 break; | 3683 break; |
| 3706 } | 3684 } |
| 3707 break; | 3685 break; |
| 3708 } | 3686 } |
| 3709 nColorType = other_nColorType; | 3687 nColorType = other_nColorType; |
| 3710 } | 3688 } |
| OLD | NEW |