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

Side by Side Diff: xfa/src/fxgraphics/src/fx_graphics.cpp

Issue 1727793002: Remove FXSYS_Div. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 10 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 | « third_party/agg23/agg_math_stroke.h ('k') | xfa/src/fxgraphics/src/fx_path_generator.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 <memory> 7 #include <memory>
8 8
9 #include "xfa/src/fxgraphics/src/fx_path_generator.h" 9 #include "xfa/src/fxgraphics/src/fx_path_generator.h"
10 #include "xfa/src/fxgraphics/src/pre.h" 10 #include "xfa/src/fxgraphics/src/pre.h"
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 case FX_SHADING_Axial: { 971 case FX_SHADING_Axial: {
972 FX_FLOAT x_span = end_x - start_x; 972 FX_FLOAT x_span = end_x - start_x;
973 FX_FLOAT y_span = end_y - start_y; 973 FX_FLOAT y_span = end_y - start_y;
974 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); 974 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
975 for (int32_t row = 0; row < height; row++) { 975 for (int32_t row = 0; row < height; row++) {
976 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); 976 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch);
977 for (int32_t column = 0; column < width; column++) { 977 for (int32_t column = 0; column < width; column++) {
978 FX_FLOAT x = (FX_FLOAT)(column); 978 FX_FLOAT x = (FX_FLOAT)(column);
979 FX_FLOAT y = (FX_FLOAT)(row); 979 FX_FLOAT y = (FX_FLOAT)(row);
980 FX_FLOAT scale = 980 FX_FLOAT scale =
981 FXSYS_Div(((x - start_x) * x_span) + ((y - start_y) * y_span), 981 (((x - start_x) * x_span) + ((y - start_y) * y_span)) /
982 axis_len_square); 982 axis_len_square;
983 if (scale < 0) { 983 if (scale < 0) {
984 if (!_info._fillColor->_shading->_isExtendedBegin) { 984 if (!_info._fillColor->_shading->_isExtendedBegin) {
985 continue; 985 continue;
986 } 986 }
987 scale = 0; 987 scale = 0;
988 } else if (scale > 1.0f) { 988 } else if (scale > 1.0f) {
989 if (!_info._fillColor->_shading->_isExtendedEnd) { 989 if (!_info._fillColor->_shading->_isExtendedEnd) {
990 continue; 990 continue;
991 } 991 }
992 scale = 1.0f; 992 scale = 1.0f;
(...skipping 16 matching lines...) Expand all
1009 for (int32_t column = 0; column < width; column++) { 1009 for (int32_t column = 0; column < width; column++) {
1010 FX_FLOAT x = (FX_FLOAT)(column); 1010 FX_FLOAT x = (FX_FLOAT)(column);
1011 FX_FLOAT y = (FX_FLOAT)(row); 1011 FX_FLOAT y = (FX_FLOAT)(row);
1012 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + 1012 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) +
1013 ((y - start_y) * (end_y - start_y)) + 1013 ((y - start_y) * (end_y - start_y)) +
1014 (start_r * (end_r - start_r))); 1014 (start_r * (end_r - start_r)));
1015 FX_FLOAT c = ((x - start_x) * (x - start_x)) + 1015 FX_FLOAT c = ((x - start_x) * (x - start_x)) +
1016 ((y - start_y) * (y - start_y)) - (start_r * start_r); 1016 ((y - start_y) * (y - start_y)) - (start_r * start_r);
1017 FX_FLOAT s; 1017 FX_FLOAT s;
1018 if (a == 0) { 1018 if (a == 0) {
1019 s = (FXSYS_Div(-c, b)); 1019 s = -c / b;
1020 } else { 1020 } else {
1021 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); 1021 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c);
1022 if (b2_4ac < 0) { 1022 if (b2_4ac < 0) {
1023 continue; 1023 continue;
1024 } 1024 }
1025 FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); 1025 FX_FLOAT root = (FXSYS_sqrt(b2_4ac));
1026 FX_FLOAT s1, s2; 1026 FX_FLOAT s1, s2;
1027 if (a > 0) { 1027 if (a > 0) {
1028 s1 = FXSYS_Div(-b - root, 2 * a); 1028 s1 = (-b - root) / (2 * a);
1029 s2 = FXSYS_Div(-b + root, 2 * a); 1029 s2 = (-b + root) / (2 * a);
1030 } else { 1030 } else {
1031 s2 = FXSYS_Div(-b - root, 2 * a); 1031 s2 = (-b - root) / (2 * a);
1032 s1 = FXSYS_Div(-b + root, 2 * a); 1032 s1 = (-b + root) / (2 * a);
1033 } 1033 }
1034 if (s2 <= 1.0f || _info._fillColor->_shading->_isExtendedEnd) { 1034 if (s2 <= 1.0f || _info._fillColor->_shading->_isExtendedEnd) {
1035 s = (s2); 1035 s = (s2);
1036 } else { 1036 } else {
1037 s = (s1); 1037 s = (s1);
1038 } 1038 }
1039 if ((start_r) + s * (end_r - start_r) < 0) { 1039 if ((start_r) + s * (end_r - start_r) < 0) {
1040 continue; 1040 continue;
1041 } 1041 }
1042 } 1042 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 b3 = (int32_t)(i * bScale); 1449 b3 = (int32_t)(i * bScale);
1450 _argbArray[i] = 1450 _argbArray[i] =
1451 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3))); 1451 FXARGB_TODIB(FXARGB_MAKE((a1 + a3), (r1 + r3), (g1 + g3), (b1 + b3)));
1452 } 1452 }
1453 return FX_ERR_Succeeded; 1453 return FX_ERR_Succeeded;
1454 } 1454 }
1455 class CFX_Pause : public IFX_Pause { 1455 class CFX_Pause : public IFX_Pause {
1456 public: 1456 public:
1457 virtual FX_BOOL NeedToPauseNow() { return TRUE; } 1457 virtual FX_BOOL NeedToPauseNow() { return TRUE; }
1458 }; 1458 };
OLDNEW
« no previous file with comments | « third_party/agg23/agg_math_stroke.h ('k') | xfa/src/fxgraphics/src/fx_path_generator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698