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

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

Issue 1729613003: Remove FXSYS_Mul. (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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 FX_FLOAT end_y = _info._fillColor->_shading->_endPoint.y; 964 FX_FLOAT end_y = _info._fillColor->_shading->_endPoint.y;
965 CFX_DIBitmap bmp; 965 CFX_DIBitmap bmp;
966 bmp.Create(width, height, FXDIB_Argb); 966 bmp.Create(width, height, FXDIB_Argb);
967 _renderDevice->GetDIBits(&bmp, 0, 0); 967 _renderDevice->GetDIBits(&bmp, 0, 0);
968 int32_t pitch = bmp.GetPitch(); 968 int32_t pitch = bmp.GetPitch();
969 FX_BOOL result = FALSE; 969 FX_BOOL result = FALSE;
970 switch (_info._fillColor->_shading->_type) { 970 switch (_info._fillColor->_shading->_type) {
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 = 974 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
975 FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_span);
976 for (int32_t row = 0; row < height; row++) { 975 for (int32_t row = 0; row < height; row++) {
977 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); 976 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch);
978 for (int32_t column = 0; column < width; column++) { 977 for (int32_t column = 0; column < width; column++) {
979 FX_FLOAT x = (FX_FLOAT)(column); 978 FX_FLOAT x = (FX_FLOAT)(column);
980 FX_FLOAT y = (FX_FLOAT)(row); 979 FX_FLOAT y = (FX_FLOAT)(row);
981 FX_FLOAT scale = FXSYS_Div( 980 FX_FLOAT scale =
982 FXSYS_Mul(x - start_x, x_span) + FXSYS_Mul(y - start_y, y_span), 981 FXSYS_Div(((x - start_x) * x_span) + ((y - start_y) * y_span),
983 axis_len_square); 982 axis_len_square);
984 if (scale < 0) { 983 if (scale < 0) {
985 if (!_info._fillColor->_shading->_isExtendedBegin) { 984 if (!_info._fillColor->_shading->_isExtendedBegin) {
986 continue; 985 continue;
987 } 986 }
988 scale = 0; 987 scale = 0;
989 } else if (scale > 1.0f) { 988 } else if (scale > 1.0f) {
990 if (!_info._fillColor->_shading->_isExtendedEnd) { 989 if (!_info._fillColor->_shading->_isExtendedEnd) {
991 continue; 990 continue;
992 } 991 }
993 scale = 1.0f; 992 scale = 1.0f;
994 } 993 }
995 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); 994 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1));
996 dib_buf[column] = _info._fillColor->_shading->_argbArray[index]; 995 dib_buf[column] = _info._fillColor->_shading->_argbArray[index];
997 } 996 }
998 } 997 }
999 result = TRUE; 998 result = TRUE;
1000 break; 999 break;
1001 } 1000 }
1002 case FX_SHADING_Radial: { 1001 case FX_SHADING_Radial: {
1003 FX_FLOAT start_r = _info._fillColor->_shading->_beginRadius; 1002 FX_FLOAT start_r = _info._fillColor->_shading->_beginRadius;
1004 FX_FLOAT end_r = _info._fillColor->_shading->_endRadius; 1003 FX_FLOAT end_r = _info._fillColor->_shading->_endRadius;
1005 FX_FLOAT a = FXSYS_Mul(start_x - end_x, start_x - end_x) + 1004 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) +
1006 FXSYS_Mul(start_y - end_y, start_y - end_y) - 1005 ((start_y - end_y) * (start_y - end_y)) -
1007 FXSYS_Mul(start_r - end_r, start_r - end_r); 1006 ((start_r - end_r) * (start_r - end_r));
1008 for (int32_t row = 0; row < height; row++) { 1007 for (int32_t row = 0; row < height; row++) {
1009 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch); 1008 FX_DWORD* dib_buf = (FX_DWORD*)(bmp.GetBuffer() + row * pitch);
1010 for (int32_t column = 0; column < width; column++) { 1009 for (int32_t column = 0; column < width; column++) {
1011 FX_FLOAT x = (FX_FLOAT)(column); 1010 FX_FLOAT x = (FX_FLOAT)(column);
1012 FX_FLOAT y = (FX_FLOAT)(row); 1011 FX_FLOAT y = (FX_FLOAT)(row);
1013 FX_FLOAT b = -2 * (FXSYS_Mul(x - start_x, end_x - start_x) + 1012 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) +
1014 FXSYS_Mul(y - start_y, end_y - start_y) + 1013 ((y - start_y) * (end_y - start_y)) +
1015 FXSYS_Mul(start_r, end_r - start_r)); 1014 (start_r * (end_r - start_r)));
1016 FX_FLOAT c = FXSYS_Mul(x - start_x, x - start_x) + 1015 FX_FLOAT c = ((x - start_x) * (x - start_x)) +
1017 FXSYS_Mul(y - start_y, y - start_y) - 1016 ((y - start_y) * (y - start_y)) - (start_r * start_r);
1018 FXSYS_Mul(start_r, start_r);
1019 FX_FLOAT s; 1017 FX_FLOAT s;
1020 if (a == 0) { 1018 if (a == 0) {
1021 s = (FXSYS_Div(-c, b)); 1019 s = (FXSYS_Div(-c, b));
1022 } else { 1020 } else {
1023 FX_FLOAT b2_4ac = FXSYS_Mul(b, b) - 4 * FXSYS_Mul(a, c); 1021 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c);
1024 if (b2_4ac < 0) { 1022 if (b2_4ac < 0) {
1025 continue; 1023 continue;
1026 } 1024 }
1027 FX_FLOAT root = (FXSYS_sqrt(b2_4ac)); 1025 FX_FLOAT root = (FXSYS_sqrt(b2_4ac));
1028 FX_FLOAT s1, s2; 1026 FX_FLOAT s1, s2;
1029 if (a > 0) { 1027 if (a > 0) {
1030 s1 = FXSYS_Div(-b - root, 2 * a); 1028 s1 = FXSYS_Div(-b - root, 2 * a);
1031 s2 = FXSYS_Div(-b + root, 2 * a); 1029 s2 = FXSYS_Div(-b + root, 2 * a);
1032 } else { 1030 } else {
1033 s2 = FXSYS_Div(-b - root, 2 * a); 1031 s2 = FXSYS_Div(-b - root, 2 * a);
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 b3 = (int32_t)(i * bScale); 1449 b3 = (int32_t)(i * bScale);
1452 _argbArray[i] = 1450 _argbArray[i] =
1453 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)));
1454 } 1452 }
1455 return FX_ERR_Succeeded; 1453 return FX_ERR_Succeeded;
1456 } 1454 }
1457 class CFX_Pause : public IFX_Pause { 1455 class CFX_Pause : public IFX_Pause {
1458 public: 1456 public:
1459 virtual FX_BOOL NeedToPauseNow() { return TRUE; } 1457 virtual FX_BOOL NeedToPauseNow() { return TRUE; }
1460 }; 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