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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 SkScalar sqDist = SkMinScalar(SkScalarSquare(x_dist), | 354 SkScalar sqDist = SkMinScalar(SkScalarSquare(x_dist), |
355 SkScalarSquare(y_dist)); | 355 SkScalarSquare(y_dist)); |
356 weight = SkMinScalar(sqDist, SK_Scalar1); | 356 weight = SkMinScalar(sqDist, SK_Scalar1); |
357 } | 357 } |
358 | 358 |
359 SkScalar x_interp = SkScalarMul(weight, (fSrcRect.x() + x * inv_x_zo
om)) + | 359 SkScalar x_interp = SkScalarMul(weight, (fSrcRect.x() + x * inv_x_zo
om)) + |
360 (SK_Scalar1 - weight) * x; | 360 (SK_Scalar1 - weight) * x; |
361 SkScalar y_interp = SkScalarMul(weight, (fSrcRect.y() + y * inv_y_zo
om)) + | 361 SkScalar y_interp = SkScalarMul(weight, (fSrcRect.y() + y * inv_y_zo
om)) + |
362 (SK_Scalar1 - weight) * y; | 362 (SK_Scalar1 - weight) * y; |
363 | 363 |
364 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 364 int x_val = SkTPin(SkScalarFloorToInt(x_interp), 0, width - 1); |
365 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 365 int y_val = SkTPin(SkScalarFloorToInt(y_interp), 0, height - 1); |
366 | 366 |
367 *dptr = sptr[y_val * width + x_val]; | 367 *dptr = sptr[y_val * width + x_val]; |
368 dptr++; | 368 dptr++; |
369 } | 369 } |
370 } | 370 } |
371 return true; | 371 return true; |
372 } | 372 } |
373 | 373 |
374 #ifndef SK_IGNORE_TO_STRING | 374 #ifndef SK_IGNORE_TO_STRING |
375 void SkMagnifierImageFilter::toString(SkString* str) const { | 375 void SkMagnifierImageFilter::toString(SkString* str) const { |
376 str->appendf("SkMagnifierImageFilter: ("); | 376 str->appendf("SkMagnifierImageFilter: ("); |
377 str->appendf("src: (%f,%f,%f,%f) ", | 377 str->appendf("src: (%f,%f,%f,%f) ", |
378 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); | 378 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m); |
379 str->appendf("inset: %f", fInset); | 379 str->appendf("inset: %f", fInset); |
380 str->append(")"); | 380 str->append(")"); |
381 } | 381 } |
382 #endif | 382 #endif |
OLD | NEW |