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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 uint32_t x = random->nextULessThan(kMaxWidth - width); | 211 uint32_t x = random->nextULessThan(kMaxWidth - width); |
212 uint32_t y = random->nextULessThan(kMaxHeight - height); | 212 uint32_t y = random->nextULessThan(kMaxHeight - height); |
213 SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset)); | 213 SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset)); |
214 | 214 |
215 SkAutoTUnref<SkMagnifierImageFilter> filter( | 215 SkAutoTUnref<SkMagnifierImageFilter> filter( |
216 new SkMagnifierImageFilter( | 216 new SkMagnifierImageFilter( |
217 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), | 217 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), |
218 SkIntToScalar(width), SkIntToScalar(height)), | 218 SkIntToScalar(width), SkIntToScalar(height)), |
219 inset)); | 219 inset)); |
220 GrEffectRef* effect; | 220 GrEffectRef* effect; |
221 filter->asNewEffect(&effect, textures[0]); | 221 filter->asNewEffect(&effect, textures[0], SkIPoint::Make(0, 0)); |
222 GrAssert(NULL != effect); | 222 GrAssert(NULL != effect); |
223 return effect; | 223 return effect; |
224 } | 224 } |
225 | 225 |
226 /////////////////////////////////////////////////////////////////////////////// | 226 /////////////////////////////////////////////////////////////////////////////// |
227 | 227 |
228 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const { | 228 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const { |
229 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance(); | 229 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance(); |
230 } | 230 } |
231 | 231 |
(...skipping 25 matching lines...) Expand all Loading... |
257 fInset = buffer.readScalar(); | 257 fInset = buffer.readScalar(); |
258 } | 258 } |
259 | 259 |
260 // FIXME: implement single-input semantics | 260 // FIXME: implement single-input semantics |
261 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) | 261 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) |
262 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { | 262 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { |
263 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 263 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
264 } | 264 } |
265 | 265 |
266 #if SK_SUPPORT_GPU | 266 #if SK_SUPPORT_GPU |
267 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e) const { | 267 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkIPoint&) const { |
268 if (effect) { | 268 if (effect) { |
269 *effect = GrMagnifierEffect::Create(texture, | 269 *effect = GrMagnifierEffect::Create(texture, |
270 fSrcRect.x() / texture->width(), | 270 fSrcRect.x() / texture->width(), |
271 fSrcRect.y() / texture->height(), | 271 fSrcRect.y() / texture->height(), |
272 texture->width() / fSrcRect.width(), | 272 texture->width() / fSrcRect.width(), |
273 texture->height() / fSrcRect.height(
), | 273 texture->height() / fSrcRect.height(
), |
274 fInset / texture->width(), | 274 fInset / texture->width(), |
275 fInset / texture->height()); | 275 fInset / texture->height()); |
276 } | 276 } |
277 return true; | 277 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); | 346 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); |
347 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); | 347 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); |
348 | 348 |
349 *dptr = sptr[y_val * width + x_val]; | 349 *dptr = sptr[y_val * width + x_val]; |
350 dptr++; | 350 dptr++; |
351 } | 351 } |
352 } | 352 } |
353 return true; | 353 return true; |
354 } | 354 } |
OLD | NEW |