| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 * only one geometry would need to be rendered. However no benches were run comp
aring | 54 * only one geometry would need to be rendered. However no benches were run comp
aring |
| 55 * chopped first order and non chopped 2nd order. | 55 * chopped first order and non chopped 2nd order. |
| 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 GrPrimitiveEdgeType edgeType, | 62 const GrPrimitiveEdgeType edgeType, |
| 63 const GrDrawTargetCaps& caps, | 63 const GrDrawTargetCaps& caps, |
| 64 const SkMatrix& localMatrix, |
| 64 uint8_t coverage = 0xff) { | 65 uint8_t coverage = 0xff) { |
| 65 switch (edgeType) { | 66 switch (edgeType) { |
| 66 case kFillAA_GrProcessorEdgeType: | 67 case kFillAA_GrProcessorEdgeType: |
| 67 if (!caps.shaderDerivativeSupport()) { | 68 if (!caps.shaderDerivativeSupport()) { |
| 68 return NULL; | 69 return NULL; |
| 69 } | 70 } |
| 70 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillAA_GrPro
cessorEdgeType)); | 71 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillAA_GrPro
cessorEdgeType, |
| 72 localMatrix)); |
| 71 case kHairlineAA_GrProcessorEdgeType: | 73 case kHairlineAA_GrProcessorEdgeType: |
| 72 if (!caps.shaderDerivativeSupport()) { | 74 if (!caps.shaderDerivativeSupport()) { |
| 73 return NULL; | 75 return NULL; |
| 74 } | 76 } |
| 75 return SkNEW_ARGS(GrConicEffect, (color, coverage, | 77 return SkNEW_ARGS(GrConicEffect, (color, coverage, |
| 76 kHairlineAA_GrProcessorEdgeTyp
e)); | 78 kHairlineAA_GrProcessorEdgeTyp
e, |
| 79 localMatrix)); |
| 77 case kFillBW_GrProcessorEdgeType: | 80 case kFillBW_GrProcessorEdgeType: |
| 78 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillBW_GrPro
cessorEdgeType));; | 81 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillBW_GrPro
cessorEdgeType, |
| 82 localMatrix)); |
| 79 default: | 83 default: |
| 80 return NULL; | 84 return NULL; |
| 81 } | 85 } |
| 82 } | 86 } |
| 83 | 87 |
| 84 virtual ~GrConicEffect(); | 88 virtual ~GrConicEffect(); |
| 85 | 89 |
| 86 virtual const char* name() const SK_OVERRIDE { return "Conic"; } | 90 virtual const char* name() const SK_OVERRIDE { return "Conic"; } |
| 87 | 91 |
| 88 inline const GrAttribute* inPosition() const { return fInPosition; } | 92 inline const GrAttribute* inPosition() const { return fInPosition; } |
| 89 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } | 93 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } |
| 90 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 94 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 91 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 95 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 92 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 96 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 93 | 97 |
| 94 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 98 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 95 const GrGLCaps& caps, | 99 const GrGLCaps& caps, |
| 96 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 100 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| 97 | 101 |
| 98 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 102 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
| 99 | 103 |
| 100 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; | 104 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; |
| 101 bool onCanMakeEqual(const GrBatchTracker&, | 105 bool onCanMakeEqual(const GrBatchTracker&, |
| 102 const GrGeometryProcessor&, | 106 const GrGeometryProcessor&, |
| 103 const GrBatchTracker&) const SK_OVERRIDE; | 107 const GrBatchTracker&) const SK_OVERRIDE; |
| 104 | 108 |
| 105 private: | 109 private: |
| 106 GrConicEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType); | 110 GrConicEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType, const SkMatrix
& localMatrix); |
| 107 | 111 |
| 108 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 112 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 109 | 113 |
| 110 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 114 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
| 111 out->setUnknownSingleComponent(); | 115 out->setUnknownSingleComponent(); |
| 112 } | 116 } |
| 113 | 117 |
| 114 uint8_t fCoverageScale; | 118 uint8_t fCoverageScale; |
| 115 GrPrimitiveEdgeType fEdgeType; | 119 GrPrimitiveEdgeType fEdgeType; |
| 116 const GrAttribute* fInPosition; | 120 const GrAttribute* fInPosition; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 130 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. | 134 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
| 131 * Requires shader derivative instruction support. | 135 * Requires shader derivative instruction support. |
| 132 */ | 136 */ |
| 133 class GrGLQuadEffect; | 137 class GrGLQuadEffect; |
| 134 | 138 |
| 135 class GrQuadEffect : public GrGeometryProcessor { | 139 class GrQuadEffect : public GrGeometryProcessor { |
| 136 public: | 140 public: |
| 137 static GrGeometryProcessor* Create(GrColor color, | 141 static GrGeometryProcessor* Create(GrColor color, |
| 138 const GrPrimitiveEdgeType edgeType, | 142 const GrPrimitiveEdgeType edgeType, |
| 139 const GrDrawTargetCaps& caps, | 143 const GrDrawTargetCaps& caps, |
| 144 const SkMatrix& localMatrix, |
| 140 uint8_t coverage = 0xff) { | 145 uint8_t coverage = 0xff) { |
| 141 switch (edgeType) { | 146 switch (edgeType) { |
| 142 case kFillAA_GrProcessorEdgeType: | 147 case kFillAA_GrProcessorEdgeType: |
| 143 if (!caps.shaderDerivativeSupport()) { | 148 if (!caps.shaderDerivativeSupport()) { |
| 144 return NULL; | 149 return NULL; |
| 145 } | 150 } |
| 146 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillAA_GrProc
essorEdgeType)); | 151 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillAA_GrProc
essorEdgeType, |
| 152 localMatrix)); |
| 147 case kHairlineAA_GrProcessorEdgeType: | 153 case kHairlineAA_GrProcessorEdgeType: |
| 148 if (!caps.shaderDerivativeSupport()) { | 154 if (!caps.shaderDerivativeSupport()) { |
| 149 return NULL; | 155 return NULL; |
| 150 } | 156 } |
| 151 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kHairlineAA_Gr
ProcessorEdgeType)); | 157 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kHairlineAA_Gr
ProcessorEdgeType, |
| 158 localMatrix)); |
| 152 case kFillBW_GrProcessorEdgeType: | 159 case kFillBW_GrProcessorEdgeType: |
| 153 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillBW_GrProc
essorEdgeType)); | 160 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillBW_GrProc
essorEdgeType, |
| 161 localMatrix)); |
| 154 default: | 162 default: |
| 155 return NULL; | 163 return NULL; |
| 156 } | 164 } |
| 157 } | 165 } |
| 158 | 166 |
| 159 virtual ~GrQuadEffect(); | 167 virtual ~GrQuadEffect(); |
| 160 | 168 |
| 161 virtual const char* name() const SK_OVERRIDE { return "Quad"; } | 169 virtual const char* name() const SK_OVERRIDE { return "Quad"; } |
| 162 | 170 |
| 163 inline const GrAttribute* inPosition() const { return fInPosition; } | 171 inline const GrAttribute* inPosition() const { return fInPosition; } |
| 164 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } | 172 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } |
| 165 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 173 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
| 166 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 174 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
| 167 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 175 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
| 168 | 176 |
| 169 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 177 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 170 const GrGLCaps& caps, | 178 const GrGLCaps& caps, |
| 171 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 179 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| 172 | 180 |
| 173 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 181 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
| 174 | 182 |
| 175 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; | 183 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; |
| 176 bool onCanMakeEqual(const GrBatchTracker&, | 184 bool onCanMakeEqual(const GrBatchTracker&, |
| 177 const GrGeometryProcessor&, | 185 const GrGeometryProcessor&, |
| 178 const GrBatchTracker&) const SK_OVERRIDE; | 186 const GrBatchTracker&) const SK_OVERRIDE; |
| 179 | 187 |
| 180 private: | 188 private: |
| 181 GrQuadEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType); | 189 GrQuadEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType, const SkMatrix&
localMatrix); |
| 182 | 190 |
| 183 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 191 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
| 184 | 192 |
| 185 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 193 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
| 186 out->setUnknownSingleComponent(); | 194 out->setUnknownSingleComponent(); |
| 187 } | 195 } |
| 188 | 196 |
| 189 uint8_t fCoverageScale; | 197 uint8_t fCoverageScale; |
| 190 GrPrimitiveEdgeType fEdgeType; | 198 GrPrimitiveEdgeType fEdgeType; |
| 191 const GrAttribute* fInPosition; | 199 const GrAttribute* fInPosition; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 GrPrimitiveEdgeType fEdgeType; | 273 GrPrimitiveEdgeType fEdgeType; |
| 266 const GrAttribute* fInPosition; | 274 const GrAttribute* fInPosition; |
| 267 const GrAttribute* fInCubicCoeffs; | 275 const GrAttribute* fInCubicCoeffs; |
| 268 | 276 |
| 269 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 277 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
| 270 | 278 |
| 271 typedef GrGeometryProcessor INHERITED; | 279 typedef GrGeometryProcessor INHERITED; |
| 272 }; | 280 }; |
| 273 | 281 |
| 274 #endif | 282 #endif |
| OLD | NEW |