epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * 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.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 11 | #ifndef GrGpuGLShaders_DEFINED |
| 12 | #define GrGpuGLShaders_DEFINED |
| 13 | |
| 14 | #include "GrGpuGL.h" |
| 15 | #include "GrGLProgram.h" |
| 16 | |
| 17 | class GrGpuGLProgram; |
| 18 | |
| 19 | // Programmable OpenGL or OpenGL ES 2.0 |
| 20 | class GrGpuGLShaders : public GrGpuGL { |
| 21 | public: |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 22 | GrGpuGLShaders(const GrGLInterface* glInterface); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 23 | virtual ~GrGpuGLShaders(); |
| 24 | |
| 25 | virtual void resetContext(); |
| 26 | |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 27 | virtual void abandonResources(); |
| 28 | |
bsalomon@google.com | a8e686e | 2011-08-16 15:45:58 +0000 | [diff] [blame] | 29 | bool programUnitTest(); |
| 30 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 31 | protected: |
| 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 | |
| 40 | private: |
| 41 | |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 42 | // for readability of function impls |
| 43 | typedef GrGLProgram::ProgramDesc ProgramDesc; |
| 44 | typedef ProgramDesc::StageDesc StageDesc; |
| 45 | typedef GrGLProgram::CachedData CachedData; |
| 46 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 47 | class ProgramCache; |
| 48 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 49 | // 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.com | 6acc9b3 | 2011-05-16 18:32:07 +0000 | [diff] [blame] | 56 | // sets the texture domain uniform for currently bound program |
| 57 | void flushTextureDomain(int stage); |
| 58 | |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 59 | // sets the color specified by GrDrawTarget::setColor() |
bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 60 | void flushColor(GrColor color); |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 61 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 62 | // 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.org | 027de5f | 2011-07-08 18:03:33 +0000 | [diff] [blame] | 68 | // flushes the parameters for convolution |
| 69 | void flushConvolution(int stage); |
| 70 | |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 71 | // flushes the normalized texel size |
| 72 | void flushTexelSize(int stage); |
| 73 | |
senorblanco@chromium.org | 92e0f22 | 2011-05-12 15:49:15 +0000 | [diff] [blame] | 74 | // flushes the edges for edge AA |
| 75 | void flushEdgeAAData(); |
| 76 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 77 | static void DeleteProgram(const GrGLInterface* gl, |
| 78 | CachedData* programData); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 79 | |
bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 80 | void buildProgram(GrPrimitiveType typeBlend, |
| 81 | BlendOptFlags blendOpts, |
| 82 | GrBlendCoeff dstCoeff); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 83 | |
| 84 | ProgramCache* fProgramCache; |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 85 | CachedData* fProgramData; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 86 | GrGLuint fHWProgramID; |
| 87 | GrGLProgram fCurrentProgram; |
bsalomon@google.com | b5b5eaf | 2011-10-19 13:25:46 +0000 | [diff] [blame] | 88 | // If we get rid of fixed function subclass this should move |
| 89 | // to the GLCaps struct in parent class |
| 90 | GrGLint fMaxVertexAttribs; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 91 | |
| 92 | typedef GrGpuGL INHERITED; |
| 93 | }; |
| 94 | |
| 95 | #endif |
| 96 | |