| 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 "SkBitmapController.h" |
| 12 #include "SkBitmapFilter.h" | 13 #include "SkBitmapFilter.h" |
| 14 #include "SkInPlace.h" |
| 13 #include "SkMatrix.h" | 15 #include "SkMatrix.h" |
| 14 #include "SkMipMap.h" | 16 #include "SkMipMap.h" |
| 15 #include "SkPaint.h" | 17 #include "SkPaint.h" |
| 16 | 18 |
| 17 typedef SkFixed3232 SkFractionalInt; | 19 typedef SkFixed3232 SkFractionalInt; |
| 18 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) | 20 #define SkScalarToFractionalInt(x) SkScalarToFixed3232(x) |
| 19 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) | 21 #define SkFractionalIntToFixed(x) SkFixed3232ToFixed(x) |
| 20 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) | 22 #define SkFixedToFractionalInt(x) SkFixedToFixed3232(x) |
| 21 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) | 23 #define SkFractionalIntToInt(x) SkFixed3232ToInt(x) |
| 22 | 24 |
| 23 class SkPaint; | 25 class SkPaint; |
| 24 | 26 |
| 25 struct SkBitmapProcState { | 27 struct SkBitmapProcState { |
| 28 SkBitmapProcState(); |
| 29 ~SkBitmapProcState(); |
| 30 |
| 26 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, | 31 typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, |
| 27 SkPMColor[], int count); | 32 SkPMColor[], int count); |
| 28 | 33 |
| 29 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, | 34 typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, |
| 30 uint16_t[], int count); | 35 uint16_t[], int count); |
| 31 | 36 |
| 32 typedef void (*MatrixProc)(const SkBitmapProcState&, | 37 typedef void (*MatrixProc)(const SkBitmapProcState&, |
| 33 uint32_t bitmapXY[], | 38 uint32_t bitmapXY[], |
| 34 int count, | 39 int count, |
| 35 int x, int y); | 40 int x, int y); |
| 36 | 41 |
| 37 typedef void (*SampleProc32)(const SkBitmapProcState&, | 42 typedef void (*SampleProc32)(const SkBitmapProcState&, |
| 38 const uint32_t[], | 43 const uint32_t[], |
| 39 int count, | 44 int count, |
| 40 SkPMColor colors[]); | 45 SkPMColor colors[]); |
| 41 | 46 |
| 42 typedef void (*SampleProc16)(const SkBitmapProcState&, | 47 typedef void (*SampleProc16)(const SkBitmapProcState&, |
| 43 const uint32_t[], | 48 const uint32_t[], |
| 44 int count, | 49 int count, |
| 45 uint16_t colors[]); | 50 uint16_t colors[]); |
| 46 | 51 |
| 47 typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF | 52 typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF |
| 48 typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF | 53 typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF |
| 49 typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1 | 54 typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1 |
| 50 | 55 |
| 51 const SkBitmap* fBitmap; // chooseProcs - orig or scaled | 56 const SkBitmap* fBitmap; // chooseProcs - orig or scaled |
| 52 SkMatrix fInvMatrix; // chooseProcs | 57 SkMatrix fInvMatrix; // copy of what is in fBMState, can
we remove the dup? |
| 58 |
| 53 SkMatrix::MapXYProc fInvProc; // chooseProcs | 59 SkMatrix::MapXYProc fInvProc; // chooseProcs |
| 54 | 60 |
| 55 SkFractionalInt fInvSxFractionalInt; | 61 SkFractionalInt fInvSxFractionalInt; |
| 56 SkFractionalInt fInvKyFractionalInt; | 62 SkFractionalInt fInvKyFractionalInt; |
| 57 | 63 |
| 58 FixedTileProc fTileProcX; // chooseProcs | 64 FixedTileProc fTileProcX; // chooseProcs |
| 59 FixedTileProc fTileProcY; // chooseProcs | 65 FixedTileProc fTileProcY; // chooseProcs |
| 60 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs | 66 FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs |
| 61 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs | 67 FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs |
| 62 IntTileProc fIntTileProcY; // chooseProcs | 68 IntTileProc fIntTileProcY; // chooseProcs |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 friend class SkBitmapProcShader; | 121 friend class SkBitmapProcShader; |
| 116 | 122 |
| 117 ShaderProc32 fShaderProc32; // chooseProcs | 123 ShaderProc32 fShaderProc32; // chooseProcs |
| 118 ShaderProc16 fShaderProc16; // chooseProcs | 124 ShaderProc16 fShaderProc16; // chooseProcs |
| 119 // These are used if the shaderproc is NULL | 125 // These are used if the shaderproc is NULL |
| 120 MatrixProc fMatrixProc; // chooseProcs | 126 MatrixProc fMatrixProc; // chooseProcs |
| 121 SampleProc32 fSampleProc32; // chooseProcs | 127 SampleProc32 fSampleProc32; // chooseProcs |
| 122 SampleProc16 fSampleProc16; // chooseProcs | 128 SampleProc16 fSampleProc16; // chooseProcs |
| 123 | 129 |
| 124 SkBitmap fOrigBitmap; // CONSTRUCTOR | 130 SkBitmap fOrigBitmap; // CONSTRUCTOR |
| 125 SkBitmap fScaledBitmap; // chooseProcs | |
| 126 | 131 |
| 127 SkAutoTUnref<const SkMipMap> fCurrMip; | 132 enum { |
| 128 | 133 kBMStateSize = 136 // found by inspection. if too small, we will call n
ew/delete |
| 129 void processHQRequest(); | 134 }; |
| 130 void processMediumRequest(); | 135 SkSInPlace<kBMStateSize> fBMAllocator; |
| 136 SkBitmapController::State* fBMState; |
| 131 | 137 |
| 132 MatrixProc chooseMatrixProc(bool trivial_matrix); | 138 MatrixProc chooseMatrixProc(bool trivial_matrix); |
| 133 bool chooseProcs(const SkMatrix& inv, const SkPaint&); | 139 bool chooseProcs(const SkMatrix& inv, const SkPaint&); |
| 134 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint&
paint); | 140 bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint&
paint); |
| 135 ShaderProc32 chooseShaderProc32(); | 141 ShaderProc32 chooseShaderProc32(); |
| 136 | 142 |
| 137 // returns false if we failed to "lock" the pixels at all. Typically this | |
| 138 // means we have to abort the shader. | |
| 139 bool lockBaseBitmap(); | |
| 140 | |
| 141 // Return false if we failed to setup for fast translate (e.g. overflow) | 143 // Return false if we failed to setup for fast translate (e.g. overflow) |
| 142 bool setupForTranslate(); | 144 bool setupForTranslate(); |
| 143 | 145 |
| 144 #ifdef SK_DEBUG | 146 #ifdef SK_DEBUG |
| 145 static void DebugMatrixProc(const SkBitmapProcState&, | 147 static void DebugMatrixProc(const SkBitmapProcState&, |
| 146 uint32_t[], int count, int x, int y); | 148 uint32_t[], int count, int x, int y); |
| 147 #endif | 149 #endif |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint. | 152 /* Macros for packing and unpacking pairs of 16bit values in a 32bit uint. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, | 190 void ClampX_ClampY_filter_affine(const SkBitmapProcState& s, |
| 189 uint32_t xy[], int count, int x, int y); | 191 uint32_t xy[], int count, int x, int y); |
| 190 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, | 192 void ClampX_ClampY_nofilter_affine(const SkBitmapProcState& s, |
| 191 uint32_t xy[], int count, int x, int y); | 193 uint32_t xy[], int count, int x, int y); |
| 192 void S32_D16_filter_DX(const SkBitmapProcState& s, | 194 void S32_D16_filter_DX(const SkBitmapProcState& s, |
| 193 const uint32_t* xy, int count, uint16_t* colors); | 195 const uint32_t* xy, int count, uint16_t* colors); |
| 194 void S32_D16_filter_DXDY(const SkBitmapProcState& s, | 196 void S32_D16_filter_DXDY(const SkBitmapProcState& s, |
| 195 const uint32_t* xy, int count, uint16_t* colors); | 197 const uint32_t* xy, int count, uint16_t* colors); |
| 196 | 198 |
| 197 #endif | 199 #endif |
| OLD | NEW |