Index: skia/ext/convolver.h |
=================================================================== |
--- skia/ext/convolver.h (revision 68621) |
+++ skia/ext/convolver.h (working copy) |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -6,11 +6,13 @@ |
#define SKIA_EXT_CONVOLVER_H_ |
#pragma once |
+#include <cmath> |
#include <vector> |
// avoid confusion with Mac OS X's math library (Carbon) |
#if defined(__APPLE__) |
#undef FloatToFixed |
+#undef FixedToFloat |
#endif |
namespace skia { |
@@ -40,6 +42,13 @@ |
static unsigned char FixedToChar(Fixed x) { |
return static_cast<unsigned char>(x >> kShiftBits); |
} |
+ static float FixedToFloat(Fixed x) { |
+ // The cast relies on Fixed being a short, implying that on |
+ // the platforms we care about all (16) bits will fit into |
+ // the mantissa of a (32-bit) float. |
+ float raw = static_cast<float>(x); |
+ return ldexpf(raw, -kShiftBits); |
+ } |
// Returns the maximum pixel span of a filter. |
int max_filter() const { return max_filter_; } |
@@ -80,7 +89,11 @@ |
const FilterInstance& filter = filters_[value_offset]; |
*filter_offset = filter.offset; |
*filter_length = filter.length; |
- return &filter_values_[filter.data_location]; |
+ if (filter.length == 0) { |
+ return NULL; |
+ } else { |
+ return &filter_values_[filter.data_location]; |
+ } |
} |
private: |
@@ -130,9 +143,9 @@ |
bool source_has_alpha, |
const ConvolutionFilter1D& xfilter, |
const ConvolutionFilter1D& yfilter, |
+ int output_byte_row_stride, |
unsigned char* output); |
} // namespace skia |
#endif // SKIA_EXT_CONVOLVER_H_ |
- |