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

Side by Side Diff: src/effects/SkAlphaThresholdFilter.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/core/SkScalerContext.cpp ('k') | src/effects/SkBlurImageFilter.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (!ctx.ctm().invert(&localInverse)) { 336 if (!ctx.ctm().invert(&localInverse)) {
337 return false; 337 return false;
338 } 338 }
339 339
340 SkAutoLockPixels alp(src); 340 SkAutoLockPixels alp(src);
341 SkASSERT(src.getPixels()); 341 SkASSERT(src.getPixels());
342 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { 342 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
343 return false; 343 return false;
344 } 344 }
345 345
346 if (!dst->allocPixels(src.info())) { 346 if (!dst->tryAllocPixels(src.info())) {
347 return false; 347 return false;
348 } 348 }
349 349
350 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); 350 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
351 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); 351 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
352 SkColor* sptr = src.getAddr32(0, 0); 352 SkColor* sptr = src.getAddr32(0, 0);
353 SkColor* dptr = dst->getAddr32(0, 0); 353 SkColor* dptr = dst->getAddr32(0, 0);
354 int width = src.width(), height = src.height(); 354 int width = src.width(), height = src.height();
355 for (int y = 0; y < height; ++y) { 355 for (int y = 0; y < height; ++y) {
356 for (int x = 0; x < width; ++x) { 356 for (int x = 0; x < width; ++x) {
(...skipping 20 matching lines...) Expand all
377 (U8CPU)(SkColorGetG(source) * scale), 377 (U8CPU)(SkColorGetG(source) * scale),
378 (U8CPU)(SkColorGetB(source) * scale)); 378 (U8CPU)(SkColorGetB(source) * scale));
379 } 379 }
380 } 380 }
381 dptr[y * dst->width() + x] = output_color; 381 dptr[y * dst->width() + x] = output_color;
382 } 382 }
383 } 383 }
384 384
385 return true; 385 return true;
386 } 386 }
OLDNEW
« no previous file with comments | « src/core/SkScalerContext.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698