| 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" |
| 11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
| 12 #include "SkValidationUtils.h" |
| 12 | 13 |
| 13 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
| 14 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 15 #include "effects/GrSingleTextureEffect.h" | 16 #include "effects/GrSingleTextureEffect.h" |
| 16 #include "gl/GrGLEffect.h" | 17 #include "gl/GrGLEffect.h" |
| 17 #include "gl/GrGLEffectMatrix.h" | 18 #include "gl/GrGLEffectMatrix.h" |
| 18 #include "gl/GrGLSL.h" | 19 #include "gl/GrGLSL.h" |
| 19 #include "gl/GrGLTexture.h" | 20 #include "gl/GrGLTexture.h" |
| 20 #include "GrTBackendEffectFactory.h" | 21 #include "GrTBackendEffectFactory.h" |
| 21 | 22 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 246 |
| 246 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
| 247 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) | 248 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) |
| 248 : INHERITED(buffer) { | 249 : INHERITED(buffer) { |
| 249 float x = buffer.readScalar(); | 250 float x = buffer.readScalar(); |
| 250 float y = buffer.readScalar(); | 251 float y = buffer.readScalar(); |
| 251 float width = buffer.readScalar(); | 252 float width = buffer.readScalar(); |
| 252 float height = buffer.readScalar(); | 253 float height = buffer.readScalar(); |
| 253 fSrcRect = SkRect::MakeXYWH(x, y, width, height); | 254 fSrcRect = SkRect::MakeXYWH(x, y, width, height); |
| 254 fInset = buffer.readScalar(); | 255 fInset = buffer.readScalar(); |
| 256 |
| 257 buffer.validateData(SkIsValidRect(fSrcRect) && SkScalarIsFinite(fInset)); |
| 255 } | 258 } |
| 256 | 259 |
| 257 // FIXME: implement single-input semantics | 260 // FIXME: implement single-input semantics |
| 258 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) | 261 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) |
| 259 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { | 262 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { |
| 260 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); | 263 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); |
| 261 } | 264 } |
| 262 | 265 |
| 263 #if SK_SUPPORT_GPU | 266 #if SK_SUPPORT_GPU |
| 264 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur
e, const SkMatrix&) const { | 267 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 | 345 |
| 343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); | 346 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); |
| 344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); | 347 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); |
| 345 | 348 |
| 346 *dptr = sptr[y_val * width + x_val]; | 349 *dptr = sptr[y_val * width + x_val]; |
| 347 dptr++; | 350 dptr++; |
| 348 } | 351 } |
| 349 } | 352 } |
| 350 return true; | 353 return true; |
| 351 } | 354 } |
| OLD | NEW |