| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2014 Google Inc. | 2  * Copyright 2014 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #ifndef GrGLVertexShader_DEFINED | 8 #ifndef GrGLVertexShader_DEFINED | 
| 9 #define GrGLVertexShader_DEFINED | 9 #define GrGLVertexShader_DEFINED | 
| 10 | 10 | 
| 11 #include "GrGLShaderBuilder.h" | 11 #include "GrGLShaderBuilder.h" | 
| 12 | 12 | 
| 13 class GrGLProgramBuilder; | 13 class GrGLVarying; | 
| 14 | 14 | 
| 15 // TODO we only actually ever need to return a GrGLShaderBuilder for this guy, n
    one of the below |  | 
| 16 // functions need to be part of VertexShaderBuilder's public interface |  | 
| 17 class GrGLVertexBuilder : public GrGLShaderBuilder { | 15 class GrGLVertexBuilder : public GrGLShaderBuilder { | 
| 18 public: | 16 public: | 
| 19     GrGLVertexBuilder(GrGLProgramBuilder* program); | 17     GrGLVertexBuilder(GrGLProgramBuilder* program); | 
| 20 | 18 | 
| 21     /** | 19     /** | 
| 22      * Are explicit local coordinates provided as input to the vertex shader. | 20      * Are explicit local coordinates provided as input to the vertex shader. | 
| 23      */ | 21      */ | 
| 24     bool hasLocalCoords() const { return (fLocalCoordsVar != fPositionVar); } | 22     bool hasLocalCoords() const { return (fLocalCoordsVar != fPositionVar); } | 
| 25 | 23 | 
| 26     /** Returns a vertex attribute that represents the local coords in the VS. T
    his may be the same | 24     /** Returns a vertex attribute that represents the local coords in the VS. T
    his may be the same | 
| 27         as positionAttribute() or it may not be. It depends upon whether the ren
    dering code | 25         as positionAttribute() or it may not be. It depends upon whether the ren
    dering code | 
| 28         specified explicit local coords or not in the GrDrawState. */ | 26         specified explicit local coords or not in the GrDrawState. */ | 
| 29     const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
     } | 27     const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
     } | 
| 30 | 28 | 
| 31     /** Returns a vertex attribute that represents the vertex position in the VS
    . This is the | 29     /** Returns a vertex attribute that represents the vertex position in the VS
    . This is the | 
| 32         pre-matrix position and is commonly used by effects to compute texture c
    oords via a matrix. | 30         pre-matrix position and is commonly used by effects to compute texture c
    oords via a matrix. | 
| 33       */ | 31       */ | 
| 34     const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } | 32     const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } | 
| 35 | 33 | 
|  | 34 private: | 
| 36     /* | 35     /* | 
| 37      * Internal call for GrGLProgramBuilder.addVarying | 36      * Internal call for GrGLProgramBuilder.addVarying | 
| 38      */ | 37      */ | 
| 39     SkString* addVarying(GrSLType type, const char* name, const char** vsOutName
    ); | 38     void addVarying(const char* name, GrGLVarying*); | 
| 40 | 39 | 
| 41     /* | 40     /* | 
| 42      * private helpers for compilation by GrGLProgramBuilder | 41      * private helpers for compilation by GrGLProgramBuilder | 
| 43      */ | 42      */ | 
| 44     void setupLocalCoords(); | 43     void setupLocalCoords(); | 
| 45     void transformGLToSkiaCoords(); | 44     void transformGLToSkiaCoords(); | 
| 46     void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); | 45     void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); | 
| 47     void emitAttributes(const GrGeometryProcessor& gp); | 46     void emitAttributes(const GrGeometryProcessor& gp); | 
| 48     void transformSkiaToGLCoords(); | 47     void transformSkiaToGLCoords(); | 
| 49     void bindVertexAttributes(GrGLuint programID); | 48     void bindVertexAttributes(GrGLuint programID); | 
| 50     bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
    Ids) const; | 49     bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
    Ids) const; | 
| 51 | 50 | 
| 52 private: |  | 
| 53     // an internal call which checks for uniquness of a var before adding it to 
    the list of inputs | 51     // an internal call which checks for uniquness of a var before adding it to 
    the list of inputs | 
| 54     bool addAttribute(const GrShaderVar& var); | 52     bool addAttribute(const GrShaderVar& var); | 
| 55     struct AttributePair { | 53     struct AttributePair { | 
| 56         void set(int index, const SkString& name) { | 54         void set(int index, const SkString& name) { | 
| 57             fIndex = index; fName = name; | 55             fIndex = index; fName = name; | 
| 58         } | 56         } | 
| 59         int      fIndex; | 57         int      fIndex; | 
| 60         SkString fName; | 58         SkString fName; | 
| 61     }; | 59     }; | 
| 62 | 60 | 
| 63     GrGLShaderVar*                      fPositionVar; | 61     GrGLShaderVar*                      fPositionVar; | 
| 64     GrGLShaderVar*                      fLocalCoordsVar; | 62     GrGLShaderVar*                      fLocalCoordsVar; | 
| 65     int                                 fEffectAttribOffset; | 63     int                                 fEffectAttribOffset; | 
| 66 | 64 | 
|  | 65     friend class GrGLProgramBuilder; | 
|  | 66 | 
| 67     typedef GrGLShaderBuilder INHERITED; | 67     typedef GrGLShaderBuilder INHERITED; | 
| 68 }; | 68 }; | 
| 69 | 69 | 
| 70 #endif | 70 #endif | 
| OLD | NEW | 
|---|