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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 (fSrcRect.height() >= src.height())) { | 314 (fSrcRect.height() >= src.height())) { |
315 return false; | 315 return false; |
316 } | 316 } |
317 | 317 |
318 SkAutoLockPixels alp(src); | 318 SkAutoLockPixels alp(src); |
319 SkASSERT(src.getPixels()); | 319 SkASSERT(src.getPixels()); |
320 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { | 320 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { |
321 return false; | 321 return false; |
322 } | 322 } |
323 | 323 |
324 if (!dst->allocPixels(src.info())) { | 324 if (!dst->tryAllocPixels(src.info())) { |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
328 SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; | 328 SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; |
329 | 329 |
330 SkScalar inv_x_zoom = fSrcRect.width() / src.width(); | 330 SkScalar inv_x_zoom = fSrcRect.width() / src.width(); |
331 SkScalar inv_y_zoom = fSrcRect.height() / src.height(); | 331 SkScalar inv_y_zoom = fSrcRect.height() / src.height(); |
332 | 332 |
333 SkColor* sptr = src.getAddr32(0, 0); | 333 SkColor* sptr = src.getAddr32(0, 0); |
334 SkColor* dptr = dst->getAddr32(0, 0); | 334 SkColor* dptr = dst->getAddr32(0, 0); |
(...skipping 29 matching lines...) Expand all Loading... |
364 | 364 |
365 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 365 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
366 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 366 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
367 | 367 |
368 *dptr = sptr[y_val * width + x_val]; | 368 *dptr = sptr[y_val * width + x_val]; |
369 dptr++; | 369 dptr++; |
370 } | 370 } |
371 } | 371 } |
372 return true; | 372 return true; |
373 } | 373 } |
OLD | NEW |