blob: 565498ed96f70a0e6757f5bb64189bc50cf06866 [file] [log] [blame]
reed@android.comb34086a2009-06-12 19:49:30 +00001
2#ifndef SkGLState_DEFINED
3#define SkGLState_DEFINED
4
5#include "SkGL.h"
6#include "SkSize.h"
7
8class SkGLState {
9public:
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
54private:
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