| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 float height = buffer.readScalar(); | 240 float height = buffer.readScalar(); |
| 241 fSrcRect = SkRect::MakeXYWH(x, y, width, height); | 241 fSrcRect = SkRect::MakeXYWH(x, y, width, height); |
| 242 fInset = buffer.readScalar(); | 242 fInset = buffer.readScalar(); |
| 243 | 243 |
| 244 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && | 244 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && |
| 245 // Negative numbers in src rect are not supported | 245 // Negative numbers in src rect are not supported |
| 246 (fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0)); | 246 (fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0)); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // FIXME: implement single-input semantics | 249 // FIXME: implement single-input semantics |
| 250 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) | 250 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
nset) |
| 251 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { | 251 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { |
| 252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
| 253 } | 253 } |
| 254 | 254 |
| 255 #if SK_SUPPORT_GPU | 255 #if SK_SUPPORT_GPU |
| 256 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkMatrix&, const SkIRect&) const { | 256 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkMatrix&, const SkIRect&) const { |
| 257 if (effect) { | 257 if (effect) { |
| 258 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr
cRect.y() : | 258 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr
cRect.y() : |
| 259 (texture->height() - (fSrcRect.y() + fSrcRect.height(
))); | 259 (texture->height() - (fSrcRect.y() + fSrcRect.height(
))); |
| 260 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; | 260 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 344 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
| 345 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 345 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
| 346 | 346 |
| 347 *dptr = sptr[y_val * width + x_val]; | 347 *dptr = sptr[y_val * width + x_val]; |
| 348 dptr++; | 348 dptr++; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 return true; | 351 return true; |
| 352 } | 352 } |
| OLD | NEW |