blob: 96d8374e5a8de6ff2b9b3f8f16ba0abe78de9c50 [file] [log] [blame]
reed@android.comb34086a2009-06-12 19:49:30 +00001
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.comb34086a2009-06-12 19:49:30 +00009#ifndef SkGLState_DEFINED
10#define SkGLState_DEFINED
11
12#include "SkGL.h"
13#include "SkSize.h"
14
15class SkGLState {
16public:
17 static SkGLState& GlobalState() { return gState; }
18
19 SkGLState();
20
21 void reset();
22
23 // internally, these are bit_shifts, so they must be 0, 1, ...
24 enum Caps {
25 kDITHER,
26 kTEXTURE_2D,
27 };
28 void enable(Caps);
29 void disable(Caps);
30
31 // internally, these are bit_shifts, so they must be 0, 1, ...
32 enum ClientState {
33 kTEXTURE_COORD_ARRAY,
34 kCOLOR_ARRAY,
35 };
36 void enableClientState(ClientState);
37 void disableClientState(ClientState);
38
39 // we use -1 for unknown, so the enum must be >= 0
40 enum ShadeModel {
41 kFLAT,
42 kSMOOTH,
43 };
44 void shadeModel(ShadeModel);
45
46 void scissor(int x, int y, int w, int h);
47
48 void color(SkColor c) {
49 this->pmColor(SkPreMultiplyColor(c));
50 }
51 void alpha(U8CPU a) {
52 this->pmColor((a << 24) | (a << 16) | (a << 8) | a);
53 }
54 void pmColor(SkPMColor);
55
56 void blendFunc(GLenum src, GLenum dst);
57
58 void pointSize(float);
59 void lineWidth(float);
60
61private:
62 void init();
63
64 unsigned fCapBits;
65 unsigned fClientStateBits;
66 int fShadeModel;
67 SkIPoint fScissorLoc;
68 SkISize fScissorSize;
69 SkPMColor fPMColor;
70 GLenum fSrcBlend, fDstBlend;
71 float fPointSize;
72 float fLineWidth;
73
74 const GLenum* fCapsPtr;
75 const GLenum* fClientPtr;
76 const GLenum* fShadePtr;
77
78 static SkGLState gState;
79};
80
81#endif