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

Side by Side Diff: src/images/SkImageDecoder_libwebp.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_libpng.cpp ('k') | src/images/SkMovie_gif.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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 bitmap = &tmpBitmap; 368 bitmap = &tmpBitmap;
369 } 369 }
370 370
371 if (bitmap->isNull()) { 371 if (bitmap->isNull()) {
372 if (!setDecodeConfig(bitmap, width, height)) { 372 if (!setDecodeConfig(bitmap, width, height)) {
373 return false; 373 return false;
374 } 374 }
375 // alloc from native heap if it is a temp bitmap. (prevent GC) 375 // alloc from native heap if it is a temp bitmap. (prevent GC)
376 bool allocResult = (bitmap == decodedBitmap) 376 bool allocResult = (bitmap == decodedBitmap)
377 ? allocPixelRef(bitmap, NULL) 377 ? allocPixelRef(bitmap, NULL)
378 : bitmap->allocPixels(); 378 : bitmap->tryAllocPixels();
379 if (!allocResult) { 379 if (!allocResult) {
380 return return_false(*decodedBitmap, "allocPixelRef"); 380 return return_false(*decodedBitmap, "allocPixelRef");
381 } 381 }
382 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER 382 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
383 } else { 383 } else {
384 // This is also called in setDecodeConfig in above block. 384 // This is also called in setDecodeConfig in above block.
385 // i.e., when bitmap->isNull() is true. 385 // i.e., when bitmap->isNull() is true.
386 if (!chooseFromOneChoice(bitmap->colorType(), width, height)) { 386 if (!chooseFromOneChoice(bitmap->colorType(), width, height)) {
387 return false; 387 return false;
388 } 388 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return SkImageDecoder::kUnknown_Format; 677 return SkImageDecoder::kUnknown_Format;
678 } 678 }
679 679
680 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 680 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
681 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 681 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
682 } 682 }
683 683
684 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 684 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
685 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 685 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
686 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 686 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkMovie_gif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698