commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrBezierEffect_DEFINED |
skia.committer@gmail.com | 44a77c8 | 2013-08-23 07:01:29 +0000 | [diff] [blame] | 9 | #define GrBezierEffect_DEFINED |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 10 | |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 11 | #include "GrDrawTargetCaps.h" |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 12 | #include "GrProcessor.h" |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 13 | #include "GrGeometryProcessor.h" |
egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 14 | #include "GrInvariantOutput.h" |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 15 | #include "GrTypesPriv.h" |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * Shader is based off of Loop-Blinn Quadratic GPU Rendering |
| 19 | * The output of this effect is a hairline edge for conics. |
| 20 | * Conics specified by implicit equation K^2 - LM. |
| 21 | * K, L, and M, are the first three values of the vertex attribute, |
| 22 | * the fourth value is not used. Distance is calculated using a |
| 23 | * first order approximation from the taylor series. |
| 24 | * Coverage for AA is max(0, 1-distance). |
| 25 | * |
| 26 | * Test were also run using a second order distance approximation. |
| 27 | * There were two versions of the second order approx. The first version |
| 28 | * is of roughly the form: |
| 29 | * f(q) = |f(p)| - ||f'(p)||*||q-p|| - ||f''(p)||*||q-p||^2. |
| 30 | * The second is similar: |
| 31 | * f(q) = |f(p)| + ||f'(p)||*||q-p|| + ||f''(p)||*||q-p||^2. |
| 32 | * The exact version of the equations can be found in the paper |
| 33 | * "Distance Approximations for Rasterizing Implicit Curves" by Gabriel Taubin |
| 34 | * |
| 35 | * In both versions we solve the quadratic for ||q-p||. |
| 36 | * Version 1: |
| 37 | * gFM is magnitude of first partials and gFM2 is magnitude of 2nd partials (as derived from paper) |
| 38 | * builder->fsCodeAppend("\t\tedgeAlpha = (sqrt(gFM*gFM+4.0*func*gF2M) - gFM)/(2.0*gF2M);\n"); |
| 39 | * Version 2: |
| 40 | * builder->fsCodeAppend("\t\tedgeAlpha = (gFM - sqrt(gFM*gFM-4.0*func*gF2M))/(2.0*gF2M);\n"); |
| 41 | * |
| 42 | * Also note that 2nd partials of k,l,m are zero |
| 43 | * |
| 44 | * When comparing the two second order approximations to the first order approximations, |
| 45 | * the following results were found. Version 1 tends to underestimate the distances, thus it |
| 46 | * basically increases all the error that we were already seeing in the first order |
| 47 | * approx. So this version is not the one to use. Version 2 has the opposite effect |
| 48 | * and tends to overestimate the distances. This is much closer to what we are |
| 49 | * looking for. It is able to render ellipses (even thin ones) without the need to chop. |
| 50 | * However, it can not handle thin hyperbolas well and thus would still rely on |
| 51 | * chopping to tighten the clipping. Another side effect of the overestimating is |
| 52 | * that the curves become much thinner and "ropey". If all that was ever rendered |
| 53 | * were "not too thin" curves and ellipses then 2nd order may have an advantage since |
| 54 | * only one geometry would need to be rendered. However no benches were run comparing |
| 55 | * chopped first order and non chopped 2nd order. |
| 56 | */ |
| 57 | class GrGLConicEffect; |
| 58 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 59 | class GrConicEffect : public GrGeometryProcessor { |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 60 | public: |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 61 | static GrGeometryProcessor* Create(GrColor color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 62 | const SkMatrix& viewMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 63 | const GrPrimitiveEdgeType edgeType, |
| 64 | const GrDrawTargetCaps& caps, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 65 | const SkMatrix& localMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 66 | uint8_t coverage = 0xff) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 67 | switch (edgeType) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 68 | case kFillAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 69 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 70 | return NULL; |
| 71 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 72 | return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 73 | kFillAA_GrProcessorEdgeType, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 74 | localMatrix)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 75 | case kHairlineAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 76 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 77 | return NULL; |
| 78 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 79 | return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 80 | kHairlineAA_GrProcessorEdgeType, |
| 81 | localMatrix)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 82 | case kFillBW_GrProcessorEdgeType: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 83 | return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 84 | kFillBW_GrProcessorEdgeType, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 85 | localMatrix)); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 86 | default: |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 87 | return NULL; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | virtual ~GrConicEffect(); |
| 92 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 93 | const char* name() const override { return "Conic"; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 94 | |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 95 | inline const Attribute* inPosition() const { return fInPosition; } |
| 96 | inline const Attribute* inConicCoeffs() const { return fInConicCoeffs; } |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 97 | inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } |
| 98 | inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } |
| 99 | inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 100 | GrColor color() const { return fColor; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 101 | |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 102 | virtual void getGLProcessorKey(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 103 | const GrGLSLCaps& caps, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 104 | GrProcessorKeyBuilder* b) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 105 | |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 106 | virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 107 | const GrGLSLCaps&) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 108 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 109 | void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override; |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 110 | |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 111 | private: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 112 | GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType, |
| 113 | const SkMatrix& localMatrix); |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 114 | |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 115 | GrColor fColor; |
| 116 | uint8_t fCoverageScale; |
| 117 | GrPrimitiveEdgeType fEdgeType; |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 118 | const Attribute* fInPosition; |
| 119 | const Attribute* fInConicCoeffs; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 120 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 121 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 122 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 123 | typedef GrGeometryProcessor INHERITED; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | /////////////////////////////////////////////////////////////////////////////// |
| 127 | /** |
| 128 | * The output of this effect is a hairline edge for quadratics. |
| 129 | * Quadratic specified by 0=u^2-v canonical coords. u and v are the first |
| 130 | * two components of the vertex attribute. At the three control points that define |
| 131 | * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. |
| 132 | * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
| 133 | * Requires shader derivative instruction support. |
| 134 | */ |
| 135 | class GrGLQuadEffect; |
| 136 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 137 | class GrQuadEffect : public GrGeometryProcessor { |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 138 | public: |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 139 | static GrGeometryProcessor* Create(GrColor color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 140 | const SkMatrix& viewMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 141 | const GrPrimitiveEdgeType edgeType, |
| 142 | const GrDrawTargetCaps& caps, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 143 | const SkMatrix& localMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 144 | uint8_t coverage = 0xff) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 145 | switch (edgeType) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 146 | case kFillAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 147 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 148 | return NULL; |
| 149 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 150 | return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 151 | kFillAA_GrProcessorEdgeType, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 152 | localMatrix)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 153 | case kHairlineAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 154 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 155 | return NULL; |
| 156 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 157 | return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 158 | kHairlineAA_GrProcessorEdgeType, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 159 | localMatrix)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 160 | case kFillBW_GrProcessorEdgeType: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 161 | return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 162 | kFillBW_GrProcessorEdgeType, |
joshualitt | d27f73e | 2014-12-29 07:43:36 -0800 | [diff] [blame] | 163 | localMatrix)); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 164 | default: |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 165 | return NULL; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | virtual ~GrQuadEffect(); |
| 170 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 171 | const char* name() const override { return "Quad"; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 172 | |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 173 | inline const Attribute* inPosition() const { return fInPosition; } |
| 174 | inline const Attribute* inHairQuadEdge() const { return fInHairQuadEdge; } |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 175 | inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } |
| 176 | inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } |
| 177 | inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 178 | GrColor color() const { return fColor; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 179 | |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 180 | virtual void getGLProcessorKey(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 181 | const GrGLSLCaps& caps, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 182 | GrProcessorKeyBuilder* b) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 183 | |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 184 | virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 185 | const GrGLSLCaps&) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 186 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 187 | void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override; |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 188 | |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 189 | private: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 190 | GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimitiveEdgeType, |
| 191 | const SkMatrix& localMatrix); |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 192 | |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 193 | GrColor fColor; |
| 194 | uint8_t fCoverageScale; |
| 195 | GrPrimitiveEdgeType fEdgeType; |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 196 | const Attribute* fInPosition; |
| 197 | const Attribute* fInHairQuadEdge; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 198 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 199 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 200 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 201 | typedef GrGeometryProcessor INHERITED; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 202 | }; |
| 203 | |
| 204 | ////////////////////////////////////////////////////////////////////////////// |
| 205 | /** |
| 206 | * Shader is based off of "Resolution Independent Curve Rendering using |
| 207 | * Programmable Graphics Hardware" by Loop and Blinn. |
| 208 | * The output of this effect is a hairline edge for non rational cubics. |
| 209 | * Cubics are specified by implicit equation K^3 - LM. |
| 210 | * K, L, and M, are the first three values of the vertex attribute, |
| 211 | * the fourth value is not used. Distance is calculated using a |
| 212 | * first order approximation from the taylor series. |
| 213 | * Coverage for AA is max(0, 1-distance). |
| 214 | */ |
| 215 | class GrGLCubicEffect; |
| 216 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 217 | class GrCubicEffect : public GrGeometryProcessor { |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 218 | public: |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 219 | static GrGeometryProcessor* Create(GrColor color, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 220 | const SkMatrix& viewMatrix, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 221 | const GrPrimitiveEdgeType edgeType, |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 222 | const GrDrawTargetCaps& caps) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 223 | switch (edgeType) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 224 | case kFillAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 225 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 226 | return NULL; |
| 227 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 228 | return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, kFillAA_GrProcessorEdgeType)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 229 | case kHairlineAA_GrProcessorEdgeType: |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 230 | if (!caps.shaderCaps()->shaderDerivativeSupport()) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 231 | return NULL; |
| 232 | } |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 233 | return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, |
| 234 | kHairlineAA_GrProcessorEdgeType)); |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 235 | case kFillBW_GrProcessorEdgeType: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 236 | return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, |
| 237 | kFillBW_GrProcessorEdgeType)); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 238 | default: |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 239 | return NULL; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | |
| 243 | virtual ~GrCubicEffect(); |
| 244 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 245 | const char* name() const override { return "Cubic"; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 246 | |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 247 | inline const Attribute* inPosition() const { return fInPosition; } |
| 248 | inline const Attribute* inCubicCoeffs() const { return fInCubicCoeffs; } |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 249 | inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); } |
| 250 | inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } |
| 251 | inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 252 | GrColor color() const { return fColor; } |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 253 | |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 254 | virtual void getGLProcessorKey(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 255 | const GrGLSLCaps& caps, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 256 | GrProcessorKeyBuilder* b) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 257 | |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 258 | virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 259 | const GrGLSLCaps&) const override; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 260 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 261 | void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override; |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 262 | |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 263 | private: |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 264 | GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType); |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 265 | |
joshualitt | 88c23fc | 2015-05-13 14:18:07 -0700 | [diff] [blame^] | 266 | GrColor fColor; |
| 267 | GrPrimitiveEdgeType fEdgeType; |
joshualitt | 71c9260 | 2015-01-14 08:12:47 -0800 | [diff] [blame] | 268 | const Attribute* fInPosition; |
| 269 | const Attribute* fInCubicCoeffs; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 270 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 271 | GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 272 | |
joshualitt | 249af15 | 2014-09-15 11:41:13 -0700 | [diff] [blame] | 273 | typedef GrGeometryProcessor INHERITED; |
commit-bot@chromium.org | 07e1c3f | 2013-08-22 20:41:15 +0000 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | #endif |