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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 builder->fsCodeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectName,
fragmentPos); | 136 builder->fsCodeAppendf("\t\txSub += min(%s.z - %s.x, 0.0);\n", rectName,
fragmentPos); |
137 builder->fsCodeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragmentPo
s, rectName); | 137 builder->fsCodeAppendf("\t\tySub = min(%s.y - %s.y, 0.0);\n", fragmentPo
s, rectName); |
138 builder->fsCodeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectName,
fragmentPos); | 138 builder->fsCodeAppendf("\t\tySub += min(%s.w - %s.y, 0.0);\n", rectName,
fragmentPos); |
139 // Now compute coverage in x and y and multiply them to get the fraction
of the pixel | 139 // Now compute coverage in x and y and multiply them to get the fraction
of the pixel |
140 // covered. | 140 // covered. |
141 builder->fsCodeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0
+ max(ySub, -1.0));\n"); | 141 builder->fsCodeAppendf("\t\tfloat alpha = (1.0 + max(xSub, -1.0)) * (1.0
+ max(ySub, -1.0));\n"); |
142 } else { | 142 } else { |
143 builder->fsCodeAppendf("\t\tfloat alpha = 1.0;\n"); | 143 builder->fsCodeAppendf("\t\tfloat alpha = 1.0;\n"); |
144 builder->fsCodeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n
", fragmentPos, rectName); | 144 builder->fsCodeAppendf("\t\talpha *= (%s.x - %s.x) > -0.5 ? 1.0 : 0.0;\n
", fragmentPos, rectName); |
145 builder->fsCodeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n
", rectName, fragmentPos); | 145 builder->fsCodeAppendf("\t\talpha *= (%s.z - %s.x) > -0.5 ? 1.0 : 0.0;\n
", rectName, fragmentPos); |
146 builder->fsCodeAppendf("\t\talpha *= (%s.y - %s.y) > 0.5 ? 1.0 : 0.0;\n"
, fragmentPos, rectName); | 146 builder->fsCodeAppendf("\t\talpha *= (%s.y - %s.y) > -0.5 ? 1.0 : 0.0;\n
", fragmentPos, rectName); |
147 builder->fsCodeAppendf("\t\talpha *= (%s.w - %s.y) > 0.5 ? 1.0 : 0.0;\n"
, rectName, fragmentPos); | 147 builder->fsCodeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n
", rectName, fragmentPos); |
148 } | 148 } |
149 | 149 |
150 if (GrEffectEdgeTypeIsInverseFill(aare.getEdgeType())) { | 150 if (GrEffectEdgeTypeIsInverseFill(aare.getEdgeType())) { |
151 builder->fsCodeAppend("\t\talpha = 1.0 - alpha;\n"); | 151 builder->fsCodeAppend("\t\talpha = 1.0 - alpha;\n"); |
152 } | 152 } |
153 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, | 153 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, |
154 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); | 154 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); |
155 } | 155 } |
156 | 156 |
157 void GLAARectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect&
drawEffect) { | 157 void GLAARectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect&
drawEffect) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 } | 365 } |
366 | 366 |
367 GrEffectRef* effect; | 367 GrEffectRef* effect; |
368 do { | 368 do { |
369 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( | 369 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( |
370 random->nextULessThan(kGrEffectEdgeTypeC
nt)); | 370 random->nextULessThan(kGrEffectEdgeTypeC
nt)); |
371 effect = GrConvexPolyEffect::Create(edgeType, count, edges); | 371 effect = GrConvexPolyEffect::Create(edgeType, count, edges); |
372 } while (NULL == effect); | 372 } while (NULL == effect); |
373 return effect; | 373 return effect; |
374 } | 374 } |
OLD | NEW |