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

Side by Side Diff: src/images/SkImageDecoder_libjpeg.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.cpp ('k') | src/images/SkImageDecoder_libpng.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 2007 The Android Open Source Project 2 * Copyright 2007 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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 int h = rect.height() / actualSampleSize; 845 int h = rect.height() / actualSampleSize;
846 bool swapOnly = (rect == region) && bm->isNull() && 846 bool swapOnly = (rect == region) && bm->isNull() &&
847 (w == bitmap.width()) && (h == bitmap.height()) && 847 (w == bitmap.width()) && (h == bitmap.height()) &&
848 ((startX - rect.x()) / actualSampleSize == 0) && 848 ((startX - rect.x()) / actualSampleSize == 0) &&
849 ((startY - rect.y()) / actualSampleSize == 0); 849 ((startY - rect.y()) / actualSampleSize == 0);
850 if (swapOnly) { 850 if (swapOnly) {
851 if (!this->allocPixelRef(&bitmap, NULL)) { 851 if (!this->allocPixelRef(&bitmap, NULL)) {
852 return return_false(*cinfo, bitmap, "allocPixelRef"); 852 return return_false(*cinfo, bitmap, "allocPixelRef");
853 } 853 }
854 } else { 854 } else {
855 if (!bitmap.allocPixels()) { 855 if (!bitmap.tryAllocPixels()) {
856 return return_false(*cinfo, bitmap, "allocPixels"); 856 return return_false(*cinfo, bitmap, "allocPixels");
857 } 857 }
858 } 858 }
859 859
860 SkAutoLockPixels alp(bitmap); 860 SkAutoLockPixels alp(bitmap);
861 861
862 #ifdef ANDROID_RGB 862 #ifdef ANDROID_RGB
863 /* short-circuit the SkScaledBitmapSampler when possible, as this gives 863 /* short-circuit the SkScaledBitmapSampler when possible, as this gives
864 a significant performance boost. 864 a significant performance boost.
865 */ 865 */
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 return SkImageDecoder::kUnknown_Format; 1233 return SkImageDecoder::kUnknown_Format;
1234 } 1234 }
1235 1235
1236 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1236 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1237 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1237 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1238 } 1238 }
1239 1239
1240 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1240 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1241 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1241 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1242 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1242 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698