OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkMagnifierImageFilter.h" | 9 #include "SkMagnifierImageFilter.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 fragBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n"); | 148 fragBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n"); |
149 fragBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n"); | 149 fragBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n"); |
150 fragBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n"); | 150 fragBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n"); |
151 fragBuilder->codeAppend("\t\t} else {\n"); | 151 fragBuilder->codeAppend("\t\t} else {\n"); |
152 fragBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n"); | 152 fragBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n"); |
153 fragBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squar
ed.y), 1.0);\n"); | 153 fragBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squar
ed.y), 1.0);\n"); |
154 fragBuilder->codeAppend("\t\t}\n"); | 154 fragBuilder->codeAppend("\t\t}\n"); |
155 | 155 |
156 fragBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight)
;\n"); | 156 fragBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight)
;\n"); |
157 fragBuilder->codeAppend("\t\tvec4 output_color = "); | 157 fragBuilder->codeAppend("\t\tvec4 output_color = "); |
158 fragBuilder->appendTextureLookup(args.fTexSamplers[0], "mix_coord"); | 158 fragBuilder->appendTextureLookup(uniformHandler->getSampler(args.fTexSampler
s[0]), "mix_coord"); |
159 fragBuilder->codeAppend(";\n"); | 159 fragBuilder->codeAppend(";\n"); |
160 | 160 |
161 fragBuilder->codeAppendf("\t\t%s = output_color;", args.fOutputColor); | 161 fragBuilder->codeAppendf("\t\t%s = output_color;", args.fOutputColor); |
162 SkString modulate; | 162 SkString modulate; |
163 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); | 163 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); |
164 fragBuilder->codeAppend(modulate.c_str()); | 164 fragBuilder->codeAppend(modulate.c_str()); |
165 } | 165 } |
166 | 166 |
167 void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 167 void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
168 const GrProcessor& effect) { | 168 const GrProcessor& effect) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 #ifndef SK_IGNORE_TO_STRING | 368 #ifndef SK_IGNORE_TO_STRING |
369 void SkMagnifierImageFilter::toString(SkString* str) const { | 369 void SkMagnifierImageFilter::toString(SkString* str) const { |
370 str->appendf("SkMagnifierImageFilter: ("); | 370 str->appendf("SkMagnifierImageFilter: ("); |
371 str->appendf("src: (%f,%f,%f,%f) ", | 371 str->appendf("src: (%f,%f,%f,%f) ", |
372 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 372 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
373 str->appendf("inset: %f", fInset); | 373 str->appendf("inset: %f", fInset); |
374 str->append(")"); | 374 str->append(")"); |
375 } | 375 } |
376 #endif | 376 #endif |
OLD | NEW |