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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 float width = buffer.readScalar(); | 239 float width = buffer.readScalar(); |
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 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset, SkImageFilter* input) |
reed1
2014/07/08 15:15:24
nit: 100 col
Stephen White
2014/07/08 15:33:30
Fixed.
| |
250 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset) | 250 : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) { |
251 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { | |
252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 251 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
253 } | 252 } |
254 | 253 |
255 #if SK_SUPPORT_GPU | 254 #if SK_SUPPORT_GPU |
256 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&, const SkIRect&) const { | 255 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&, const SkIRect&) const { |
257 if (effect) { | 256 if (effect) { |
258 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr cRect.y() : | 257 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr cRect.y() : |
259 (texture->height() - (fSrcRect.y() + fSrcRect.height( ))); | 258 (texture->height() - (fSrcRect.y() + fSrcRect.height( ))); |
260 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; | 259 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; |
261 *effect = GrMagnifierEffect::Create(texture, | 260 *effect = GrMagnifierEffect::Create(texture, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 | 340 |
342 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 341 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
343 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 342 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
344 | 343 |
345 *dptr = sptr[y_val * width + x_val]; | 344 *dptr = sptr[y_val * width + x_val]; |
346 dptr++; | 345 dptr++; |
347 } | 346 } |
348 } | 347 } |
349 return true; | 348 return true; |
350 } | 349 } |
OLD | NEW |