| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkNormalBevelSource.h" | 8 #include "SkNormalBevelSource.h" |
| 9 | 9 |
| 10 #include "SkNormalSource.h" | 10 #include "SkNormalSource.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 "NormalizedWidt
h", | 79 "NormalizedWidt
h", |
| 80 &normalizedWidt
hUniName); | 80 &normalizedWidt
hUniName); |
| 81 fNormalizedHeightUni = uniformHandler->addUniform(kFragment_GrSh
aderFlag, | 81 fNormalizedHeightUni = uniformHandler->addUniform(kFragment_GrSh
aderFlag, |
| 82 kFloat_GrSLTyp
e, | 82 kFloat_GrSLTyp
e, |
| 83 kDefault_GrSLP
recision, | 83 kDefault_GrSLP
recision, |
| 84 "NormalizedHei
ght", | 84 "NormalizedHei
ght", |
| 85 &normalizedHei
ghtUniName); | 85 &normalizedHei
ghtUniName); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Here we are splitting the distance vector into length and normali
zed direction | 88 // Here we are splitting the distance vector into length and normali
zed direction |
| 89 // TODO: Output these values from the geometry processor frag code i
nstead of the vector | 89 fragBuilder->codeAppendf("float dv_length = %s.z;", |
| 90 fragBuilder->codeAppendf("float dv_length = length(%s);", | |
| 91 fragBuilder->distanceVectorName()); | 90 fragBuilder->distanceVectorName()); |
| 92 fragBuilder->codeAppendf("vec2 dv_norm = normalize(%s);", | 91 fragBuilder->codeAppendf("vec2 dv_norm = %s.xy;", |
| 93 fragBuilder->distanceVectorName()); | 92 fragBuilder->distanceVectorName()); |
| 94 | 93 |
| 95 // Asserting presence of necessary uniforms | 94 // Asserting presence of necessary uniforms |
| 96 SkASSERT(widthUniName); | 95 SkASSERT(widthUniName); |
| 97 | 96 |
| 98 fragBuilder->codeAppend( "vec3 normal;"); | 97 fragBuilder->codeAppend( "vec3 normal;"); |
| 99 fragBuilder->codeAppendf("if (dv_length >= %s) {", widthUniName); | 98 fragBuilder->codeAppendf("if (dv_length >= %s) {", widthUniName); |
| 100 fragBuilder->codeAppend( " normal = vec3(0.0, 0.0, 1.0);"); | 99 fragBuilder->codeAppend( " normal = vec3(0.0, 0.0, 1.0);"); |
| 101 fragBuilder->codeAppend( "} else {"); | 100 fragBuilder->codeAppend( "} else {"); |
| 102 this->emitMath(fragBuilder, fp.fBevelType, widthUniName, heightUniNa
me, | 101 this->emitMath(fragBuilder, fp.fBevelType, widthUniName, heightUniNa
me, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 sk_sp<SkNormalSource> SkNormalSource::MakeBevel(BevelType type, SkScalar width,
SkScalar height) { | 299 sk_sp<SkNormalSource> SkNormalSource::MakeBevel(BevelType type, SkScalar width,
SkScalar height) { |
| 301 /* TODO make sure this checks are tolerant enough to account for loss of con
version when GPUs | 300 /* TODO make sure this checks are tolerant enough to account for loss of con
version when GPUs |
| 302 use 16-bit float types. We don't want to assume stuff is non-zero on the
GPU and be wrong.*/ | 301 use 16-bit float types. We don't want to assume stuff is non-zero on the
GPU and be wrong.*/ |
| 303 SkASSERT(width > 0.0f && !SkScalarNearlyZero(width)); | 302 SkASSERT(width > 0.0f && !SkScalarNearlyZero(width)); |
| 304 if (SkScalarNearlyZero(height)) { | 303 if (SkScalarNearlyZero(height)) { |
| 305 return SkNormalSource::MakeFlat(); | 304 return SkNormalSource::MakeFlat(); |
| 306 } | 305 } |
| 307 | 306 |
| 308 return sk_make_sp<SkNormalBevelSourceImpl>(type, width, height); | 307 return sk_make_sp<SkNormalBevelSourceImpl>(type, width, height); |
| 309 } | 308 } |
| OLD | NEW |