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 "SkMagnifierImageFilter.h" | 8 #include "SkMagnifierImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 kVec2f_GrSLType, kDefault_GrSLPreci
sion, | 128 kVec2f_GrSLType, kDefault_GrSLPreci
sion, |
129 "InvZoom"); | 129 "InvZoom"); |
130 fInvInsetVar = uniformHandler->addUniform(kFragment_GrShaderFlag, | 130 fInvInsetVar = uniformHandler->addUniform(kFragment_GrShaderFlag, |
131 kVec2f_GrSLType, kDefault_GrSLPrec
ision, | 131 kVec2f_GrSLType, kDefault_GrSLPrec
ision, |
132 "InvInset"); | 132 "InvInset"); |
133 fBoundsVar = uniformHandler->addUniform(kFragment_GrShaderFlag, | 133 fBoundsVar = uniformHandler->addUniform(kFragment_GrShaderFlag, |
134 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, | 134 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, |
135 "Bounds"); | 135 "Bounds"); |
136 | 136 |
137 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 137 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
138 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 138 SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); |
139 fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); | 139 fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); |
140 fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", | 140 fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", |
141 uniformHandler->getUniformCStr(fOffsetVar), | 141 uniformHandler->getUniformCStr(fOffsetVar), |
142 coords2D.c_str(), | 142 coords2D.c_str(), |
143 uniformHandler->getUniformCStr(fInvZoomVar)); | 143 uniformHandler->getUniformCStr(fInvZoomVar)); |
144 const char* bounds = uniformHandler->getUniformCStr(fBoundsVar); | 144 const char* bounds = uniformHandler->getUniformCStr(fBoundsVar); |
145 fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", boun
ds, bounds); | 145 fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", boun
ds, bounds); |
146 fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n"
); | 146 fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n"
); |
147 fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n", | 147 fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n", |
148 uniformHandler->getUniformCStr(fInvInsetVar)); | 148 uniformHandler->getUniformCStr(fInvInsetVar)); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 #ifndef SK_IGNORE_TO_STRING | 415 #ifndef SK_IGNORE_TO_STRING |
416 void SkMagnifierImageFilter::toString(SkString* str) const { | 416 void SkMagnifierImageFilter::toString(SkString* str) const { |
417 str->appendf("SkMagnifierImageFilter: ("); | 417 str->appendf("SkMagnifierImageFilter: ("); |
418 str->appendf("src: (%f,%f,%f,%f) ", | 418 str->appendf("src: (%f,%f,%f,%f) ", |
419 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 419 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
420 str->appendf("inset: %f", fInset); | 420 str->appendf("inset: %f", fInset); |
421 str->append(")"); | 421 str->append(")"); |
422 } | 422 } |
423 #endif | 423 #endif |
OLD | NEW |