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

Side by Side Diff: core/include/fxcrt/fx_coordinates.h

Issue 433293002: When normalize coordinate, return instead of assert() when divide by 0 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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 | « no previous file | no next file » | 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 #ifndef _FXCRT_COORDINATES_ 7 #ifndef _FXCRT_COORDINATES_
8 #define _FXCRT_COORDINATES_ 8 #define _FXCRT_COORDINATES_
9 template<class baseType> class CFX_PSVTemplate; 9 template<class baseType> class CFX_PSVTemplate;
10 template<class baseType> class CFX_VTemplate; 10 template<class baseType> class CFX_VTemplate;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 { 149 {
150 return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y; 150 return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;
151 } 151 }
152 baseType Length() const 152 baseType Length() const
153 { 153 {
154 return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y); 154 return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);
155 } 155 }
156 void Normalize() 156 void Normalize()
157 { 157 {
158 FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PS V::y); 158 FX_FLOAT fLen = FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PS V::y);
159 FXSYS_assert(fLen >= 0.0001f); 159 if (fLen < 0.0001f) {
Tom Sepez 2014/08/04 17:09:38 Isn't .0001f a kinda large value for near-zero? I'
Bo Xu 2014/08/04 18:48:09 For some fuzz test, the x, and y are set to be rea
160 return;
161 }
160 FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen; 162 FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
161 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen; 163 FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
162 } 164 }
163 baseType DotProduct(baseType x, baseType y) const 165 baseType DotProduct(baseType x, baseType y) const
164 { 166 {
165 return FXT_PSV::x * x + FXT_PSV::y * y; 167 return FXT_PSV::x * x + FXT_PSV::y * y;
166 } 168 }
167 baseType DotProduct(const FXT_VECTOR &v) const 169 baseType DotProduct(const FXT_VECTOR &v) const
168 { 170 {
169 return FXT_PSV::x * v.x + FXT_PSV::y * v.y; 171 return FXT_PSV::x * v.x + FXT_PSV::y * v.y;
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 public: 893 public:
892 FX_FLOAT a; 894 FX_FLOAT a;
893 FX_FLOAT b; 895 FX_FLOAT b;
894 FX_FLOAT c; 896 FX_FLOAT c;
895 FX_FLOAT d; 897 FX_FLOAT d;
896 FX_FLOAT e; 898 FX_FLOAT e;
897 FX_FLOAT f; 899 FX_FLOAT f;
898 }; 900 };
899 #define CFX_AffineMatrix CFX_Matrix 901 #define CFX_AffineMatrix CFX_Matrix
900 #endif 902 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698