reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2007, The Android Open Source Project |
| 3 | ** |
| 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | ** you may not use this file except in compliance with the License. |
| 6 | ** You may obtain a copy of the License at |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 10 | ** Unless required by applicable law or agreed to in writing, software |
| 11 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | ** See the License for the specific language governing permissions and |
| 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef SkBitmapProcState_DEFINED |
| 18 | #define SkBitmapProcState_DEFINED |
| 19 | |
| 20 | #include "SkBitmap.h" |
| 21 | #include "SkMatrix.h" |
| 22 | |
| 23 | class SkPaint; |
| 24 | |
| 25 | struct SkBitmapProcState { |
| 26 | |
reed@android.com | 7a99eb1 | 2009-07-16 01:13:14 +0000 | [diff] [blame] | 27 | typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y, |
| 28 | SkPMColor[], int count); |
| 29 | |
| 30 | typedef void (*ShaderProc16)(const SkBitmapProcState&, int x, int y, |
| 31 | uint16_t[], int count); |
| 32 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | typedef void (*MatrixProc)(const SkBitmapProcState&, |
| 34 | uint32_t bitmapXY[], |
| 35 | int count, |
| 36 | int x, int y); |
| 37 | |
| 38 | typedef void (*SampleProc32)(const SkBitmapProcState&, |
| 39 | const uint32_t[], |
| 40 | int count, |
| 41 | SkPMColor colors[]); |
| 42 | |
| 43 | typedef void (*SampleProc16)(const SkBitmapProcState&, |
| 44 | const uint32_t[], |
| 45 | int count, |
| 46 | uint16_t colors[]); |
| 47 | |
| 48 | typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF |
reed@android.com | 7a99eb1 | 2009-07-16 01:13:14 +0000 | [diff] [blame] | 49 | |
| 50 | // If a shader proc is present, then the corresponding matrix/sample procs |
| 51 | // are ignored |
| 52 | ShaderProc32 fShaderProc32; // chooseProcs |
| 53 | ShaderProc16 fShaderProc16; // chooseProcs |
| 54 | // These are used if the shaderproc is NULL |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | MatrixProc fMatrixProc; // chooseProcs |
| 56 | SampleProc32 fSampleProc32; // chooseProcs |
| 57 | SampleProc16 fSampleProc16; // chooseProcs |
| 58 | |
reed@android.com | eef375b | 2009-08-03 14:45:45 +0000 | [diff] [blame] | 59 | const SkBitmap* fBitmap; // chooseProcs - orig or mip |
| 60 | const SkMatrix* fInvMatrix; // chooseProcs |
| 61 | SkMatrix::MapXYProc fInvProc; // chooseProcs |
| 62 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 63 | FixedTileProc fTileProcX; // chooseProcs |
| 64 | FixedTileProc fTileProcY; // chooseProcs |
| 65 | SkFixed fFilterOneX; |
| 66 | SkFixed fFilterOneY; |
| 67 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 68 | SkPMColor fPaintPMColor; // chooseProcs - A8 config |
reed@android.com | eef375b | 2009-08-03 14:45:45 +0000 | [diff] [blame] | 69 | SkFixed fInvSx; // chooseProcs |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 70 | SkFixed fInvKy; // chooseProcs |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 71 | uint16_t fAlphaScale; // chooseProcs |
| 72 | uint8_t fInvType; // chooseProcs |
| 73 | uint8_t fTileModeX; // CONSTRUCTOR |
| 74 | uint8_t fTileModeY; // CONSTRUCTOR |
| 75 | SkBool8 fDoFilter; // chooseProcs |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 76 | |
reed@android.com | c9a1d4b | 2009-08-03 15:05:55 +0000 | [diff] [blame^] | 77 | /** Platforms implement this, and can optionally overwrite only the |
| 78 | following fields: |
| 79 | |
| 80 | fShaderProc32 |
| 81 | fShaderProc16 |
| 82 | fMatrixProc |
| 83 | fSampleProc32 |
| 84 | fSampleProc32 |
| 85 | |
| 86 | They will already have valid function pointers, so a platform that does |
| 87 | not have an accelerated version can just leave that field as is. A valid |
| 88 | implementation can do nothing (see SkBitmapProcState_opts_none.cpp) |
| 89 | */ |
| 90 | void platformProcs(); |
| 91 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 92 | private: |
reed@android.com | eef375b | 2009-08-03 14:45:45 +0000 | [diff] [blame] | 93 | friend class SkBitmapProcShader; |
| 94 | |
| 95 | SkMatrix fUnitInvMatrix; // chooseProcs |
| 96 | SkBitmap fOrigBitmap; // CONSTRUCTOR |
| 97 | SkBitmap fMipBitmap; |
| 98 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 99 | MatrixProc chooseMatrixProc(); |
reed@android.com | eef375b | 2009-08-03 14:45:45 +0000 | [diff] [blame] | 100 | bool chooseProcs(const SkMatrix& inv, const SkPaint&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | #endif |