blob: eb3ee3773be2e3ca190426b027bbb88429531d51 [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:
22 GrGpuGLShaders();
23 virtual ~GrGpuGLShaders();
24
25 virtual void resetContext();
26
junov@google.com53a55842011-06-08 22:55:10 +000027 virtual void abandonResources();
28
junov@google.comf93e7172011-03-31 21:26:24 +000029protected:
30 // overrides from GrGpu
31 virtual bool flushGraphicsState(GrPrimitiveType type);
32 virtual void setupGeometry(int* startVertex,
33 int* startIndex,
34 int vertexCount,
35 int indexCount);
36 virtual void postDraw();
37
38private:
39
bsalomon@google.com1e257a52011-07-06 19:52:16 +000040 // for readability of function impls
41 typedef GrGLProgram::ProgramDesc ProgramDesc;
42 typedef ProgramDesc::StageDesc StageDesc;
43 typedef GrGLProgram::CachedData CachedData;
44
junov@google.comf93e7172011-03-31 21:26:24 +000045 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
junov@google.com6acc9b32011-05-16 18:32:07 +000054 // sets the texture domain uniform for currently bound program
55 void flushTextureDomain(int stage);
56
bsalomon@google.com4be283f2011-04-19 21:15:09 +000057 // sets the color specified by GrDrawTarget::setColor()
58 void flushColor();
59
junov@google.comf93e7172011-03-31 21:26:24 +000060 // sets the MVP matrix uniform for currently bound program
61 void flushViewMatrix();
62
63 // flushes the parameters to two point radial gradient
64 void flushRadial2(int stage);
65
senorblanco@chromium.org027de5f2011-07-08 18:03:33 +000066 // flushes the parameters for convolution
67 void flushConvolution(int stage);
68
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000069 // flushes the normalized texel size
70 void flushTexelSize(int stage);
71
senorblanco@chromium.org92e0f222011-05-12 15:49:15 +000072 // flushes the edges for edge AA
73 void flushEdgeAAData();
74
bsalomon@google.com1e257a52011-07-06 19:52:16 +000075 static void DeleteProgram(CachedData* programData);
junov@google.comf93e7172011-03-31 21:26:24 +000076
77 void ProgramUnitTest();
78
79 void buildProgram(GrPrimitiveType type);
80
81 ProgramCache* fProgramCache;
bsalomon@google.com1e257a52011-07-06 19:52:16 +000082 CachedData* fProgramData;
junov@google.comf93e7172011-03-31 21:26:24 +000083 GrGLuint fHWProgramID;
84 GrGLProgram fCurrentProgram;
85
86 typedef GrGpuGL INHERITED;
87};
88
89#endif
90