reed@android.com | b34086a | 2009-06-12 19:49:30 +0000 | [diff] [blame] | 1 | |
| 2 | #ifndef SkGLState_DEFINED |
| 3 | #define SkGLState_DEFINED |
| 4 | |
| 5 | #include "SkGL.h" |
| 6 | #include "SkSize.h" |
| 7 | |
| 8 | class SkGLState { |
| 9 | public: |
| 10 | static SkGLState& GlobalState() { return gState; } |
| 11 | |
| 12 | SkGLState(); |
| 13 | |
| 14 | void reset(); |
| 15 | |
| 16 | // internally, these are bit_shifts, so they must be 0, 1, ... |
| 17 | enum Caps { |
| 18 | kDITHER, |
| 19 | kTEXTURE_2D, |
| 20 | }; |
| 21 | void enable(Caps); |
| 22 | void disable(Caps); |
| 23 | |
| 24 | // internally, these are bit_shifts, so they must be 0, 1, ... |
| 25 | enum ClientState { |
| 26 | kTEXTURE_COORD_ARRAY, |
| 27 | kCOLOR_ARRAY, |
| 28 | }; |
| 29 | void enableClientState(ClientState); |
| 30 | void disableClientState(ClientState); |
| 31 | |
| 32 | // we use -1 for unknown, so the enum must be >= 0 |
| 33 | enum ShadeModel { |
| 34 | kFLAT, |
| 35 | kSMOOTH, |
| 36 | }; |
| 37 | void shadeModel(ShadeModel); |
| 38 | |
| 39 | void scissor(int x, int y, int w, int h); |
| 40 | |
| 41 | void color(SkColor c) { |
| 42 | this->pmColor(SkPreMultiplyColor(c)); |
| 43 | } |
| 44 | void alpha(U8CPU a) { |
| 45 | this->pmColor((a << 24) | (a << 16) | (a << 8) | a); |
| 46 | } |
| 47 | void pmColor(SkPMColor); |
| 48 | |
| 49 | void blendFunc(GLenum src, GLenum dst); |
| 50 | |
| 51 | void pointSize(float); |
| 52 | void lineWidth(float); |
| 53 | |
| 54 | private: |
| 55 | void init(); |
| 56 | |
| 57 | unsigned fCapBits; |
| 58 | unsigned fClientStateBits; |
| 59 | int fShadeModel; |
| 60 | SkIPoint fScissorLoc; |
| 61 | SkISize fScissorSize; |
| 62 | SkPMColor fPMColor; |
| 63 | GLenum fSrcBlend, fDstBlend; |
| 64 | float fPointSize; |
| 65 | float fLineWidth; |
| 66 | |
| 67 | const GLenum* fCapsPtr; |
| 68 | const GLenum* fClientPtr; |
| 69 | const GLenum* fShadePtr; |
| 70 | |
| 71 | static SkGLState gState; |
| 72 | }; |
| 73 | |
| 74 | #endif |