blob: baa5d9d90741cc2422a4be28f19e7ef3115cbb03 [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
junov@google.com53a55842011-06-08 22:55:10 +000025 virtual void abandonResources();
26
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000027 bool programUnitTest();
28
junov@google.comf93e7172011-03-31 21:26:24 +000029protected:
30 // overrides from GrGpu
bsalomon@google.com1bf1c212011-11-05 12:18:58 +000031 virtual void onResetContext() SK_OVERRIDE;
junov@google.comf93e7172011-03-31 21:26:24 +000032 virtual bool flushGraphicsState(GrPrimitiveType type);
33 virtual void setupGeometry(int* startVertex,
34 int* startIndex,
35 int vertexCount,
36 int indexCount);
37 virtual void postDraw();
38
39private:
40
bsalomon@google.com1e257a52011-07-06 19:52:16 +000041 // for readability of function impls
42 typedef GrGLProgram::ProgramDesc ProgramDesc;
43 typedef ProgramDesc::StageDesc StageDesc;
44 typedef GrGLProgram::CachedData CachedData;
45
junov@google.comf93e7172011-03-31 21:26:24 +000046 class ProgramCache;
47
junov@google.comf93e7172011-03-31 21:26:24 +000048 // Helpers to make code more readable
49 const GrMatrix& getHWSamplerMatrix(int stage);
50 void recordHWSamplerMatrix(int stage, const GrMatrix& matrix);
51
52 // sets the texture matrix uniform for currently bound program
53 void flushTextureMatrix(int stage);
54
junov@google.com6acc9b32011-05-16 18:32:07 +000055 // sets the texture domain uniform for currently bound program
56 void flushTextureDomain(int stage);
57
bsalomon@google.com4be283f2011-04-19 21:15:09 +000058 // sets the color specified by GrDrawTarget::setColor()
bsalomon@google.com86c1f712011-10-12 14:54:26 +000059 void flushColor(GrColor color);
bsalomon@google.com4be283f2011-04-19 21:15:09 +000060
junov@google.comf93e7172011-03-31 21:26:24 +000061 // sets the MVP matrix uniform for currently bound program
62 void flushViewMatrix();
63
64 // flushes the parameters to two point radial gradient
65 void flushRadial2(int stage);
66
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +000067 // flushes the parameters for convolution
68 void flushConvolution(int stage);
69
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000070 // flushes the normalized texel size
71 void flushTexelSize(int stage);
72
senorblanco@chromium.org92e0f222011-05-12 15:49:15 +000073 // flushes the edges for edge AA
74 void flushEdgeAAData();
75
bsalomon@google.com0b77d682011-08-19 13:28:54 +000076 static void DeleteProgram(const GrGLInterface* gl,
77 CachedData* programData);
junov@google.comf93e7172011-03-31 21:26:24 +000078
bsalomon@google.com86c1f712011-10-12 14:54:26 +000079 void buildProgram(GrPrimitiveType typeBlend,
80 BlendOptFlags blendOpts,
81 GrBlendCoeff dstCoeff);
junov@google.comf93e7172011-03-31 21:26:24 +000082
83 ProgramCache* fProgramCache;
bsalomon@google.com1e257a52011-07-06 19:52:16 +000084 CachedData* fProgramData;
junov@google.comf93e7172011-03-31 21:26:24 +000085 GrGLuint fHWProgramID;
86 GrGLProgram fCurrentProgram;
bsalomon@google.comb5b5eaf2011-10-19 13:25:46 +000087 // If we get rid of fixed function subclass this should move
88 // to the GLCaps struct in parent class
89 GrGLint fMaxVertexAttribs;
junov@google.comf93e7172011-03-31 21:26:24 +000090
91 typedef GrGpuGL INHERITED;
92};
93
94#endif
95