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