blob: fc5215f48b72918179cba893860e253300f671e7 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
junov@google.comf93e7172011-03-31 21:26:24 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.
junov@google.comf93e7172011-03-31 21:26:24 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
junov@google.comf93e7172011-03-31 21:26:24 +000011#ifndef GrGpuGLShaders_DEFINED
12#define GrGpuGLShaders_DEFINED
13
14#include "GrGpuGL.h"
15#include "GrGLProgram.h"
16
17class GrGpuGLProgram;
18
19// Programmable OpenGL or OpenGL ES 2.0
20class GrGpuGLShaders : public GrGpuGL {
21public:
bsalomon@google.com0b77d682011-08-19 13:28:54 +000022 GrGpuGLShaders(const GrGLInterface* glInterface);
junov@google.comf93e7172011-03-31 21:26:24 +000023 virtual ~GrGpuGLShaders();
24
25 virtual void resetContext();
26
junov@google.com53a55842011-06-08 22:55:10 +000027 virtual void abandonResources();
28
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000029 bool programUnitTest();
30
junov@google.comf93e7172011-03-31 21:26:24 +000031protected:
32 // overrides from GrGpu
33 virtual bool flushGraphicsState(GrPrimitiveType type);
34 virtual void setupGeometry(int* startVertex,
35 int* startIndex,
36 int vertexCount,
37 int indexCount);
38 virtual void postDraw();
39
40private:
41
bsalomon@google.com1e257a52011-07-06 19:52:16 +000042 // for readability of function impls
43 typedef GrGLProgram::ProgramDesc ProgramDesc;
44 typedef ProgramDesc::StageDesc StageDesc;
45 typedef GrGLProgram::CachedData CachedData;
46
junov@google.comf93e7172011-03-31 21:26:24 +000047 class ProgramCache;
48
junov@google.comf93e7172011-03-31 21:26:24 +000049 // Helpers to make code more readable
50 const GrMatrix& getHWSamplerMatrix(int stage);
51 void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
52
53 // sets the texture matrix uniform for currently bound program
54 void flushTextureMatrix(int stage);
55
junov@google.com6acc9b32011-05-16 18:32:07 +000056 // sets the texture domain uniform for currently bound program
57 void flushTextureDomain(int stage);
58
bsalomon@google.com4be283f2011-04-19 21:15:09 +000059 // sets the color specified by GrDrawTarget::setColor()
bsalomon@google.com86c1f712011-10-12 14:54:26 +000060 void flushColor(GrColor color);
bsalomon@google.com4be283f2011-04-19 21:15:09 +000061
junov@google.comf93e7172011-03-31 21:26:24 +000062 // sets the MVP matrix uniform for currently bound program
63 void flushViewMatrix();
64
65 // flushes the parameters to two point radial gradient
66 void flushRadial2(int stage);
67
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +000068 // flushes the parameters for convolution
69 void flushConvolution(int stage);
70
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000071 // flushes the normalized texel size
72 void flushTexelSize(int stage);
73
senorblanco@chromium.org92e0f222011-05-12 15:49:15 +000074 // flushes the edges for edge AA
75 void flushEdgeAAData();
76
bsalomon@google.com0b77d682011-08-19 13:28:54 +000077 static void DeleteProgram(const GrGLInterface* gl,
78 CachedData* programData);
junov@google.comf93e7172011-03-31 21:26:24 +000079
bsalomon@google.com86c1f712011-10-12 14:54:26 +000080 void buildProgram(GrPrimitiveType typeBlend,
81 BlendOptFlags blendOpts,
82 GrBlendCoeff dstCoeff);
junov@google.comf93e7172011-03-31 21:26:24 +000083
84 ProgramCache* fProgramCache;
bsalomon@google.com1e257a52011-07-06 19:52:16 +000085 CachedData* fProgramData;
junov@google.comf93e7172011-03-31 21:26:24 +000086 GrGLuint fHWProgramID;
87 GrGLProgram fCurrentProgram;
bsalomon@google.comb5b5eaf2011-10-19 13:25:46 +000088 // If we get rid of fixed function subclass this should move
89 // to the GLCaps struct in parent class
90 GrGLint fMaxVertexAttribs;
junov@google.comf93e7172011-03-31 21:26:24 +000091
92 typedef GrGpuGL INHERITED;
93};
94
95#endif
96