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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 float fYOffset; | 82 float fYOffset; |
83 float fXInvZoom; | 83 float fXInvZoom; |
84 float fYInvZoom; | 84 float fYInvZoom; |
85 float fXInvInset; | 85 float fXInvInset; |
86 float fYInvInset; | 86 float fYInvInset; |
87 | 87 |
88 typedef GrSingleTextureEffect INHERITED; | 88 typedef GrSingleTextureEffect INHERITED; |
89 }; | 89 }; |
90 | 90 |
91 // For brevity | 91 // For brevity |
92 typedef GrGLUniformManager::UniformHandle UniformHandle; | 92 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
93 | 93 |
94 class GrGLMagnifierEffect : public GrGLEffect { | 94 class GrGLMagnifierEffect : public GrGLEffect { |
95 public: | 95 public: |
96 GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 96 GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
97 | 97 |
98 virtual void emitCode(GrGLShaderBuilder*, | 98 virtual void emitCode(GrGLShaderBuilder*, |
99 const GrDrawEffect&, | 99 const GrDrawEffect&, |
100 const GrEffectKey&, | 100 const GrEffectKey&, |
101 const char* outputColor, | 101 const char* outputColor, |
102 const char* inputColor, | 102 const char* inputColor, |
103 const TransformedCoordsArray&, | 103 const TransformedCoordsArray&, |
104 const TextureSamplerArray&) SK_OVERRIDE; | 104 const TextureSamplerArray&) SK_OVERRIDE; |
105 | 105 |
106 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 106 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
107 | 107 |
108 private: | 108 private: |
109 UniformHandle fOffsetVar; | 109 UniformHandle fOffsetVar; |
110 UniformHandle fInvZoomVar; | 110 UniformHandle fInvZoomVar; |
111 UniformHandle fInvInsetVar; | 111 UniformHandle fInvInsetVar; |
112 | 112 |
113 typedef GrGLEffect INHERITED; | 113 typedef GrGLEffect INHERITED; |
114 }; | 114 }; |
115 | 115 |
116 GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
const GrDrawEffect&) | 116 GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
const GrDrawEffect&) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 builder->fsCodeAppend("\t\tvec4 output_color = "); | 163 builder->fsCodeAppend("\t\tvec4 output_color = "); |
164 builder->fsAppendTextureLookup(samplers[0], "mix_coord"); | 164 builder->fsAppendTextureLookup(samplers[0], "mix_coord"); |
165 builder->fsCodeAppend(";\n"); | 165 builder->fsCodeAppend(";\n"); |
166 | 166 |
167 builder->fsCodeAppendf("\t\t%s = output_color;", outputColor); | 167 builder->fsCodeAppendf("\t\t%s = output_color;", outputColor); |
168 SkString modulate; | 168 SkString modulate; |
169 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); | 169 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); |
170 builder->fsCodeAppend(modulate.c_str()); | 170 builder->fsCodeAppend(modulate.c_str()); |
171 } | 171 } |
172 | 172 |
173 void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman, | 173 void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman, |
174 const GrDrawEffect& drawEffect) { | 174 const GrDrawEffect& drawEffect) { |
175 const GrMagnifierEffect& zoom = drawEffect.castEffect<GrMagnifierEffect>(); | 175 const GrMagnifierEffect& zoom = drawEffect.castEffect<GrMagnifierEffect>(); |
176 uman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); | 176 pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); |
177 uman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); | 177 pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); |
178 uman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); | 178 pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset()); |
179 } | 179 } |
180 | 180 |
181 ///////////////////////////////////////////////////////////////////// | 181 ///////////////////////////////////////////////////////////////////// |
182 | 182 |
183 GR_DEFINE_EFFECT_TEST(GrMagnifierEffect); | 183 GR_DEFINE_EFFECT_TEST(GrMagnifierEffect); |
184 | 184 |
185 GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random, | 185 GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random, |
186 GrContext* context, | 186 GrContext* context, |
187 const GrDrawTargetCaps&, | 187 const GrDrawTargetCaps&, |
188 GrTexture** textures) { | 188 GrTexture** textures) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 343 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
344 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 344 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
345 | 345 |
346 *dptr = sptr[y_val * width + x_val]; | 346 *dptr = sptr[y_val * width + x_val]; |
347 dptr++; | 347 dptr++; |
348 } | 348 } |
349 } | 349 } |
350 return true; | 350 return true; |
351 } | 351 } |
OLD | NEW |