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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 4 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
5 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> 6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
7 * Copyright (C) 2011 University of Szeged 7 * Copyright (C) 2011 University of Szeged
8 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 8 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 14 matching lines...) Expand all
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #include "platform/graphics/filters/SpotLightSource.h" 32 #include "platform/graphics/filters/SpotLightSource.h"
33 33
34 #include "platform/text/TextStream.h" 34 #include "platform/text/TextStream.h"
35 #include <algorithm> 35 #include "wtf/MathExtras.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 bool SpotLightSource::setPosition(const FloatPoint3D& position) 39 bool SpotLightSource::setPosition(const FloatPoint3D& position)
40 { 40 {
41 if (m_position == position) 41 if (m_position == position)
42 return false; 42 return false;
43 m_position = position; 43 m_position = position;
44 return true; 44 return true;
45 } 45 }
46 46
47 bool SpotLightSource::setPointsAt(const FloatPoint3D& direction) 47 bool SpotLightSource::setPointsAt(const FloatPoint3D& direction)
48 { 48 {
49 if (m_direction == direction) 49 if (m_direction == direction)
50 return false; 50 return false;
51 m_direction = direction; 51 m_direction = direction;
52 return true; 52 return true;
53 } 53 }
54 54
55 bool SpotLightSource::setSpecularExponent(float specularExponent) 55 bool SpotLightSource::setSpecularExponent(float specularExponent)
56 { 56 {
57 specularExponent = std::min(std::max(specularExponent, 1.0f), 128.0f); 57 specularExponent = clampTo(specularExponent, 1.0f, 128.0f);
58 if (m_specularExponent == specularExponent) 58 if (m_specularExponent == specularExponent)
59 return false; 59 return false;
60 m_specularExponent = specularExponent; 60 m_specularExponent = specularExponent;
61 return true; 61 return true;
62 } 62 }
63 63
64 bool SpotLightSource::setLimitingConeAngle(float limitingConeAngle) 64 bool SpotLightSource::setLimitingConeAngle(float limitingConeAngle)
65 { 65 {
66 if (m_limitingConeAngle == limitingConeAngle) 66 if (m_limitingConeAngle == limitingConeAngle)
67 return false; 67 return false;
(...skipping 11 matching lines...) Expand all
79 { 79 {
80 ts << "[type=SPOT-LIGHT] "; 80 ts << "[type=SPOT-LIGHT] ";
81 ts << "[position=\"" << position() << "\"]"; 81 ts << "[position=\"" << position() << "\"]";
82 ts << "[direction=\"" << direction() << "\"]"; 82 ts << "[direction=\"" << direction() << "\"]";
83 ts << "[specularExponent=\"" << specularExponent() << "\"]"; 83 ts << "[specularExponent=\"" << specularExponent() << "\"]";
84 ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]"; 84 ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]";
85 return ts; 85 return ts;
86 } 86 }
87 87
88 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698