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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 fsBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared
.y), 1.0);\n"); | 161 fsBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared
.y), 1.0);\n"); |
162 fsBuilder->codeAppend("\t\t}\n"); | 162 fsBuilder->codeAppend("\t\t}\n"); |
163 | 163 |
164 fsBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\
n"); | 164 fsBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\
n"); |
165 fsBuilder->codeAppend("\t\tvec4 output_color = "); | 165 fsBuilder->codeAppend("\t\tvec4 output_color = "); |
166 fsBuilder->appendTextureLookup(samplers[0], "mix_coord"); | 166 fsBuilder->appendTextureLookup(samplers[0], "mix_coord"); |
167 fsBuilder->codeAppend(";\n"); | 167 fsBuilder->codeAppend(";\n"); |
168 | 168 |
169 fsBuilder->codeAppendf("\t\t%s = output_color;", outputColor); | 169 fsBuilder->codeAppendf("\t\t%s = output_color;", outputColor); |
170 SkString modulate; | 170 SkString modulate; |
171 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); | 171 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); |
172 fsBuilder->codeAppend(modulate.c_str()); | 172 fsBuilder->codeAppend(modulate.c_str()); |
173 } | 173 } |
174 | 174 |
175 void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman, | 175 void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman, |
176 const GrProcessor& effect) { | 176 const GrProcessor& effect) { |
177 const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>(); | 177 const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>(); |
178 pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); | 178 pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); |
179 pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); | 179 pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); |
180 pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); | 180 pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); |
181 } | 181 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 367 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
368 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 368 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
369 | 369 |
370 *dptr = sptr[y_val * width + x_val]; | 370 *dptr = sptr[y_val * width + x_val]; |
371 dptr++; | 371 dptr++; |
372 } | 372 } |
373 } | 373 } |
374 return true; | 374 return true; |
375 } | 375 } |
OLD | NEW |