| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 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_DEFINED | 8 #ifndef SkBitmapProcState_DEFINED |
| 9 #define SkBitmapProcState_DEFINED | 9 #define SkBitmapProcState_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkBitmapFilter.h" | 12 #include "SkBitmapFilter.h" |
| 13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 14 #include "SkMipMap.h" | 14 #include "SkMipMap.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 | 16 |
| 17 typedef SkFixed3232 SkFractionalInt; | 17 typedef SkFixed3232 SkFractionalInt; |
| 18 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) | 18 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) |
| 19 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) | 19 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) |
| 20 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) | 20 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) |
| 21 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) | 21 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) |
| 22 | 22 |
| 23 class SkPaint; | 23 class SkPaint; |
| 24 | 24 |
| 25 struct SkBitmapProcState { | 25 struct SkBitmapProcState { |
| 26 | |
| 27 SkBitmapProcState() : fBitmapFilter(NULL) {} | |
| 28 ~SkBitmapProcState(); | |
| 29 | |
| 30 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, | 26 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, |
| 31 SkPMColor[], int count); | 27 SkPMColor[], int count); |
| 32 | 28 |
| 33 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, | 29 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, |
| 34 uint16_t[], int count); | 30 uint16_t[], int count); |
| 35 | 31 |
| 36 typedef void (*MatrixProc)(const SkBitmapProcState&, | 32 typedef void (*MatrixProc)(const SkBitmapProcState&, |
| 37 uint32_t bitmapXY[], | 33 uint32_t bitmapXY[], |
| 38 int count, | 34 int count, |
| 39 int x, int y); | 35 int x, int y); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 Only valid to call after chooseProcs (setContext) has been called. It is | 96 Only valid to call after chooseProcs (setContext) has been called. It is |
| 101 safe to call this inside the shader's shadeSpan() method. | 97 safe to call this inside the shader's shadeSpan() method. |
| 102 */ | 98 */ |
| 103 int maxCountForBufferSize(size_t bufferSize) const; | 99 int maxCountForBufferSize(size_t bufferSize) const; |
| 104 | 100 |
| 105 // If a shader proc is present, then the corresponding matrix/sample procs | 101 // If a shader proc is present, then the corresponding matrix/sample procs |
| 106 // are ignored | 102 // are ignored |
| 107 ShaderProc32 getShaderProc32() const { return fShaderProc32; } | 103 ShaderProc32 getShaderProc32() const { return fShaderProc32; } |
| 108 ShaderProc16 getShaderProc16() const { return fShaderProc16; } | 104 ShaderProc16 getShaderProc16() const { return fShaderProc16; } |
| 109 | 105 |
| 110 SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; } | |
| 111 | |
| 112 #ifdef SK_DEBUG | 106 #ifdef SK_DEBUG |
| 113 MatrixProc getMatrixProc() const; | 107 MatrixProc getMatrixProc() const; |
| 114 #else | 108 #else |
| 115 MatrixProc getMatrixProc() const { return fMatrixProc; } | 109 MatrixProc getMatrixProc() const { return fMatrixProc; } |
| 116 #endif | 110 #endif |
| 117 SampleProc32 getSampleProc32() const { return fSampleProc32; } | 111 SampleProc32 getSampleProc32() const { return fSampleProc32; } |
| 118 SampleProc16 getSampleProc16() const { return fSampleProc16; } | 112 SampleProc16 getSampleProc16() const { return fSampleProc16; } |
| 119 | 113 |
| 120 private: | 114 private: |
| 121 friend class SkBitmapProcShader; | 115 friend class SkBitmapProcShader; |
| 122 | 116 |
| 123 ShaderProc32 fShaderProc32; // chooseProcs | 117 ShaderProc32 fShaderProc32; // chooseProcs |
| 124 ShaderProc16 fShaderProc16; // chooseProcs | 118 ShaderProc16 fShaderProc16; // chooseProcs |
| 125 // These are used if the shaderproc is NULL | 119 // These are used if the shaderproc is NULL |
| 126 MatrixProc fMatrixProc; // chooseProcs | 120 MatrixProc fMatrixProc; // chooseProcs |
| 127 SampleProc32 fSampleProc32; // chooseProcs | 121 SampleProc32 fSampleProc32; // chooseProcs |
| 128 SampleProc16 fSampleProc16; // chooseProcs | 122 SampleProc16 fSampleProc16; // chooseProcs |
| 129 | 123 |
| 130 SkBitmap fOrigBitmap; // CONSTRUCTOR | 124 SkBitmap fOrigBitmap; // CONSTRUCTOR |
| 131 SkBitmap fScaledBitmap; // chooseProcs | 125 SkBitmap fScaledBitmap; // chooseProcs |
| 132 | 126 |
| 133 SkAutoTUnref<const SkMipMap> fCurrMip; | 127 SkAutoTUnref<const SkMipMap> fCurrMip; |
| 134 bool fAdjustedMatrix; // set by possiblyScaleImage | |
| 135 | 128 |
| 136 void processHQRequest(); | 129 void processHQRequest(); |
| 137 void processMediumRequest(); | 130 void processMediumRequest(); |
| 138 | 131 |
| 139 MatrixProc chooseMatrixProc(bool trivial_matrix); | 132 MatrixProc chooseMatrixProc(bool trivial_matrix); |
| 140 bool chooseProcs(const SkMatrix& inv, const SkPaint&); | 133 bool chooseProcs(const SkMatrix& inv, const SkPaint&); |
| 141 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint&
paint); | 134 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint&
paint); |
| 142 ShaderProc32 chooseShaderProc32(); | 135 ShaderProc32 chooseShaderProc32(); |
| 143 | 136 |
| 144 // returns false if we did not try to scale the image. In that case, we | |
| 145 // will need to "lock" its pixels some other way. | |
| 146 bool possiblyScaleImage(); | |
| 147 | |
| 148 // returns false if we failed to "lock" the pixels at all. Typically this | 137 // returns false if we failed to "lock" the pixels at all. Typically this |
| 149 // means we have to abort the shader. | 138 // means we have to abort the shader. |
| 150 bool lockBaseBitmap(); | 139 bool lockBaseBitmap(); |
| 151 | 140 |
| 152 SkBitmapFilter* fBitmapFilter; | |
| 153 | |
| 154 // If supported, sets fShaderProc32 and fShaderProc16 and returns true, | |
| 155 // otherwise returns false. | |
| 156 bool setBitmapFilterProcs(); | |
| 157 | |
| 158 // Return false if we failed to setup for fast translate (e.g. overflow) | 141 // Return false if we failed to setup for fast translate (e.g. overflow) |
| 159 bool setupForTranslate(); | 142 bool setupForTranslate(); |
| 160 | 143 |
| 161 #ifdef SK_DEBUG | 144 #ifdef SK_DEBUG |
| 162 static void DebugMatrixProc(const SkBitmapProcState&, | 145 static void DebugMatrixProc(const SkBitmapProcState&, |
| 163 uint32_t[], int count, int x, int y); | 146 uint32_t[], int count, int x, int y); |
| 164 #endif | 147 #endif |
| 165 }; | 148 }; |
| 166 | 149 |
| 167 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint. | 150 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 int count, int x, int y); | 187 int count, int x, int y); |
| 205 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, | 188 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, |
| 206 uint32_t xy[], int count, int x, int y); | 189 uint32_t xy[], int count, int x, int y); |
| 207 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, | 190 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, |
| 208 uint32_t xy[], int count, int x, int y); | 191 uint32_t xy[], int count, int x, int y); |
| 209 void S32_D16_filter_DX(const SkBitmapProcState& s, | 192 void S32_D16_filter_DX(const SkBitmapProcState& s, |
| 210 const uint32_t* xy, int count, uint16_t* colors); | 193 const uint32_t* xy, int count, uint16_t* colors); |
| 211 void S32_D16_filter_DXDY(const SkBitmapProcState& s, | 194 void S32_D16_filter_DXDY(const SkBitmapProcState& s, |
| 212 const uint32_t* xy, int count, uint16_t* colors); | 195 const uint32_t* xy, int count, uint16_t* colors); |
| 213 | 196 |
| 214 void highQualityFilter32(const SkBitmapProcState &s, int x, int y, | |
| 215 SkPMColor *SK_RESTRICT colors, int count); | |
| 216 void highQualityFilter16(const SkBitmapProcState &s, int x, int y, | |
| 217 uint16_t *SK_RESTRICT colors, int count); | |
| 218 | |
| 219 | |
| 220 #endif | 197 #endif |
| OLD | NEW |