blob: 92aab6ce44867893323271add27bcc4bae97d354 [file] [log] [blame]
junov@google.comf93e7172011-03-31 21:26:24 +00001/*
2 Copyright 2011 Google Inc.
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
18#ifndef GrGpuGLShaders_DEFINED
19#define GrGpuGLShaders_DEFINED
20
21#include "GrGpuGL.h"
22#include "GrGLProgram.h"
23
24class GrGpuGLProgram;
25
26// Programmable OpenGL or OpenGL ES 2.0
27class GrGpuGLShaders : public GrGpuGL {
28public:
29 GrGpuGLShaders();
30 virtual ~GrGpuGLShaders();
31
32 virtual void resetContext();
33
34protected:
35 // overrides from GrGpu
36 virtual bool flushGraphicsState(GrPrimitiveType type);
37 virtual void setupGeometry(int* startVertex,
38 int* startIndex,
39 int vertexCount,
40 int indexCount);
41 virtual void postDraw();
42
43private:
44
45 class ProgramCache;
46
junov@google.comf93e7172011-03-31 21:26:24 +000047 // Helpers to make code more readable
48 const GrMatrix& getHWSamplerMatrix(int stage);
49 void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
50
51 // sets the texture matrix uniform for currently bound program
52 void flushTextureMatrix(int stage);
53
bsalomon@google.com4be283f2011-04-19 21:15:09 +000054 // sets the color specified by GrDrawTarget::setColor()
55 void flushColor();
56
junov@google.comf93e7172011-03-31 21:26:24 +000057 // sets the MVP matrix uniform for currently bound program
58 void flushViewMatrix();
59
60 // flushes the parameters to two point radial gradient
61 void flushRadial2(int stage);
62
63 static void DeleteProgram(GrGLProgram::CachedData* programData);
64
65 void ProgramUnitTest();
66
67 void buildProgram(GrPrimitiveType type);
68
69 ProgramCache* fProgramCache;
70 GrGLProgram::CachedData* fProgramData;
71 GrGLuint fHWProgramID;
72 GrGLProgram fCurrentProgram;
73
74 typedef GrGpuGL INHERITED;
75};
76
77#endif
78