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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 //////////////////////////////////////////////////////////////////////////////// | 246 //////////////////////////////////////////////////////////////////////////////// |
247 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) | 247 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) |
248 : INHERITED(buffer) { | 248 : INHERITED(buffer) { |
249 float x = buffer.readScalar(); | 249 float x = buffer.readScalar(); |
250 float y = buffer.readScalar(); | 250 float y = buffer.readScalar(); |
251 float width = buffer.readScalar(); | 251 float width = buffer.readScalar(); |
252 float height = buffer.readScalar(); | 252 float height = buffer.readScalar(); |
253 fSrcRect = SkRect::MakeXYWH(x, y, width, height); | 253 fSrcRect = SkRect::MakeXYWH(x, y, width, height); |
254 fInset = buffer.readScalar(); | 254 fInset = buffer.readScalar(); |
| 255 |
| 256 buffer.validateData(fSrcRect.isValid() && SkScalarIsFinite(fInset)); |
255 } | 257 } |
256 | 258 |
257 // FIXME: implement single-input semantics | 259 // FIXME: implement single-input semantics |
258 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) | 260 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) |
259 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { | 261 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { |
260 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 262 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
261 } | 263 } |
262 | 264 |
263 #if SK_SUPPORT_GPU | 265 #if SK_SUPPORT_GPU |
264 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkMatrix&) const { | 266 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkMatrix&) const { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 344 |
343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); | 345 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); |
344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); | 346 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); |
345 | 347 |
346 *dptr = sptr[y_val * width + x_val]; | 348 *dptr = sptr[y_val * width + x_val]; |
347 dptr++; | 349 dptr++; |
348 } | 350 } |
349 } | 351 } |
350 return true; | 352 return true; |
351 } | 353 } |
OLD | NEW |