| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkMath.h" | 9 #include "SkMath.h" |
| 10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SCALE_FILTER_NAME(const SkBitmapProcState& s, | 50 void SCALE_FILTER_NAME(const SkBitmapProcState& s, |
| 51 uint32_t xy[], int count, int x, int y) { | 51 uint32_t xy[], int count, int x, int y) { |
| 52 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 52 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 53 SkMatrix::kScale_Mask)) == 0); | 53 SkMatrix::kScale_Mask)) == 0); |
| 54 SkASSERT(s.fInvKy == 0); | 54 SkASSERT(s.fInvKy == 0); |
| 55 | 55 |
| 56 PREAMBLE(s); | 56 PREAMBLE(s); |
| 57 | 57 |
| 58 const unsigned maxX = s.fBitmap->width() - 1; | 58 const unsigned maxX = s.fPixmap.width() - 1; |
| 59 const SkFixed one = s.fFilterOneX; | 59 const SkFixed one = s.fFilterOneX; |
| 60 const SkFractionalInt dx = s.fInvSxFractionalInt; | 60 const SkFractionalInt dx = s.fInvSxFractionalInt; |
| 61 SkFractionalInt fx; | 61 SkFractionalInt fx; |
| 62 | 62 |
| 63 { | 63 { |
| 64 SkPoint pt; | 64 SkPoint pt; |
| 65 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 65 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
| 66 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 66 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
| 67 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); | 67 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); |
| 68 const unsigned maxY = s.fBitmap->height() - 1; | 68 const unsigned maxY = s.fPixmap.height() - 1; |
| 69 // compute our two Y values up front | 69 // compute our two Y values up front |
| 70 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); | 70 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); |
| 71 // now initialize fx | 71 // now initialize fx |
| 72 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; | 72 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; |
| 73 } | 73 } |
| 74 | 74 |
| 75 #ifdef CHECK_FOR_DECAL | 75 #ifdef CHECK_FOR_DECAL |
| 76 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { | 76 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { |
| 77 decal_filter_scale(xy, SkFractionalIntToFixed(fx), | 77 decal_filter_scale(xy, SkFractionalIntToFixed(fx), |
| 78 SkFractionalIntToFixed(dx), count); | 78 SkFractionalIntToFixed(dx), count); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 99 s.fInvProc(s.fInvMatrix, | 99 s.fInvProc(s.fInvMatrix, |
| 100 SkIntToScalar(x) + SK_ScalarHalf, | 100 SkIntToScalar(x) + SK_ScalarHalf, |
| 101 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 101 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 102 | 102 |
| 103 SkFixed oneX = s.fFilterOneX; | 103 SkFixed oneX = s.fFilterOneX; |
| 104 SkFixed oneY = s.fFilterOneY; | 104 SkFixed oneY = s.fFilterOneY; |
| 105 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); | 105 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); |
| 106 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); | 106 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); |
| 107 SkFixed dx = s.fInvSx; | 107 SkFixed dx = s.fInvSx; |
| 108 SkFixed dy = s.fInvKy; | 108 SkFixed dy = s.fInvKy; |
| 109 unsigned maxX = s.fBitmap->width() - 1; | 109 unsigned maxX = s.fPixmap.width() - 1; |
| 110 unsigned maxY = s.fBitmap->height() - 1; | 110 unsigned maxY = s.fPixmap.height() - 1; |
| 111 | 111 |
| 112 do { | 112 do { |
| 113 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y); | 113 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y); |
| 114 fy += dy; | 114 fy += dy; |
| 115 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X); | 115 *xy++ = PACK_FILTER_X_NAME(fx, maxX, oneX PREAMBLE_ARG_X); |
| 116 fx += dx; | 116 fx += dx; |
| 117 } while (--count != 0); | 117 } while (--count != 0); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void PERSP_FILTER_NAME(const SkBitmapProcState& s, | 120 void PERSP_FILTER_NAME(const SkBitmapProcState& s, |
| 121 uint32_t* SK_RESTRICT xy, int count, | 121 uint32_t* SK_RESTRICT xy, int count, |
| 122 int x, int y) { | 122 int x, int y) { |
| 123 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); | 123 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); |
| 124 | 124 |
| 125 PREAMBLE(s); | 125 PREAMBLE(s); |
| 126 unsigned maxX = s.fBitmap->width() - 1; | 126 unsigned maxX = s.fPixmap.width() - 1; |
| 127 unsigned maxY = s.fBitmap->height() - 1; | 127 unsigned maxY = s.fPixmap.height() - 1; |
| 128 SkFixed oneX = s.fFilterOneX; | 128 SkFixed oneX = s.fFilterOneX; |
| 129 SkFixed oneY = s.fFilterOneY; | 129 SkFixed oneY = s.fFilterOneY; |
| 130 | 130 |
| 131 SkPerspIter iter(s.fInvMatrix, | 131 SkPerspIter iter(s.fInvMatrix, |
| 132 SkIntToScalar(x) + SK_ScalarHalf, | 132 SkIntToScalar(x) + SK_ScalarHalf, |
| 133 SkIntToScalar(y) + SK_ScalarHalf, count); | 133 SkIntToScalar(y) + SK_ScalarHalf, count); |
| 134 | 134 |
| 135 while ((count = iter.next()) != 0) { | 135 while ((count = iter.next()) != 0) { |
| 136 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 136 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
| 137 do { | 137 do { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 156 #undef PERSP_FILTER_NAME | 156 #undef PERSP_FILTER_NAME |
| 157 | 157 |
| 158 #undef PREAMBLE | 158 #undef PREAMBLE |
| 159 #undef PREAMBLE_PARAM_X | 159 #undef PREAMBLE_PARAM_X |
| 160 #undef PREAMBLE_PARAM_Y | 160 #undef PREAMBLE_PARAM_Y |
| 161 #undef PREAMBLE_ARG_X | 161 #undef PREAMBLE_ARG_X |
| 162 #undef PREAMBLE_ARG_Y | 162 #undef PREAMBLE_ARG_Y |
| 163 | 163 |
| 164 #undef TILEX_LOW_BITS | 164 #undef TILEX_LOW_BITS |
| 165 #undef TILEY_LOW_BITS | 165 #undef TILEY_LOW_BITS |
| OLD | NEW |