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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayer.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: Handling that minimumThumbLength > trackLen. 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "public/platform/WebCompositorSupport.h" 51 #include "public/platform/WebCompositorSupport.h"
52 #include "public/platform/WebFilterOperations.h" 52 #include "public/platform/WebFilterOperations.h"
53 #include "public/platform/WebFloatPoint.h" 53 #include "public/platform/WebFloatPoint.h"
54 #include "public/platform/WebFloatRect.h" 54 #include "public/platform/WebFloatRect.h"
55 #include "public/platform/WebLayer.h" 55 #include "public/platform/WebLayer.h"
56 #include "public/platform/WebPoint.h" 56 #include "public/platform/WebPoint.h"
57 #include "public/platform/WebSize.h" 57 #include "public/platform/WebSize.h"
58 #include "wtf/CurrentTime.h" 58 #include "wtf/CurrentTime.h"
59 #include "wtf/HashMap.h" 59 #include "wtf/HashMap.h"
60 #include "wtf/HashSet.h" 60 #include "wtf/HashSet.h"
61 #include "wtf/MathExtras.h"
61 #include "wtf/text/StringUTF8Adaptor.h" 62 #include "wtf/text/StringUTF8Adaptor.h"
62 #include "wtf/text/WTFString.h" 63 #include "wtf/text/WTFString.h"
63 #include <algorithm> 64 #include <algorithm>
65 #include <cmath>
66 #include <utility>
64 67
65 #ifndef NDEBUG 68 #ifndef NDEBUG
66 #include <stdio.h> 69 #include <stdio.h>
67 #endif 70 #endif
68 71
69 namespace blink { 72 namespace blink {
70 73
71 static bool s_drawDebugRedFill = true; 74 static bool s_drawDebugRedFill = true;
72 75
73 // TODO(wangxianzhu): Remove this when we no longer invalidate rects. 76 // TODO(wangxianzhu): Remove this when we no longer invalidate rects.
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } 977 }
975 978
976 void GraphicsLayer::setBackfaceVisibility(bool visible) 979 void GraphicsLayer::setBackfaceVisibility(bool visible)
977 { 980 {
978 m_backfaceVisibility = visible; 981 m_backfaceVisibility = visible;
979 platformLayer()->setDoubleSided(m_backfaceVisibility); 982 platformLayer()->setDoubleSided(m_backfaceVisibility);
980 } 983 }
981 984
982 void GraphicsLayer::setOpacity(float opacity) 985 void GraphicsLayer::setOpacity(float opacity)
983 { 986 {
984 float clampedOpacity = std::max(std::min(opacity, 1.0f), 0.0f); 987 float clampedOpacity = clampTo(opacity, 0.0f, 1.0f);
985 m_opacity = clampedOpacity; 988 m_opacity = clampedOpacity;
986 platformLayer()->setOpacity(opacity); 989 platformLayer()->setOpacity(opacity);
987 } 990 }
988 991
989 void GraphicsLayer::setBlendMode(WebBlendMode blendMode) 992 void GraphicsLayer::setBlendMode(WebBlendMode blendMode)
990 { 993 {
991 if (m_blendMode == blendMode) 994 if (m_blendMode == blendMode)
992 return; 995 return;
993 m_blendMode = blendMode; 996 m_blendMode = blendMode;
994 platformLayer()->setBlendMode(blendMode); 997 platformLayer()->setBlendMode(blendMode);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 { 1247 {
1245 if (!layer) { 1248 if (!layer) {
1246 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1249 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1247 return; 1250 return;
1248 } 1251 }
1249 1252
1250 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1253 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1251 fprintf(stderr, "%s\n", output.utf8().data()); 1254 fprintf(stderr, "%s\n", output.utf8().data());
1252 } 1255 }
1253 #endif 1256 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698