OLD | NEW |
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 Loading... |
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 Loading... |
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); |
OLD | NEW |