junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | class GrGpuGLProgram; |
| 25 | |
| 26 | // Programmable OpenGL or OpenGL ES 2.0 |
| 27 | class GrGpuGLShaders : public GrGpuGL { |
| 28 | public: |
| 29 | GrGpuGLShaders(); |
| 30 | virtual ~GrGpuGLShaders(); |
| 31 | |
| 32 | virtual void resetContext(); |
| 33 | |
| 34 | protected: |
| 35 | // overrides from GrGpu |
| 36 | virtual bool flushGraphicsState(GrPrimitiveType type); |
| 37 | virtual void setupGeometry(int* startVertex, |
| 38 | int* startIndex, |
| 39 | int vertexCount, |
| 40 | int indexCount); |
| 41 | virtual void postDraw(); |
| 42 | |
| 43 | private: |
| 44 | |
| 45 | class ProgramCache; |
| 46 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 47 | // 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.com | 6acc9b3 | 2011-05-16 18:32:07 +0000 | [diff] [blame^] | 54 | // sets the texture domain uniform for currently bound program |
| 55 | void flushTextureDomain(int stage); |
| 56 | |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 57 | // sets the color specified by GrDrawTarget::setColor() |
| 58 | void flushColor(); |
| 59 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 60 | // 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 | |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 66 | // flushes the normalized texel size |
| 67 | void flushTexelSize(int stage); |
| 68 | |
senorblanco@chromium.org | 92e0f22 | 2011-05-12 15:49:15 +0000 | [diff] [blame] | 69 | // flushes the edges for edge AA |
| 70 | void flushEdgeAAData(); |
| 71 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 72 | static void DeleteProgram(GrGLProgram::CachedData* programData); |
| 73 | |
| 74 | void ProgramUnitTest(); |
| 75 | |
| 76 | void buildProgram(GrPrimitiveType type); |
| 77 | |
| 78 | ProgramCache* fProgramCache; |
| 79 | GrGLProgram::CachedData* fProgramData; |
| 80 | GrGLuint fHWProgramID; |
| 81 | GrGLProgram fCurrentProgram; |
| 82 | |
| 83 | typedef GrGpuGL INHERITED; |
| 84 | }; |
| 85 | |
| 86 | #endif |
| 87 | |