| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrBezierEffect_DEFINED | 8 #ifndef GrBezierEffect_DEFINED |
| 9 #define GrBezierEffect_DEFINED | 9 #define GrBezierEffect_DEFINED |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 */ | 56 */ |
| 57 class GrGLConicEffect; | 57 class GrGLConicEffect; |
| 58 | 58 |
| 59 class GrConicEffect : public GrGeometryProcessor { | 59 class GrConicEffect : public GrGeometryProcessor { |
| 60 public: | 60 public: |
| 61 static GrGeometryProcessor* Create(GrColor color, | 61 static GrGeometryProcessor* Create(GrColor color, |
| 62 const SkMatrix& viewMatrix, | 62 const SkMatrix& viewMatrix, |
| 63 const GrPrimitiveEdgeType edgeType, | 63 const GrPrimitiveEdgeType edgeType, |
| 64 const GrDrawTargetCaps& caps, | 64 const GrDrawTargetCaps& caps, |
| 65 const SkMatrix& localMatrix, | 65 const SkMatrix& localMatrix, |
| 66 bool usesLocalCoords, | |
| 67 uint8_t coverage = 0xff) { | 66 uint8_t coverage = 0xff) { |
| 68 switch (edgeType) { | 67 switch (edgeType) { |
| 69 case kFillAA_GrProcessorEdgeType: | 68 case kFillAA_GrProcessorEdgeType: |
| 70 if (!caps.shaderCaps()->shaderDerivativeSupport()) { | 69 if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
| 71 return NULL; | 70 return NULL; |
| 72 } | 71 } |
| 73 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, | 72 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 74 kFillAA_GrProcessorEdgeType, | 73 kFillAA_GrProcessorEdgeType, |
| 75 localMatrix, usesLocalCoords))
; | 74 localMatrix)); |
| 76 case kHairlineAA_GrProcessorEdgeType: | 75 case kHairlineAA_GrProcessorEdgeType: |
| 77 if (!caps.shaderCaps()->shaderDerivativeSupport()) { | 76 if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
| 78 return NULL; | 77 return NULL; |
| 79 } | 78 } |
| 80 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, | 79 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 81 kHairlineAA_GrProcessorEdgeTyp
e, | 80 kHairlineAA_GrProcessorEdgeTyp
e, |
| 82 localMatrix, usesLocalCoords))
; | 81 localMatrix)); |
| 83 case kFillBW_GrProcessorEdgeType: | 82 case kFillBW_GrProcessorEdgeType: |
| 84 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, | 83 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 85 kFillBW_GrProcessorEdgeType, | 84 kFillBW_GrProcessorEdgeType, |
| 86 localMatrix, usesLocalCoords))
; | 85 localMatrix)); |
| 87 default: | 86 default: |
| 88 return NULL; | 87 return NULL; |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| 92 virtual ~GrConicEffect(); | 91 virtual ~GrConicEffect(); |
| 93 | 92 |
| 94 const char* name() const override { return "Conic"; } | 93 const char* name() const override { return "Conic"; } |
| 95 | 94 |
| 96 inline const Attribute* inPosition() const { return fInPosition; } | 95 inline const Attribute* inPosition() const { return fInPosition; } |
| 97 inline const Attribute* inConicCoeffs() const { return fInConicCoeffs; } | 96 inline const Attribute* inConicCoeffs() const { return fInConicCoeffs; } |
| 98 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 97 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 99 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 98 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 100 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 99 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 101 GrColor color() const { return fColor; } | 100 GrColor color() const { return fColor; } |
| 102 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
| 103 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 101 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 104 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 102 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
| 105 bool usesLocalCoords() const { return fUsesLocalCoords; } | |
| 106 uint8_t coverageScale() const { return fCoverageScale; } | |
| 107 | 103 |
| 108 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 104 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 109 const GrGLSLCaps& caps, | 105 const GrGLSLCaps& caps, |
| 110 GrProcessorKeyBuilder* b) const override; | 106 GrProcessorKeyBuilder* b) const override; |
| 111 | 107 |
| 112 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 108 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 113 const GrGLSLCaps&) const ov
erride; | 109 const GrGLSLCaps&) const ov
erride; |
| 114 | 110 |
| 111 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override
; |
| 112 |
| 115 private: | 113 private: |
| 116 GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimi
tiveEdgeType, | 114 GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimi
tiveEdgeType, |
| 117 const SkMatrix& localMatrix, bool usesLocalCoords); | 115 const SkMatrix& localMatrix); |
| 118 | 116 |
| 119 GrColor fColor; | 117 GrColor fColor; |
| 120 SkMatrix fViewMatrix; | 118 SkMatrix fViewMatrix; |
| 121 SkMatrix fLocalMatrix; | 119 SkMatrix fLocalMatrix; |
| 122 bool fUsesLocalCoords; | |
| 123 uint8_t fCoverageScale; | 120 uint8_t fCoverageScale; |
| 124 GrPrimitiveEdgeType fEdgeType; | 121 GrPrimitiveEdgeType fEdgeType; |
| 125 const Attribute* fInPosition; | 122 const Attribute* fInPosition; |
| 126 const Attribute* fInConicCoeffs; | 123 const Attribute* fInConicCoeffs; |
| 127 | 124 |
| 128 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 125 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 129 | 126 |
| 130 typedef GrGeometryProcessor INHERITED; | 127 typedef GrGeometryProcessor INHERITED; |
| 131 }; | 128 }; |
| 132 | 129 |
| 133 /////////////////////////////////////////////////////////////////////////////// | 130 /////////////////////////////////////////////////////////////////////////////// |
| 134 /** | 131 /** |
| 135 * The output of this effect is a hairline edge for quadratics. | 132 * The output of this effect is a hairline edge for quadratics. |
| 136 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first | 133 * Quadratic specified by 0=u^2-v canonical coords. u and v are the first |
| 137 * two components of the vertex attribute. At the three control points that defi
ne | 134 * two components of the vertex attribute. At the three control points that defi
ne |
| 138 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. | 135 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. |
| 139 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. | 136 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
| 140 * Requires shader derivative instruction support. | 137 * Requires shader derivative instruction support. |
| 141 */ | 138 */ |
| 142 class GrGLQuadEffect; | 139 class GrGLQuadEffect; |
| 143 | 140 |
| 144 class GrQuadEffect : public GrGeometryProcessor { | 141 class GrQuadEffect : public GrGeometryProcessor { |
| 145 public: | 142 public: |
| 146 static GrGeometryProcessor* Create(GrColor color, | 143 static GrGeometryProcessor* Create(GrColor color, |
| 147 const SkMatrix& viewMatrix, | 144 const SkMatrix& viewMatrix, |
| 148 const GrPrimitiveEdgeType edgeType, | 145 const GrPrimitiveEdgeType edgeType, |
| 149 const GrDrawTargetCaps& caps, | 146 const GrDrawTargetCaps& caps, |
| 150 const SkMatrix& localMatrix, | 147 const SkMatrix& localMatrix, |
| 151 bool usesLocalCoords, | |
| 152 uint8_t coverage = 0xff) { | 148 uint8_t coverage = 0xff) { |
| 153 switch (edgeType) { | 149 switch (edgeType) { |
| 154 case kFillAA_GrProcessorEdgeType: | 150 case kFillAA_GrProcessorEdgeType: |
| 155 if (!caps.shaderCaps()->shaderDerivativeSupport()) { | 151 if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
| 156 return NULL; | 152 return NULL; |
| 157 } | 153 } |
| 158 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, | 154 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 159 kFillAA_GrProcessorEdgeType, | 155 kFillAA_GrProcessorEdgeType, |
| 160 localMatrix, usesLocalCoords)); | 156 localMatrix)); |
| 161 case kHairlineAA_GrProcessorEdgeType: | 157 case kHairlineAA_GrProcessorEdgeType: |
| 162 if (!caps.shaderCaps()->shaderDerivativeSupport()) { | 158 if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
| 163 return NULL; | 159 return NULL; |
| 164 } | 160 } |
| 165 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, | 161 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 166 kHairlineAA_GrProcessorEdgeType
, | 162 kHairlineAA_GrProcessorEdgeType
, |
| 167 localMatrix, usesLocalCoords)); | 163 localMatrix)); |
| 168 case kFillBW_GrProcessorEdgeType: | 164 case kFillBW_GrProcessorEdgeType: |
| 169 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, | 165 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 170 kFillBW_GrProcessorEdgeType, | 166 kFillBW_GrProcessorEdgeType, |
| 171 localMatrix, usesLocalCoords)); | 167 localMatrix)); |
| 172 default: | 168 default: |
| 173 return NULL; | 169 return NULL; |
| 174 } | 170 } |
| 175 } | 171 } |
| 176 | 172 |
| 177 virtual ~GrQuadEffect(); | 173 virtual ~GrQuadEffect(); |
| 178 | 174 |
| 179 const char* name() const override { return "Quad"; } | 175 const char* name() const override { return "Quad"; } |
| 180 | 176 |
| 181 inline const Attribute* inPosition() const { return fInPosition; } | 177 inline const Attribute* inPosition() const { return fInPosition; } |
| 182 inline const Attribute* inHairQuadEdge() const { return fInHairQuadEdge; } | 178 inline const Attribute* inHairQuadEdge() const { return fInHairQuadEdge; } |
| 183 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 179 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 184 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 180 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 185 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 181 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 186 GrColor color() const { return fColor; } | 182 GrColor color() const { return fColor; } |
| 187 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
| 188 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 183 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 189 const SkMatrix& localMatrix() const { return fLocalMatrix; } | 184 const SkMatrix& localMatrix() const { return fLocalMatrix; } |
| 190 bool usesLocalCoords() const { return fUsesLocalCoords; } | |
| 191 uint8_t coverageScale() const { return fCoverageScale; } | |
| 192 | 185 |
| 193 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 186 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 194 const GrGLSLCaps& caps, | 187 const GrGLSLCaps& caps, |
| 195 GrProcessorKeyBuilder* b) const override; | 188 GrProcessorKeyBuilder* b) const override; |
| 196 | 189 |
| 197 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 190 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 198 const GrGLSLCaps&) const ov
erride; | 191 const GrGLSLCaps&) const ov
erride; |
| 199 | 192 |
| 193 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override
; |
| 194 |
| 200 private: | 195 private: |
| 201 GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimit
iveEdgeType, | 196 GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimit
iveEdgeType, |
| 202 const SkMatrix& localMatrix, bool usesLocalCoords); | 197 const SkMatrix& localMatrix); |
| 203 | 198 |
| 204 GrColor fColor; | 199 GrColor fColor; |
| 205 SkMatrix fViewMatrix; | 200 SkMatrix fViewMatrix; |
| 206 SkMatrix fLocalMatrix; | 201 SkMatrix fLocalMatrix; |
| 207 bool fUsesLocalCoords; | |
| 208 uint8_t fCoverageScale; | 202 uint8_t fCoverageScale; |
| 209 GrPrimitiveEdgeType fEdgeType; | 203 GrPrimitiveEdgeType fEdgeType; |
| 210 const Attribute* fInPosition; | 204 const Attribute* fInPosition; |
| 211 const Attribute* fInHairQuadEdge; | 205 const Attribute* fInHairQuadEdge; |
| 212 | 206 |
| 213 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 207 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 214 | 208 |
| 215 typedef GrGeometryProcessor INHERITED; | 209 typedef GrGeometryProcessor INHERITED; |
| 216 }; | 210 }; |
| 217 | 211 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 virtual ~GrCubicEffect(); | 251 virtual ~GrCubicEffect(); |
| 258 | 252 |
| 259 const char* name() const override { return "Cubic"; } | 253 const char* name() const override { return "Cubic"; } |
| 260 | 254 |
| 261 inline const Attribute* inPosition() const { return fInPosition; } | 255 inline const Attribute* inPosition() const { return fInPosition; } |
| 262 inline const Attribute* inCubicCoeffs() const { return fInCubicCoeffs; } | 256 inline const Attribute* inCubicCoeffs() const { return fInCubicCoeffs; } |
| 263 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 257 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 264 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 258 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 265 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 259 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 266 GrColor color() const { return fColor; } | 260 GrColor color() const { return fColor; } |
| 267 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } | |
| 268 const SkMatrix& viewMatrix() const { return fViewMatrix; } | 261 const SkMatrix& viewMatrix() const { return fViewMatrix; } |
| 269 | 262 |
| 270 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 263 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 271 const GrGLSLCaps& caps, | 264 const GrGLSLCaps& caps, |
| 272 GrProcessorKeyBuilder* b) const override; | 265 GrProcessorKeyBuilder* b) const override; |
| 273 | 266 |
| 274 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 267 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 275 const GrGLSLCaps&) const ov
erride; | 268 const GrGLSLCaps&) const ov
erride; |
| 276 | 269 |
| 270 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override
; |
| 271 |
| 277 private: | 272 private: |
| 278 GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType); | 273 GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType); |
| 279 | 274 |
| 280 GrColor fColor; | 275 GrColor fColor; |
| 281 SkMatrix fViewMatrix; | 276 SkMatrix fViewMatrix; |
| 282 GrPrimitiveEdgeType fEdgeType; | 277 GrPrimitiveEdgeType fEdgeType; |
| 283 const Attribute* fInPosition; | 278 const Attribute* fInPosition; |
| 284 const Attribute* fInCubicCoeffs; | 279 const Attribute* fInCubicCoeffs; |
| 285 | 280 |
| 286 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 281 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 287 | 282 |
| 288 typedef GrGeometryProcessor INHERITED; | 283 typedef GrGeometryProcessor INHERITED; |
| 289 }; | 284 }; |
| 290 | 285 |
| 291 #endif | 286 #endif |
| OLD | NEW |