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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 fInvZoomVar = uniformHandler->addUniform(kFragment_GrShaderFlag, | 122 fInvZoomVar = uniformHandler->addUniform(kFragment_GrShaderFlag, |
123 kVec2f_GrSLType, kDefault_GrSLPreci
sion, | 123 kVec2f_GrSLType, kDefault_GrSLPreci
sion, |
124 "InvZoom"); | 124 "InvZoom"); |
125 fInvInsetVar = uniformHandler->addUniform(kFragment_GrShaderFlag, | 125 fInvInsetVar = uniformHandler->addUniform(kFragment_GrShaderFlag, |
126 kVec2f_GrSLType, kDefault_GrSLPrec
ision, | 126 kVec2f_GrSLType, kDefault_GrSLPrec
ision, |
127 "InvInset"); | 127 "InvInset"); |
128 fBoundsVar = uniformHandler->addUniform(kFragment_GrShaderFlag, | 128 fBoundsVar = uniformHandler->addUniform(kFragment_GrShaderFlag, |
129 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, | 129 kVec4f_GrSLType, kDefault_GrSLPrecis
ion, |
130 "Bounds"); | 130 "Bounds"); |
131 | 131 |
132 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 132 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
133 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 133 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
134 fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); | 134 fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); |
135 fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", | 135 fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", |
136 uniformHandler->getUniformCStr(fOffsetVar), | 136 uniformHandler->getUniformCStr(fOffsetVar), |
137 coords2D.c_str(), | 137 coords2D.c_str(), |
138 uniformHandler->getUniformCStr(fInvZoomVar)); | 138 uniformHandler->getUniformCStr(fInvZoomVar)); |
139 const char* bounds = uniformHandler->getUniformCStr(fBoundsVar); | 139 const char* bounds = uniformHandler->getUniformCStr(fBoundsVar); |
140 fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", boun
ds, bounds); | 140 fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", boun
ds, bounds); |
141 fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n"
); | 141 fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n"
); |
142 fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n", | 142 fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n", |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 #ifndef SK_IGNORE_TO_STRING | 366 #ifndef SK_IGNORE_TO_STRING |
367 void SkMagnifierImageFilter::toString(SkString* str) const { | 367 void SkMagnifierImageFilter::toString(SkString* str) const { |
368 str->appendf("SkMagnifierImageFilter: ("); | 368 str->appendf("SkMagnifierImageFilter: ("); |
369 str->appendf("src: (%f,%f,%f,%f) ", | 369 str->appendf("src: (%f,%f,%f,%f) ", |
370 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 370 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
371 str->appendf("inset: %f", fInset); | 371 str->appendf("inset: %f", fInset); |
372 str->append(")"); | 372 str->append(")"); |
373 } | 373 } |
374 #endif | 374 #endif |
OLD | NEW |