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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/FloatQuad.cpp

Issue 2733503002: Fix the conditional operator's usage (Closed)
Patch Set: add unittests. Created 3 years, 9 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 | third_party/WebKit/Source/platform/geometry/FloatQuadTest.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com) 4 * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 float u = (dot11 * dot02 - dot01 * dot12) * invDenom; 75 float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
76 float v = (dot00 * dot12 - dot01 * dot02) * invDenom; 76 float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
77 77
78 // Check if point is in triangle 78 // Check if point is in triangle
79 return (u >= 0) && (v >= 0) && (u + v <= 1); 79 return (u >= 0) && (v >= 0) && (u + v <= 1);
80 } 80 }
81 81
82 static inline float saturateInf(float value) { 82 static inline float saturateInf(float value) {
83 if (UNLIKELY(std::isinf(value))) { 83 if (UNLIKELY(std::isinf(value))) {
84 return std::signbit(value) ? std::numeric_limits<int>::min() 84 return std::signbit(value) ? std::numeric_limits<int>::min()
85 : std::numeric_limits<int>::min(); 85 : std::numeric_limits<int>::max();
86 } 86 }
87 return value; 87 return value;
88 } 88 }
89 89
90 FloatRect FloatQuad::boundingBox() const { 90 FloatRect FloatQuad::boundingBox() const {
91 float left = saturateInf(min4(m_p1.x(), m_p2.x(), m_p3.x(), m_p4.x())); 91 float left = saturateInf(min4(m_p1.x(), m_p2.x(), m_p3.x(), m_p4.x()));
92 float top = saturateInf(min4(m_p1.y(), m_p2.y(), m_p3.y(), m_p4.y())); 92 float top = saturateInf(min4(m_p1.y(), m_p2.y(), m_p3.y(), m_p4.y()));
93 93
94 float right = saturateInf(max4(m_p1.x(), m_p2.x(), m_p3.x(), m_p4.x())); 94 float right = saturateInf(max4(m_p1.x(), m_p2.x(), m_p3.x(), m_p4.x()));
95 float bottom = saturateInf(max4(m_p1.y(), m_p2.y(), m_p3.y(), m_p4.y())); 95 float bottom = saturateInf(max4(m_p1.y(), m_p2.y(), m_p3.y(), m_p4.y()));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 254
255 String FloatQuad::toString() const { 255 String FloatQuad::toString() const {
256 return String::format("%s; %s; %s; %s", m_p1.toString().ascii().data(), 256 return String::format("%s; %s; %s; %s", m_p1.toString().ascii().data(),
257 m_p2.toString().ascii().data(), 257 m_p2.toString().ascii().data(),
258 m_p3.toString().ascii().data(), 258 m_p3.toString().ascii().data(),
259 m_p4.toString().ascii().data()); 259 m_p4.toString().ascii().data());
260 } 260 }
261 261
262 } // namespace blink 262 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/geometry/FloatQuadTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698