| 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 "SkReadBuffer.h" |
| 12 #include "SkWriteBuffer.h" |
| 12 #include "SkValidationUtils.h" | 13 #include "SkValidationUtils.h" |
| 13 | 14 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 15 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
| 16 #include "effects/GrSingleTextureEffect.h" | 17 #include "effects/GrSingleTextureEffect.h" |
| 17 #include "gl/GrGLEffect.h" | 18 #include "gl/GrGLEffect.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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 this->fYInvInset == s.fYInvInset); | 225 this->fYInvInset == s.fYInvInset); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* val
idFlags) const { | 228 void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* val
idFlags) const { |
| 228 this->updateConstantColorComponentsForModulation(color, validFlags); | 229 this->updateConstantColorComponentsForModulation(color, validFlags); |
| 229 } | 230 } |
| 230 | 231 |
| 231 #endif | 232 #endif |
| 232 | 233 |
| 233 //////////////////////////////////////////////////////////////////////////////// | 234 //////////////////////////////////////////////////////////////////////////////// |
| 234 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) | 235 SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer) |
| 235 : INHERITED(1, buffer) { | 236 : INHERITED(1, buffer) { |
| 236 float x = buffer.readScalar(); | 237 float x = buffer.readScalar(); |
| 237 float y = buffer.readScalar(); | 238 float y = buffer.readScalar(); |
| 238 float width = buffer.readScalar(); | 239 float width = buffer.readScalar(); |
| 239 float height = buffer.readScalar(); | 240 float height = buffer.readScalar(); |
| 240 fSrcRect = SkRect::MakeXYWH(x, y, width, height); | 241 fSrcRect = SkRect::MakeXYWH(x, y, width, height); |
| 241 fInset = buffer.readScalar(); | 242 fInset = buffer.readScalar(); |
| 242 | 243 |
| 243 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && | 244 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && |
| 244 // Negative numbers in src rect are not supported | 245 // Negative numbers in src rect are not supported |
| (...skipping 17 matching lines...) Expand all Loading... |
| 262 yOffset / texture->height(), | 263 yOffset / texture->height(), |
| 263 fSrcRect.width() / texture->width(), | 264 fSrcRect.width() / texture->width(), |
| 264 fSrcRect.height() / texture->height(
), | 265 fSrcRect.height() / texture->height(
), |
| 265 texture->width() * invInset, | 266 texture->width() * invInset, |
| 266 texture->height() * invInset); | 267 texture->height() * invInset); |
| 267 } | 268 } |
| 268 return true; | 269 return true; |
| 269 } | 270 } |
| 270 #endif | 271 #endif |
| 271 | 272 |
| 272 void SkMagnifierImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 273 void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 273 this->INHERITED::flatten(buffer); | 274 this->INHERITED::flatten(buffer); |
| 274 buffer.writeScalar(fSrcRect.x()); | 275 buffer.writeScalar(fSrcRect.x()); |
| 275 buffer.writeScalar(fSrcRect.y()); | 276 buffer.writeScalar(fSrcRect.y()); |
| 276 buffer.writeScalar(fSrcRect.width()); | 277 buffer.writeScalar(fSrcRect.width()); |
| 277 buffer.writeScalar(fSrcRect.height()); | 278 buffer.writeScalar(fSrcRect.height()); |
| 278 buffer.writeScalar(fInset); | 279 buffer.writeScalar(fInset); |
| 279 } | 280 } |
| 280 | 281 |
| 281 bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src, | 282 bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src, |
| 282 const SkMatrix&, SkBitmap* dst, | 283 const SkMatrix&, SkBitmap* dst, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 343 |
| 343 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 344 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
| 344 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 345 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
| 345 | 346 |
| 346 *dptr = sptr[y_val * width + x_val]; | 347 *dptr = sptr[y_val * width + x_val]; |
| 347 dptr++; | 348 dptr++; |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 return true; | 351 return true; |
| 351 } | 352 } |
| OLD | NEW |