| 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 #include "GrConvexPolyEffect.h" | 8 #include "GrConvexPolyEffect.h" |
| 9 | 9 |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 builder->fsCodeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); | 68 builder->fsCodeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n"); |
| 69 builder->fsCodeAppend("\t\talpha *= edge;\n"); | 69 builder->fsCodeAppend("\t\talpha *= edge;\n"); |
| 70 break; | 70 break; |
| 71 case GrConvexPolyEffect::kFillNoAA_EdgeType: | 71 case GrConvexPolyEffect::kFillNoAA_EdgeType: |
| 72 builder->fsCodeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); | 72 builder->fsCodeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n"); |
| 73 builder->fsCodeAppend("\t\talpha *= edge;\n"); | 73 builder->fsCodeAppend("\t\talpha *= edge;\n"); |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Woe is me. See skbug.com/2149. |
| 79 if (kTegra2_GrGLRenderer == builder->ctxInfo().renderer()) { |
| 80 builder->fsCodeAppend("\t\tif (-1.0 == alpha) {\n\t\t\tdiscard;\n\t\t}\n
"); |
| 81 } |
| 78 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 82 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
| 79 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); | 83 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void GrGLConvexPolyEffect::setData(const GrGLUniformManager& uman, const GrDrawE
ffect& drawEffect) { | 86 void GrGLConvexPolyEffect::setData(const GrGLUniformManager& uman, const GrDrawE
ffect& drawEffect) { |
| 83 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>(); | 87 const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>(); |
| 84 size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar); | 88 size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar); |
| 85 if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) { | 89 if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) { |
| 86 uman.set3fv(fEdgeUniform, cpe.getEdgeCount(), cpe.getEdges()); | 90 uman.set3fv(fEdgeUniform, cpe.getEdgeCount(), cpe.getEdges()); |
| 87 memcpy(fPrevEdges, cpe.getEdges(), byteSize); | 91 memcpy(fPrevEdges, cpe.getEdges(), byteSize); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 GrTexture*[]) { | 179 GrTexture*[]) { |
| 176 EdgeType edgeType = static_cast<EdgeType>(random->nextULessThan(kEdgeTypeCnt
)); | 180 EdgeType edgeType = static_cast<EdgeType>(random->nextULessThan(kEdgeTypeCnt
)); |
| 177 int count = random->nextULessThan(kMaxEdges) + 1; | 181 int count = random->nextULessThan(kMaxEdges) + 1; |
| 178 SkScalar edges[kMaxEdges * 3]; | 182 SkScalar edges[kMaxEdges * 3]; |
| 179 for (int i = 0; i < 3 * count; ++i) { | 183 for (int i = 0; i < 3 * count; ++i) { |
| 180 edges[i] = random->nextSScalar1(); | 184 edges[i] = random->nextSScalar1(); |
| 181 } | 185 } |
| 182 | 186 |
| 183 return GrConvexPolyEffect::Create(edgeType, count, edges); | 187 return GrConvexPolyEffect::Create(edgeType, count, edges); |
| 184 } | 188 } |
| OLD | NEW |