OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBitmapProcState_MatrixTemplates_DEFINED | 8 #ifndef SkBitmapProcState_MatrixTemplates_DEFINED |
9 #define SkBitmapProcState_MatrixTemplates_DEFINED | 9 #define SkBitmapProcState_MatrixTemplates_DEFINED |
10 | 10 |
11 #include "SkMath.h" | 11 #include "SkMath.h" |
12 #include "SkMathPriv.h" | 12 #include "SkMathPriv.h" |
13 | 13 |
14 template <typename TileProc, bool tryDecal> | 14 template <typename TileProc, bool tryDecal> |
15 void NoFilterProc_Scale(const SkBitmapProcState& s, uint32_t xy[], | 15 void NoFilterProc_Scale(const SkBitmapProcState& s, uint32_t xy[], |
16 int count, int x, int y) { | 16 int count, int x, int y) { |
17 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 17 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
18 SkMatrix::kScale_Mask)) == 0); | 18 SkMatrix::kScale_Mask)) == 0); |
19 | 19 |
20 // we store y, x, x, x, x, x | 20 // we store y, x, x, x, x, x |
21 | 21 |
22 const unsigned maxX = s.fPixmap.width() - 1; | 22 const unsigned maxX = s.fPixmap.width() - 1; |
23 SkFractionalInt fx; | 23 SkFractionalInt fx; |
24 { | 24 { |
25 SkPoint pt; | 25 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
26 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | |
27 SkIntToScalar(y) + SK_ScalarHalf, &pt); | |
28 fx = SkScalarToFractionalInt(pt.fY); | |
29 const unsigned maxY = s.fPixmap.height() - 1; | 26 const unsigned maxY = s.fPixmap.height() - 1; |
30 *xy++ = TileProc::Y(s, SkFractionalIntToFixed(fx), maxY); | 27 *xy++ = TileProc::Y(s, SkFractionalIntToFixed(mapper.y()), maxY); |
31 fx = SkScalarToFractionalInt(pt.fX); | 28 fx = mapper.x(); |
32 } | 29 } |
33 | 30 |
34 if (0 == maxX) { | 31 if (0 == maxX) { |
35 // all of the following X values must be 0 | 32 // all of the following X values must be 0 |
36 memset(xy, 0, count * sizeof(uint16_t)); | 33 memset(xy, 0, count * sizeof(uint16_t)); |
37 return; | 34 return; |
38 } | 35 } |
39 | 36 |
40 const SkFractionalInt dx = s.fInvSxFractionalInt; | 37 const SkFractionalInt dx = s.fInvSxFractionalInt; |
41 | 38 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // SCALE's inner loop that only looks at dx | 70 // SCALE's inner loop that only looks at dx |
74 | 71 |
75 template <typename TileProc> | 72 template <typename TileProc> |
76 void NoFilterProc_Affine(const SkBitmapProcState& s, uint32_t xy[], | 73 void NoFilterProc_Affine(const SkBitmapProcState& s, uint32_t xy[], |
77 int count, int x, int y) { | 74 int count, int x, int y) { |
78 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 75 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
79 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 76 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
80 SkMatrix::kScale_Mask | | 77 SkMatrix::kScale_Mask | |
81 SkMatrix::kAffine_Mask)) == 0); | 78 SkMatrix::kAffine_Mask)) == 0); |
82 | 79 |
83 SkPoint srcPt; | 80 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
84 s.fInvProc(s.fInvMatrix, | |
85 SkIntToScalar(x) + SK_ScalarHalf, | |
86 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | |
87 | 81 |
88 SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); | 82 SkFractionalInt fx = mapper.x(); |
89 SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); | 83 SkFractionalInt fy = mapper.y(); |
90 SkFractionalInt dx = s.fInvSxFractionalInt; | 84 SkFractionalInt dx = s.fInvSxFractionalInt; |
91 SkFractionalInt dy = s.fInvKyFractionalInt; | 85 SkFractionalInt dy = s.fInvKyFractionalInt; |
92 int maxX = s.fPixmap.width() - 1; | 86 int maxX = s.fPixmap.width() - 1; |
93 int maxY = s.fPixmap.height() - 1; | 87 int maxY = s.fPixmap.height() - 1; |
94 | 88 |
95 for (int i = count; i > 0; --i) { | 89 for (int i = count; i > 0; --i) { |
96 *xy++ = (TileProc::Y(s, SkFractionalIntToFixed(fy), maxY) << 16) | | 90 *xy++ = (TileProc::Y(s, SkFractionalIntToFixed(fy), maxY) << 16) | |
97 TileProc::X(s, SkFractionalIntToFixed(fx), maxX); | 91 TileProc::X(s, SkFractionalIntToFixed(fx), maxX); |
98 fx += dx; fy += dy; | 92 fx += dx; fy += dy; |
99 } | 93 } |
(...skipping 15 matching lines...) Expand all Loading... |
115 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 109 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
116 while (--count >= 0) { | 110 while (--count >= 0) { |
117 *xy++ = (TileProc::Y(s, srcXY[1], maxY) << 16) | | 111 *xy++ = (TileProc::Y(s, srcXY[1], maxY) << 16) | |
118 TileProc::X(s, srcXY[0], maxX); | 112 TileProc::X(s, srcXY[0], maxX); |
119 srcXY += 2; | 113 srcXY += 2; |
120 } | 114 } |
121 } | 115 } |
122 } | 116 } |
123 | 117 |
124 #endif | 118 #endif |
OLD | NEW |