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 | |
junov@google.com | 53a5584 | 2011-06-08 22:55:10 +0000 | [diff] [blame] | 34 | virtual void abandonResources(); |
| 35 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 36 | protected: |
| 37 | // overrides from GrGpu |
| 38 | virtual bool flushGraphicsState(GrPrimitiveType type); |
| 39 | virtual void setupGeometry(int* startVertex, |
| 40 | int* startIndex, |
| 41 | int vertexCount, |
| 42 | int indexCount); |
| 43 | virtual void postDraw(); |
| 44 | |
| 45 | private: |
| 46 | |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame^] | 47 | // for readability of function impls |
| 48 | typedef GrGLProgram::ProgramDesc ProgramDesc; |
| 49 | typedef ProgramDesc::StageDesc StageDesc; |
| 50 | typedef GrGLProgram::CachedData CachedData; |
| 51 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 52 | class ProgramCache; |
| 53 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 54 | // Helpers to make code more readable |
| 55 | const GrMatrix& getHWSamplerMatrix(int stage); |
| 56 | void recordHWSamplerMatrix(int stage, const GrMatrix& matrix); |
| 57 | |
| 58 | // sets the texture matrix uniform for currently bound program |
| 59 | void flushTextureMatrix(int stage); |
| 60 | |
junov@google.com | 6acc9b3 | 2011-05-16 18:32:07 +0000 | [diff] [blame] | 61 | // sets the texture domain uniform for currently bound program |
| 62 | void flushTextureDomain(int stage); |
| 63 | |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 64 | // sets the color specified by GrDrawTarget::setColor() |
| 65 | void flushColor(); |
| 66 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 67 | // sets the MVP matrix uniform for currently bound program |
| 68 | void flushViewMatrix(); |
| 69 | |
| 70 | // flushes the parameters to two point radial gradient |
| 71 | void flushRadial2(int stage); |
| 72 | |
bsalomon@google.com | 6aef1fb | 2011-05-05 12:33:22 +0000 | [diff] [blame] | 73 | // flushes the normalized texel size |
| 74 | void flushTexelSize(int stage); |
| 75 | |
senorblanco@chromium.org | 92e0f22 | 2011-05-12 15:49:15 +0000 | [diff] [blame] | 76 | // flushes the edges for edge AA |
| 77 | void flushEdgeAAData(); |
| 78 | |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame^] | 79 | static void DeleteProgram(CachedData* programData); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 80 | |
| 81 | void ProgramUnitTest(); |
| 82 | |
| 83 | void buildProgram(GrPrimitiveType type); |
| 84 | |
| 85 | ProgramCache* fProgramCache; |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame^] | 86 | CachedData* fProgramData; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 87 | GrGLuint fHWProgramID; |
| 88 | GrGLProgram fCurrentProgram; |
| 89 | |
| 90 | typedef GrGpuGL INHERITED; |
| 91 | }; |
| 92 | |
| 93 | #endif |
| 94 | |