OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
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 | 9 |
10 #ifndef SkBitmapProcState_DEFINED | 10 #ifndef SkBitmapProcState_DEFINED |
(...skipping 15 matching lines...) Expand all Loading... |
26 typedef SkFixed SkFractionalInt; | 26 typedef SkFixed SkFractionalInt; |
27 #define SkScalarToFractionalInt(x) SkScalarToFixed(x) | 27 #define SkScalarToFractionalInt(x) SkScalarToFixed(x) |
28 #define SkFractionalIntToFixed(x) (x) | 28 #define SkFractionalIntToFixed(x) (x) |
29 #define SkFixedToFractionalInt(x) (x) | 29 #define SkFixedToFractionalInt(x) (x) |
30 #define SkFractionalIntToInt(x) ((x) >> 16) | 30 #define SkFractionalIntToInt(x) ((x) >> 16) |
31 #endif | 31 #endif |
32 | 32 |
33 class SkPaint; | 33 class SkPaint; |
34 | 34 |
35 struct SkBitmapProcState { | 35 struct SkBitmapProcState { |
36 | 36 |
37 SkBitmapProcState(): fBitmapFilter(NULL) {} | 37 SkBitmapProcState(): fBitmapFilter(NULL) {} |
38 ~SkBitmapProcState() { | |
39 SkDELETE(fBitmapFilter); | |
40 } | |
41 | 38 |
42 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, | 39 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, |
43 SkPMColor[], int count); | 40 SkPMColor[], int count); |
44 | 41 |
45 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, | 42 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, |
46 uint16_t[], int count); | 43 uint16_t[], int count); |
47 | 44 |
48 typedef void (*MatrixProc)(const SkBitmapProcState&, | 45 typedef void (*MatrixProc)(const SkBitmapProcState&, |
49 uint32_t bitmapXY[], | 46 uint32_t bitmapXY[], |
50 int count, | 47 int count, |
(...skipping 28 matching lines...) Expand all Loading... |
79 SkFixed fFilterOneX; | 76 SkFixed fFilterOneX; |
80 SkFixed fFilterOneY; | 77 SkFixed fFilterOneY; |
81 | 78 |
82 SkPMColor fPaintPMColor; // chooseProcs - A8 config | 79 SkPMColor fPaintPMColor; // chooseProcs - A8 config |
83 SkFixed fInvSx; // chooseProcs | 80 SkFixed fInvSx; // chooseProcs |
84 SkFixed fInvKy; // chooseProcs | 81 SkFixed fInvKy; // chooseProcs |
85 uint16_t fAlphaScale; // chooseProcs | 82 uint16_t fAlphaScale; // chooseProcs |
86 uint8_t fInvType; // chooseProcs | 83 uint8_t fInvType; // chooseProcs |
87 uint8_t fTileModeX; // CONSTRUCTOR | 84 uint8_t fTileModeX; // CONSTRUCTOR |
88 uint8_t fTileModeY; // CONSTRUCTOR | 85 uint8_t fTileModeY; // CONSTRUCTOR |
89 SkBool8 fDoFilter; // chooseProcs | 86 |
| 87 enum { |
| 88 kNone_BitmapFilter, |
| 89 kBilerp_BitmapFilter, |
| 90 kHQ_BitmapFilter |
| 91 } fFilterQuality; // chooseProcs |
| 92 |
| 93 /** The shader will let us know when we can release some of our resources |
| 94 * like scaled bitmaps. |
| 95 */ |
| 96 |
| 97 void endContext(); |
90 | 98 |
91 /** Platforms implement this, and can optionally overwrite only the | 99 /** Platforms implement this, and can optionally overwrite only the |
92 following fields: | 100 following fields: |
93 | 101 |
94 fShaderProc32 | 102 fShaderProc32 |
95 fShaderProc16 | 103 fShaderProc16 |
96 fMatrixProc | 104 fMatrixProc |
97 fSampleProc32 | 105 fSampleProc32 |
98 fSampleProc32 | 106 fSampleProc32 |
99 | 107 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 143 |
136 ShaderProc32 fShaderProc32; // chooseProcs | 144 ShaderProc32 fShaderProc32; // chooseProcs |
137 ShaderProc16 fShaderProc16; // chooseProcs | 145 ShaderProc16 fShaderProc16; // chooseProcs |
138 // These are used if the shaderproc is NULL | 146 // These are used if the shaderproc is NULL |
139 MatrixProc fMatrixProc; // chooseProcs | 147 MatrixProc fMatrixProc; // chooseProcs |
140 SampleProc32 fSampleProc32; // chooseProcs | 148 SampleProc32 fSampleProc32; // chooseProcs |
141 SampleProc16 fSampleProc16; // chooseProcs | 149 SampleProc16 fSampleProc16; // chooseProcs |
142 | 150 |
143 SkMatrix fUnitInvMatrix; // chooseProcs | 151 SkMatrix fUnitInvMatrix; // chooseProcs |
144 SkBitmap fOrigBitmap; // CONSTRUCTOR | 152 SkBitmap fOrigBitmap; // CONSTRUCTOR |
145 SkBitmap fMipBitmap; | 153 SkBitmap fScaledBitmap; // chooseProcs |
146 | 154 |
147 MatrixProc chooseMatrixProc(bool trivial_matrix); | 155 MatrixProc chooseMatrixProc(bool trivial_matrix); |
148 bool chooseProcs(const SkMatrix& inv, const SkPaint&); | 156 bool chooseProcs(const SkMatrix& inv, const SkPaint&); |
149 ShaderProc32 chooseShaderProc32(); | 157 ShaderProc32 chooseShaderProc32(); |
| 158 |
| 159 void possiblyScaleImage(); |
150 | 160 |
151 void buildFilterCoefficients(SkFixed dst[4], float t) const; | |
152 SkBitmapFilter *fBitmapFilter; | 161 SkBitmapFilter *fBitmapFilter; |
153 | 162 |
154 ShaderProc32 chooseBitmapFilterProc(const SkPaint &paint); | 163 ShaderProc32 chooseBitmapFilterProc(); |
155 | 164 |
156 // Return false if we failed to setup for fast translate (e.g. overflow) | 165 // Return false if we failed to setup for fast translate (e.g. overflow) |
157 bool setupForTranslate(); | 166 bool setupForTranslate(); |
158 | 167 |
159 #ifdef SK_DEBUG | 168 #ifdef SK_DEBUG |
160 static void DebugMatrixProc(const SkBitmapProcState&, | 169 static void DebugMatrixProc(const SkBitmapProcState&, |
161 uint32_t[], int count, int x, int y); | 170 uint32_t[], int count, int x, int y); |
162 #endif | 171 #endif |
163 }; | 172 }; |
164 | 173 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void S32_D16_filter_DX(const SkBitmapProcState& s, | 216 void S32_D16_filter_DX(const SkBitmapProcState& s, |
208 const uint32_t* xy, int count, uint16_t* colo
rs); | 217 const uint32_t* xy, int count, uint16_t* colo
rs); |
209 | 218 |
210 void highQualityFilter_ScaleOnly(const SkBitmapProcState &s, int x, int y, | 219 void highQualityFilter_ScaleOnly(const SkBitmapProcState &s, int x, int y, |
211 SkPMColor *SK_RESTRICT colors, int count); | 220 SkPMColor *SK_RESTRICT colors, int count); |
212 void highQualityFilter(const SkBitmapProcState &s, int x, int y, | 221 void highQualityFilter(const SkBitmapProcState &s, int x, int y, |
213 SkPMColor *SK_RESTRICT colors, int count); | 222 SkPMColor *SK_RESTRICT colors, int count); |
214 | 223 |
215 | 224 |
216 #endif | 225 #endif |
OLD | NEW |