blob: 553b952c46eabdc70f1cf00d68adb33020b01690 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
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
23class SkPaint;
24
25struct SkBitmapProcState {
26
reed@android.com7a99eb12009-07-16 01:13:14 +000027 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.com8a1c16f2008-12-17 15:59:43 +000033 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.com7a99eb12009-07-16 01:13:14 +000049
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.com8a1c16f2008-12-17 15:59:43 +000055 MatrixProc fMatrixProc; // chooseProcs
56 SampleProc32 fSampleProc32; // chooseProcs
57 SampleProc16 fSampleProc16; // chooseProcs
58
59 SkMatrix fUnitInvMatrix; // chooseProcs
60 FixedTileProc fTileProcX; // chooseProcs
61 FixedTileProc fTileProcY; // chooseProcs
62 SkFixed fFilterOneX;
63 SkFixed fFilterOneY;
64
65 const SkBitmap* fBitmap; // chooseProcs - orig or mip
66 SkBitmap fOrigBitmap; // CONSTRUCTOR
67#ifdef SK_SUPPORT_MIPMAP
68 SkBitmap fMipBitmap;
69#endif
70 SkPMColor fPaintPMColor; // chooseProcs - A8 config
71 const SkMatrix* fInvMatrix; // chooseProcs
72 SkMatrix::MapXYProc fInvProc; // chooseProcs
73 SkFixed fInvSx, fInvSy; // chooseProcs
74 SkFixed fInvKy; // chooseProcs
reed@android.com8a1c16f2008-12-17 15:59:43 +000075 uint16_t fAlphaScale; // chooseProcs
76 uint8_t fInvType; // chooseProcs
77 uint8_t fTileModeX; // CONSTRUCTOR
78 uint8_t fTileModeY; // CONSTRUCTOR
79 SkBool8 fDoFilter; // chooseProcs
80
81 bool chooseProcs(const SkMatrix& inv, const SkPaint&);
82
83private:
84 MatrixProc chooseMatrixProc();
85};
86
87#endif