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

Side by Side Diff: src/images/SkImageDecoder_libpng.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/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.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 2006 The Android Open Source Project 2 * Copyright 2006 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 "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 int w = rect.width() / sampleSize; 816 int w = rect.width() / sampleSize;
817 int h = rect.height() / sampleSize; 817 int h = rect.height() / sampleSize;
818 const bool swapOnly = (rect == region) && (w == decodedBitmap.width()) && 818 const bool swapOnly = (rect == region) && (w == decodedBitmap.width()) &&
819 (h == decodedBitmap.height()) && bm->isNull(); 819 (h == decodedBitmap.height()) && bm->isNull();
820 const bool needColorTable = kIndex_8_SkColorType == colorType; 820 const bool needColorTable = kIndex_8_SkColorType == colorType;
821 if (swapOnly) { 821 if (swapOnly) {
822 if (!this->allocPixelRef(&decodedBitmap, needColorTable ? colorTable : N ULL)) { 822 if (!this->allocPixelRef(&decodedBitmap, needColorTable ? colorTable : N ULL)) {
823 return false; 823 return false;
824 } 824 }
825 } else { 825 } else {
826 if (!decodedBitmap.allocPixels(NULL, needColorTable ? colorTable : NULL) ) { 826 if (!decodedBitmap.tryAllocPixels(NULL, needColorTable ? colorTable : NU LL)) {
827 return false; 827 return false;
828 } 828 }
829 } 829 }
830 SkAutoLockPixels alp(decodedBitmap); 830 SkAutoLockPixels alp(decodedBitmap);
831 831
832 /* Turn on interlace handling. REQUIRED if you are not using 832 /* Turn on interlace handling. REQUIRED if you are not using
833 * png_read_image(). To see how to handle interlacing passes, 833 * png_read_image(). To see how to handle interlacing passes,
834 * see the png_read_row() method below: 834 * see the png_read_row() method below:
835 */ 835 */
836 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ? 836 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ?
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 return SkImageDecoder::kUnknown_Format; 1278 return SkImageDecoder::kUnknown_Format;
1279 } 1279 }
1280 1280
1281 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 1281 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
1282 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; 1282 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
1283 } 1283 }
1284 1284
1285 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); 1285 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
1286 static SkImageDecoder_FormatReg gFormatReg(get_format_png); 1286 static SkImageDecoder_FormatReg gFormatReg(get_format_png);
1287 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); 1287 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698