aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapFilter.h
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-13 15:37:25 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-13 15:37:25 +0000
commitd647426714a96d42faff8ea53464343b29b427cd (patch)
tree317f31d6221f508d0204bf8a01d44f7932198ef5 /src/core/SkBitmapFilter.h
parentfa1bd5f86ceea6cfa8303594730125ad2853d87b (diff)
Reverted 10056-10059
git-svn-id: http://skia.googlecode.com/svn/trunk@10060 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmapFilter.h')
-rw-r--r--src/core/SkBitmapFilter.h31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/core/SkBitmapFilter.h b/src/core/SkBitmapFilter.h
index 38c2448c69..82734200e1 100644
--- a/src/core/SkBitmapFilter.h
+++ b/src/core/SkBitmapFilter.h
@@ -22,26 +22,23 @@ class SkBitmapFilter {
public:
SkBitmapFilter(float width)
: fWidth(width), fInvWidth(1.f/width) {
- fPrecomputed = false;
- fLookupMultiplier = this->invWidth() * (SKBITMAP_FILTER_TABLE_SIZE-1);
+ precomputed = false;
}
SkFixed lookup( float x ) const {
- if (!fPrecomputed) {
+ if (!precomputed) {
precomputeTable();
}
- int filter_idx = int(sk_float_abs(x * fLookupMultiplier));
- SkASSERT(filter_idx < SKBITMAP_FILTER_TABLE_SIZE);
- return fFilterTable[ filter_idx ];
+ int filter_idx = int(fabsf(x * invWidth() * SKBITMAP_FILTER_TABLE_SIZE));
+ return fFilterTable[ SkTMin(filter_idx, SKBITMAP_FILTER_TABLE_SIZE-1) ];
}
- SkScalar lookupScalar( float x ) const {
- if (!fPrecomputed) {
+ float lookupFloat( float x ) const {
+ if (!precomputed) {
precomputeTable();
}
- int filter_idx = int(sk_float_abs(x * fLookupMultiplier));
- SkASSERT(filter_idx < SKBITMAP_FILTER_TABLE_SIZE);
- return fFilterTableScalar[ filter_idx ];
+ int filter_idx = int(fabsf(x * invWidth() * SKBITMAP_FILTER_TABLE_SIZE));
+ return fFilterTableFloat[ SkTMin(filter_idx, SKBITMAP_FILTER_TABLE_SIZE-1) ];
}
float width() const { return fWidth; }
@@ -52,20 +49,18 @@ class SkBitmapFilter {
float fWidth;
float fInvWidth;
- float fLookupMultiplier;
-
- mutable bool fPrecomputed;
+ mutable bool precomputed;
mutable SkFixed fFilterTable[SKBITMAP_FILTER_TABLE_SIZE];
- mutable SkScalar fFilterTableScalar[SKBITMAP_FILTER_TABLE_SIZE];
+ mutable float fFilterTableFloat[SKBITMAP_FILTER_TABLE_SIZE];
private:
void precomputeTable() const {
- fPrecomputed = true;
+ precomputed = true;
SkFixed *ftp = fFilterTable;
- SkScalar *ftpScalar = fFilterTableScalar;
+ float *ftp_float = fFilterTableFloat;
for (int x = 0; x < SKBITMAP_FILTER_TABLE_SIZE; ++x) {
float fx = ((float)x + .5f) * this->width() / SKBITMAP_FILTER_TABLE_SIZE;
float filter_value = evaluate(fx);
- *ftpScalar++ = SkFloatToScalar(filter_value);
+ *ftp_float++ = filter_value;
*ftp++ = SkFloatToFixed(filter_value);
}
}