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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 if (fHasAlpha) { | 296 if (fHasAlpha) { |
297 if (colorType != kARGB_4444_SkColorType) { | 297 if (colorType != kARGB_4444_SkColorType) { |
298 colorType = kN32_SkColorType; | 298 colorType = kN32_SkColorType; |
299 } | 299 } |
300 } else { | 300 } else { |
301 if (colorType != kRGB_565_SkColorType && colorType != kARGB_4444_SkColor
Type) { | 301 if (colorType != kRGB_565_SkColorType && colorType != kARGB_4444_SkColor
Type) { |
302 colorType = kN32_SkColorType; | 302 colorType = kN32_SkColorType; |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | |
307 if (!this->chooseFromOneChoice(colorType, width, height)) { | |
308 return false; | |
309 } | |
310 #endif | |
311 | |
312 SkAlphaType alphaType = kOpaque_SkAlphaType; | 306 SkAlphaType alphaType = kOpaque_SkAlphaType; |
313 if (SkToBool(fHasAlpha)) { | 307 if (SkToBool(fHasAlpha)) { |
314 if (this->getRequireUnpremultipliedColors()) { | 308 if (this->getRequireUnpremultipliedColors()) { |
315 alphaType = kUnpremul_SkAlphaType; | 309 alphaType = kUnpremul_SkAlphaType; |
316 } else { | 310 } else { |
317 alphaType = kPremul_SkAlphaType; | 311 alphaType = kPremul_SkAlphaType; |
318 } | 312 } |
319 } | 313 } |
320 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al
phaType)); | 314 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al
phaType)); |
321 } | 315 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 if (!setDecodeConfig(bitmap, width, height)) { | 377 if (!setDecodeConfig(bitmap, width, height)) { |
384 return false; | 378 return false; |
385 } | 379 } |
386 // alloc from native heap if it is a temp bitmap. (prevent GC) | 380 // alloc from native heap if it is a temp bitmap. (prevent GC) |
387 bool allocResult = (bitmap == decodedBitmap) | 381 bool allocResult = (bitmap == decodedBitmap) |
388 ? allocPixelRef(bitmap, NULL) | 382 ? allocPixelRef(bitmap, NULL) |
389 : bitmap->tryAllocPixels(); | 383 : bitmap->tryAllocPixels(); |
390 if (!allocResult) { | 384 if (!allocResult) { |
391 return return_false(*decodedBitmap, "allocPixelRef"); | 385 return return_false(*decodedBitmap, "allocPixelRef"); |
392 } | 386 } |
393 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | |
394 } else { | |
395 // This is also called in setDecodeConfig in above block. | |
396 // i.e., when bitmap->isNull() is true. | |
397 if (!chooseFromOneChoice(bitmap->colorType(), width, height)) { | |
398 return false; | |
399 } | |
400 #endif | |
401 } | 387 } |
402 | 388 |
403 SkAutoLockPixels alp(*bitmap); | 389 SkAutoLockPixels alp(*bitmap); |
404 WebPDecoderConfig config; | 390 WebPDecoderConfig config; |
405 if (!webp_get_config_resize_crop(&config, bitmap, rect, | 391 if (!webp_get_config_resize_crop(&config, bitmap, rect, |
406 this->shouldPremultiply())) { | 392 this->shouldPremultiply())) { |
407 return false; | 393 return false; |
408 } | 394 } |
409 | 395 |
410 // Decode the WebP image data stream using WebP incremental decoding for | 396 // Decode the WebP image data stream using WebP incremental decoding for |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 return SkImageDecoder::kUnknown_Format; | 673 return SkImageDecoder::kUnknown_Format; |
688 } | 674 } |
689 | 675 |
690 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 676 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
691 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 677 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
692 } | 678 } |
693 | 679 |
694 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 680 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
695 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 681 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
696 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 682 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
OLD | NEW |