blob: 17811c84bf98eea57cb8d7d663d36a3327104b0f [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
junov@google.com53a55842011-06-08 22:55:10 +000034 virtual void abandonResources();
35
junov@google.comf93e7172011-03-31 21:26:24 +000036protected:
37 // overrides from GrGpu
38 virtual bool flushGraphicsState(GrPrimitiveType type);
39 virtual void setupGeometry(int* startVertex,
40 int* startIndex,
41 int vertexCount,
42 int indexCount);
43 virtual void postDraw();
44
45private:
46
bsalomon@google.com1e257a52011-07-06 19:52:16 +000047 // for readability of function impls
48 typedef GrGLProgram::ProgramDesc ProgramDesc;
49 typedef ProgramDesc::StageDesc StageDesc;
50 typedef GrGLProgram::CachedData CachedData;
51
junov@google.comf93e7172011-03-31 21:26:24 +000052 class ProgramCache;
53
junov@google.comf93e7172011-03-31 21:26:24 +000054 // Helpers to make code more readable
55 const GrMatrix& getHWSamplerMatrix(int stage);
56 void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
57
58 // sets the texture matrix uniform for currently bound program
59 void flushTextureMatrix(int stage);
60
junov@google.com6acc9b32011-05-16 18:32:07 +000061 // sets the texture domain uniform for currently bound program
62 void flushTextureDomain(int stage);
63
bsalomon@google.com4be283f2011-04-19 21:15:09 +000064 // sets the color specified by GrDrawTarget::setColor()
65 void flushColor();
66
junov@google.comf93e7172011-03-31 21:26:24 +000067 // sets the MVP matrix uniform for currently bound program
68 void flushViewMatrix();
69
70 // flushes the parameters to two point radial gradient
71 void flushRadial2(int stage);
72
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000073 // flushes the normalized texel size
74 void flushTexelSize(int stage);
75
senorblanco@chromium.org92e0f222011-05-12 15:49:15 +000076 // flushes the edges for edge AA
77 void flushEdgeAAData();
78
bsalomon@google.com1e257a52011-07-06 19:52:16 +000079 static void DeleteProgram(CachedData* programData);
junov@google.comf93e7172011-03-31 21:26:24 +000080
81 void ProgramUnitTest();
82
83 void buildProgram(GrPrimitiveType type);
84
85 ProgramCache* fProgramCache;
bsalomon@google.com1e257a52011-07-06 19:52:16 +000086 CachedData* fProgramData;
junov@google.comf93e7172011-03-31 21:26:24 +000087 GrGLuint fHWProgramID;
88 GrGLProgram fCurrentProgram;
89
90 typedef GrGpuGL INHERITED;
91};
92
93#endif
94