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

Side by Side Diff: cc/output/filter_operation.cc

Issue 22875045: cc: Remove unnecessary "default" cases from switch statements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix HasFilterThatMovesPixels()/HasFilterThatAffectsOpacity() Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/output/filter_operations.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/output/filter_operation.h" 9 #include "cc/output/filter_operation.h"
10 #include "third_party/skia/include/core/SkMath.h" 10 #include "third_party/skia/include/core/SkMath.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 case FilterOperation::COLOR_MATRIX: { 140 case FilterOperation::COLOR_MATRIX: {
141 SkScalar matrix[20]; 141 SkScalar matrix[20];
142 memset(matrix, 0, 20 * sizeof(SkScalar)); 142 memset(matrix, 0, 20 * sizeof(SkScalar));
143 matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1.f; 143 matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1.f;
144 return FilterOperation::CreateColorMatrixFilter(matrix); 144 return FilterOperation::CreateColorMatrixFilter(matrix);
145 } 145 }
146 case FilterOperation::ZOOM: 146 case FilterOperation::ZOOM:
147 return FilterOperation::CreateZoomFilter(1.f, 0); 147 return FilterOperation::CreateZoomFilter(1.f, 0);
148 case FilterOperation::SATURATING_BRIGHTNESS: 148 case FilterOperation::SATURATING_BRIGHTNESS:
149 return FilterOperation::CreateSaturatingBrightnessFilter(0.f); 149 return FilterOperation::CreateSaturatingBrightnessFilter(0.f);
150 default:
151 NOTREACHED();
152 return FilterOperation::CreateEmptyFilter();
153 } 150 }
151 NOTREACHED();
152 return FilterOperation::CreateEmptyFilter();
154 } 153 }
155 154
156 static float ClampAmountForFilterType(float amount, 155 static float ClampAmountForFilterType(float amount,
157 FilterOperation::FilterType type) { 156 FilterOperation::FilterType type) {
158 switch (type) { 157 switch (type) {
159 case FilterOperation::GRAYSCALE: 158 case FilterOperation::GRAYSCALE:
160 case FilterOperation::SEPIA: 159 case FilterOperation::SEPIA:
161 case FilterOperation::INVERT: 160 case FilterOperation::INVERT:
162 case FilterOperation::OPACITY: 161 case FilterOperation::OPACITY:
163 return MathUtil::ClampToRange(amount, 0.f, 1.f); 162 return MathUtil::ClampToRange(amount, 0.f, 1.f);
164 case FilterOperation::SATURATE: 163 case FilterOperation::SATURATE:
165 case FilterOperation::BRIGHTNESS: 164 case FilterOperation::BRIGHTNESS:
166 case FilterOperation::CONTRAST: 165 case FilterOperation::CONTRAST:
167 case FilterOperation::BLUR: 166 case FilterOperation::BLUR:
168 case FilterOperation::DROP_SHADOW: 167 case FilterOperation::DROP_SHADOW:
169 return std::max(amount, 0.f); 168 return std::max(amount, 0.f);
170 case FilterOperation::ZOOM: 169 case FilterOperation::ZOOM:
171 return std::max(amount, 1.f); 170 return std::max(amount, 1.f);
172 case FilterOperation::HUE_ROTATE: 171 case FilterOperation::HUE_ROTATE:
173 case FilterOperation::SATURATING_BRIGHTNESS: 172 case FilterOperation::SATURATING_BRIGHTNESS:
174 return amount; 173 return amount;
175 case FilterOperation::COLOR_MATRIX: 174 case FilterOperation::COLOR_MATRIX:
176 default:
177 NOTREACHED(); 175 NOTREACHED();
178 return amount; 176 return amount;
179 } 177 }
178 NOTREACHED();
179 return amount;
180 } 180 }
181 181
182 // static 182 // static
183 FilterOperation FilterOperation::Blend(const FilterOperation* from, 183 FilterOperation FilterOperation::Blend(const FilterOperation* from,
184 const FilterOperation* to, 184 const FilterOperation* to,
185 double progress) { 185 double progress) {
186 FilterOperation blended_filter = FilterOperation::CreateEmptyFilter(); 186 FilterOperation blended_filter = FilterOperation::CreateEmptyFilter();
187 187
188 if (!from && !to) 188 if (!from && !to)
189 return blended_filter; 189 return blended_filter;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 248 }
249 case FilterOperation::ZOOM: 249 case FilterOperation::ZOOM:
250 value->SetDouble("amount", amount_); 250 value->SetDouble("amount", amount_);
251 value->SetDouble("inset", zoom_inset_); 251 value->SetDouble("inset", zoom_inset_);
252 break; 252 break;
253 } 253 }
254 return value.PassAs<base::Value>(); 254 return value.PassAs<base::Value>();
255 } 255 }
256 256
257 } // namespace cc 257 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/output/filter_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698