| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 if (fHasAlpha) { | 285 if (fHasAlpha) { |
| 286 if (colorType != kARGB_4444_SkColorType) { | 286 if (colorType != kARGB_4444_SkColorType) { |
| 287 colorType = kN32_SkColorType; | 287 colorType = kN32_SkColorType; |
| 288 } | 288 } |
| 289 } else { | 289 } else { |
| 290 if (colorType != kRGB_565_SkColorType && colorType != kARGB_4444_SkColor
Type) { | 290 if (colorType != kRGB_565_SkColorType && colorType != kARGB_4444_SkColor
Type) { |
| 291 colorType = kN32_SkColorType; | 291 colorType = kN32_SkColorType; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER |
| 295 if (!this->chooseFromOneChoice(colorType, width, height)) { | 296 if (!this->chooseFromOneChoice(colorType, width, height)) { |
| 296 return false; | 297 return false; |
| 297 } | 298 } |
| 299 #endif |
| 298 | 300 |
| 299 SkAlphaType alphaType = kOpaque_SkAlphaType; | 301 SkAlphaType alphaType = kOpaque_SkAlphaType; |
| 300 if (SkToBool(fHasAlpha)) { | 302 if (SkToBool(fHasAlpha)) { |
| 301 if (this->getRequireUnpremultipliedColors()) { | 303 if (this->getRequireUnpremultipliedColors()) { |
| 302 alphaType = kUnpremul_SkAlphaType; | 304 alphaType = kUnpremul_SkAlphaType; |
| 303 } else { | 305 } else { |
| 304 alphaType = kPremul_SkAlphaType; | 306 alphaType = kPremul_SkAlphaType; |
| 305 } | 307 } |
| 306 } | 308 } |
| 307 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al
phaType)); | 309 return decodedBitmap->setInfo(SkImageInfo::Make(width, height, colorType, al
phaType)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 if (!setDecodeConfig(bitmap, width, height)) { | 374 if (!setDecodeConfig(bitmap, width, height)) { |
| 373 return false; | 375 return false; |
| 374 } | 376 } |
| 375 // alloc from native heap if it is a temp bitmap. (prevent GC) | 377 // alloc from native heap if it is a temp bitmap. (prevent GC) |
| 376 bool allocResult = (bitmap == decodedBitmap) | 378 bool allocResult = (bitmap == decodedBitmap) |
| 377 ? allocPixelRef(bitmap, NULL) | 379 ? allocPixelRef(bitmap, NULL) |
| 378 : bitmap->allocPixels(); | 380 : bitmap->allocPixels(); |
| 379 if (!allocResult) { | 381 if (!allocResult) { |
| 380 return return_false(*decodedBitmap, "allocPixelRef"); | 382 return return_false(*decodedBitmap, "allocPixelRef"); |
| 381 } | 383 } |
| 384 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER |
| 382 } else { | 385 } else { |
| 383 // This is also called in setDecodeConfig in above block. | 386 // This is also called in setDecodeConfig in above block. |
| 384 // i.e., when bitmap->isNull() is true. | 387 // i.e., when bitmap->isNull() is true. |
| 385 if (!chooseFromOneChoice(bitmap->colorType(), width, height)) { | 388 if (!chooseFromOneChoice(bitmap->colorType(), width, height)) { |
| 386 return false; | 389 return false; |
| 387 } | 390 } |
| 391 #endif |
| 388 } | 392 } |
| 389 | 393 |
| 390 SkAutoLockPixels alp(*bitmap); | 394 SkAutoLockPixels alp(*bitmap); |
| 391 WebPDecoderConfig config; | 395 WebPDecoderConfig config; |
| 392 if (!webp_get_config_resize_crop(&config, bitmap, rect, | 396 if (!webp_get_config_resize_crop(&config, bitmap, rect, |
| 393 this->shouldPremultiply())) { | 397 this->shouldPremultiply())) { |
| 394 return false; | 398 return false; |
| 395 } | 399 } |
| 396 | 400 |
| 397 // Decode the WebP image data stream using WebP incremental decoding for | 401 // Decode the WebP image data stream using WebP incremental decoding for |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 return SkImageDecoder::kUnknown_Format; | 683 return SkImageDecoder::kUnknown_Format; |
| 680 } | 684 } |
| 681 | 685 |
| 682 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 686 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
| 683 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 687 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
| 684 } | 688 } |
| 685 | 689 |
| 686 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 690 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
| 687 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 691 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
| 688 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 692 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
| OLD | NEW |