Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 95 |
| 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 |
|
robertphillips
2015/01/20 16:34:21
Can we just delete this?
reed1
2015/01/20 16:42:16
Done.
| |
| 110 SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; } | 106 // SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; } |
| 111 | 107 |
| 112 #ifdef SK_DEBUG | 108 #ifdef SK_DEBUG |
| 113 MatrixProc getMatrixProc() const; | 109 MatrixProc getMatrixProc() const; |
| 114 #else | 110 #else |
| 115 MatrixProc getMatrixProc() const { return fMatrixProc; } | 111 MatrixProc getMatrixProc() const { return fMatrixProc; } |
| 116 #endif | 112 #endif |
| 117 SampleProc32 getSampleProc32() const { return fSampleProc32; } | 113 SampleProc32 getSampleProc32() const { return fSampleProc32; } |
| 118 SampleProc16 getSampleProc16() const { return fSampleProc16; } | 114 SampleProc16 getSampleProc16() const { return fSampleProc16; } |
| 119 | 115 |
| 120 private: | 116 private: |
| 121 friend class SkBitmapProcShader; | 117 friend class SkBitmapProcShader; |
| 122 | 118 |
| 123 ShaderProc32 fShaderProc32; // chooseProcs | 119 ShaderProc32 fShaderProc32; // chooseProcs |
| 124 ShaderProc16 fShaderProc16; // chooseProcs | 120 ShaderProc16 fShaderProc16; // chooseProcs |
| 125 // These are used if the shaderproc is NULL | 121 // These are used if the shaderproc is NULL |
| 126 MatrixProc fMatrixProc; // chooseProcs | 122 MatrixProc fMatrixProc; // chooseProcs |
| 127 SampleProc32 fSampleProc32; // chooseProcs | 123 SampleProc32 fSampleProc32; // chooseProcs |
| 128 SampleProc16 fSampleProc16; // chooseProcs | 124 SampleProc16 fSampleProc16; // chooseProcs |
| 129 | 125 |
| 130 SkBitmap fOrigBitmap; // CONSTRUCTOR | 126 SkBitmap fOrigBitmap; // CONSTRUCTOR |
| 131 SkBitmap fScaledBitmap; // chooseProcs | 127 SkBitmap fScaledBitmap; // chooseProcs |
| 132 | 128 |
| 133 SkAutoTUnref<const SkMipMap> fCurrMip; | 129 SkAutoTUnref<const SkMipMap> fCurrMip; |
| 134 bool fAdjustedMatrix; // set by possiblyScaleImage | |
| 135 | 130 |
| 136 void processHQRequest(); | 131 void processHQRequest(); |
| 137 void processMediumRequest(); | 132 void processMediumRequest(); |
| 138 | 133 |
| 139 MatrixProc chooseMatrixProc(bool trivial_matrix); | 134 MatrixProc chooseMatrixProc(bool trivial_matrix); |
| 140 bool chooseProcs(const SkMatrix& inv, const SkPaint&); | 135 bool chooseProcs(const SkMatrix& inv, const SkPaint&); |
| 141 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint& paint); | 136 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint& paint); |
| 142 ShaderProc32 chooseShaderProc32(); | 137 ShaderProc32 chooseShaderProc32(); |
| 143 | 138 |
| 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 | 139 // returns false if we failed to "lock" the pixels at all. Typically this |
| 149 // means we have to abort the shader. | 140 // means we have to abort the shader. |
| 150 bool lockBaseBitmap(); | 141 bool lockBaseBitmap(); |
| 151 | 142 |
|
robertphillips
2015/01/20 16:34:21
Can we just delete this?
reed1
2015/01/20 16:42:16
Done.
| |
| 143 #if 0 | |
| 152 SkBitmapFilter* fBitmapFilter; | 144 SkBitmapFilter* fBitmapFilter; |
| 153 | 145 |
| 154 // If supported, sets fShaderProc32 and fShaderProc16 and returns true, | 146 // If supported, sets fShaderProc32 and fShaderProc16 and returns true, |
| 155 // otherwise returns false. | 147 // otherwise returns false. |
| 156 bool setBitmapFilterProcs(); | 148 bool setBitmapFilterProcs(); |
| 149 #endif | |
| 157 | 150 |
| 158 // Return false if we failed to setup for fast translate (e.g. overflow) | 151 // Return false if we failed to setup for fast translate (e.g. overflow) |
| 159 bool setupForTranslate(); | 152 bool setupForTranslate(); |
| 160 | 153 |
| 161 #ifdef SK_DEBUG | 154 #ifdef SK_DEBUG |
| 162 static void DebugMatrixProc(const SkBitmapProcState&, | 155 static void DebugMatrixProc(const SkBitmapProcState&, |
| 163 uint32_t[], int count, int x, int y); | 156 uint32_t[], int count, int x, int y); |
| 164 #endif | 157 #endif |
| 165 }; | 158 }; |
| 166 | 159 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 int count, int x, int y); | 197 int count, int x, int y); |
| 205 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, | 198 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, |
| 206 uint32_t xy[], int count, int x, int y); | 199 uint32_t xy[], int count, int x, int y); |
| 207 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, | 200 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, |
| 208 uint32_t xy[], int count, int x, int y); | 201 uint32_t xy[], int count, int x, int y); |
| 209 void S32_D16_filter_DX(const SkBitmapProcState& s, | 202 void S32_D16_filter_DX(const SkBitmapProcState& s, |
| 210 const uint32_t* xy, int count, uint16_t* colors); | 203 const uint32_t* xy, int count, uint16_t* colors); |
| 211 void S32_D16_filter_DXDY(const SkBitmapProcState& s, | 204 void S32_D16_filter_DXDY(const SkBitmapProcState& s, |
| 212 const uint32_t* xy, int count, uint16_t* colors); | 205 const uint32_t* xy, int count, uint16_t* colors); |
| 213 | 206 |
| 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 | 207 #endif |
| OLD | NEW |