Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698