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

Side by Side Diff: skia/ext/convolver.h

Issue 823403002: replace COMPILE_ASSERT with static_assert in skia/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 11 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 | skia/ext/skia_utils_win.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef SKIA_EXT_CONVOLVER_H_ 5 #ifndef SKIA_EXT_CONVOLVER_H_
6 #define SKIA_EXT_CONVOLVER_H_ 6 #define SKIA_EXT_CONVOLVER_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 static Fixed FloatToFixed(float f) { 53 static Fixed FloatToFixed(float f) {
54 return static_cast<Fixed>(f * (1 << kShiftBits)); 54 return static_cast<Fixed>(f * (1 << kShiftBits));
55 } 55 }
56 static unsigned char FixedToChar(Fixed x) { 56 static unsigned char FixedToChar(Fixed x) {
57 return static_cast<unsigned char>(x >> kShiftBits); 57 return static_cast<unsigned char>(x >> kShiftBits);
58 } 58 }
59 static float FixedToFloat(Fixed x) { 59 static float FixedToFloat(Fixed x) {
60 // The cast relies on Fixed being a short, implying that on 60 // The cast relies on Fixed being a short, implying that on
61 // the platforms we care about all (16) bits will fit into 61 // the platforms we care about all (16) bits will fit into
62 // the mantissa of a (32-bit) float. 62 // the mantissa of a (32-bit) float.
63 COMPILE_ASSERT(sizeof(Fixed) == 2, fixed_type_should_fit_in_float_mantissa); 63 static_assert(sizeof(Fixed) == 2,
64 "fixed type should fit in float mantissa");
64 float raw = static_cast<float>(x); 65 float raw = static_cast<float>(x);
65 return ldexpf(raw, -kShiftBits); 66 return ldexpf(raw, -kShiftBits);
66 } 67 }
67 68
68 // Returns the maximum pixel span of a filter. 69 // Returns the maximum pixel span of a filter.
69 int max_filter() const { return max_filter_; } 70 int max_filter() const { return max_filter_; }
70 71
71 // Returns the number of filters in this filter. This is the dimension of the 72 // Returns the number of filters in this filter. This is the dimension of the
72 // output image. 73 // output image.
73 int num_values() const { return static_cast<int>(filters_.size()); } 74 int num_values() const { return static_cast<int>(filters_.size()); }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Set up the |filter| instance with a gaussian kernel. |kernel_sigma| is the 226 // Set up the |filter| instance with a gaussian kernel. |kernel_sigma| is the
226 // parameter of gaussian. If |derivative| is true, the kernel will be that of 227 // parameter of gaussian. If |derivative| is true, the kernel will be that of
227 // the first derivative. Intended for use with the two routines above. 228 // the first derivative. Intended for use with the two routines above.
228 SK_API void SetUpGaussianConvolutionKernel(ConvolutionFilter1D* filter, 229 SK_API void SetUpGaussianConvolutionKernel(ConvolutionFilter1D* filter,
229 float kernel_sigma, 230 float kernel_sigma,
230 bool derivative); 231 bool derivative);
231 232
232 } // namespace skia 233 } // namespace skia
233 234
234 #endif // SKIA_EXT_CONVOLVER_H_ 235 #endif // SKIA_EXT_CONVOLVER_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/skia_utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698