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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 (fSrcRect.height() >= src.height())) { | 291 (fSrcRect.height() >= src.height())) { |
292 return false; | 292 return false; |
293 } | 293 } |
294 | 294 |
295 SkAutoLockPixels alp(src); | 295 SkAutoLockPixels alp(src); |
296 SkASSERT(src.getPixels()); | 296 SkASSERT(src.getPixels()); |
297 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { | 297 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { |
298 return false; | 298 return false; |
299 } | 299 } |
300 | 300 |
301 dst->setConfig(src.config(), src.width(), src.height()); | 301 if (!dst->allocPixels(src.info())) { |
302 dst->allocPixels(); | |
303 if (!dst->getPixels()) { | |
304 return false; | 302 return false; |
305 } | 303 } |
306 | 304 |
307 SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; | 305 SkScalar inv_inset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; |
308 | 306 |
309 SkScalar inv_x_zoom = fSrcRect.width() / src.width(); | 307 SkScalar inv_x_zoom = fSrcRect.width() / src.width(); |
310 SkScalar inv_y_zoom = fSrcRect.height() / src.height(); | 308 SkScalar inv_y_zoom = fSrcRect.height() / src.height(); |
311 | 309 |
312 SkColor* sptr = src.getAddr32(0, 0); | 310 SkColor* sptr = src.getAddr32(0, 0); |
313 SkColor* dptr = dst->getAddr32(0, 0); | 311 SkColor* dptr = dst->getAddr32(0, 0); |
(...skipping 29 matching lines...) Expand all Loading... |
343 | 341 |
344 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); | 342 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); |
345 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); | 343 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); |
346 | 344 |
347 *dptr = sptr[y_val * width + x_val]; | 345 *dptr = sptr[y_val * width + x_val]; |
348 dptr++; | 346 dptr++; |
349 } | 347 } |
350 } | 348 } |
351 return true; | 349 return true; |
352 } | 350 } |
OLD | NEW |