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

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: can't use (void) to suppress the "must check return result" 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
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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if (!ctx.ctm().invert(&localInverse)) { 334 if (!ctx.ctm().invert(&localInverse)) {
335 return false; 335 return false;
336 } 336 }
337 337
338 SkAutoLockPixels alp(src); 338 SkAutoLockPixels alp(src);
339 SkASSERT(src.getPixels()); 339 SkASSERT(src.getPixels());
340 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { 340 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
341 return false; 341 return false;
342 } 342 }
343 343
344 if (!dst->allocPixels(src.info())) { 344 if (!dst->tryAllocPixels(src.info())) {
345 return false; 345 return false;
346 } 346 }
347 347
348 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); 348 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
349 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); 349 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
350 SkColor* sptr = src.getAddr32(0, 0); 350 SkColor* sptr = src.getAddr32(0, 0);
351 SkColor* dptr = dst->getAddr32(0, 0); 351 SkColor* dptr = dst->getAddr32(0, 0);
352 int width = src.width(), height = src.height(); 352 int width = src.width(), height = src.height();
353 for (int y = 0; y < height; ++y) { 353 for (int y = 0; y < height; ++y) {
354 for (int x = 0; x < width; ++x) { 354 for (int x = 0; x < width; ++x) {
(...skipping 20 matching lines...) Expand all
375 (U8CPU)(SkColorGetG(source) * scale), 375 (U8CPU)(SkColorGetG(source) * scale),
376 (U8CPU)(SkColorGetB(source) * scale)); 376 (U8CPU)(SkColorGetB(source) * scale));
377 } 377 }
378 } 378 }
379 dptr[y * dst->width() + x] = output_color; 379 dptr[y * dst->width() + x] = output_color;
380 } 380 }
381 } 381 }
382 382
383 return true; 383 return true;
384 } 384 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698