| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (config != SkBitmap::kRGB_565_Config && | 291 if (config != SkBitmap::kRGB_565_Config && |
| 292 config != SkBitmap::kARGB_4444_Config) { | 292 config != SkBitmap::kARGB_4444_Config) { |
| 293 config = SkBitmap::kARGB_8888_Config; | 293 config = SkBitmap::kARGB_8888_Config; |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 if (!this->chooseFromOneChoice(config, width, height)) { | 297 if (!this->chooseFromOneChoice(config, width, height)) { |
| 298 return false; | 298 return false; |
| 299 } | 299 } |
| 300 | 300 |
| 301 SkImageInfo info; | 301 return decodedBitmap->setConfig(config, width, height, 0, |
| 302 info.fWidth = width; | 302 fHasAlpha ? kPremul_SkAlphaType : kOpaque_Sk
AlphaType); |
| 303 info.fHeight = height; | |
| 304 info.fColorType = SkBitmapConfigToColorType(config); | |
| 305 if (SkToBool(fHasAlpha)) { | |
| 306 if (this->getRequireUnpremultipliedColors()) { | |
| 307 info.fAlphaType = kUnpremul_SkAlphaType; | |
| 308 } else { | |
| 309 info.fAlphaType = kPremul_SkAlphaType; | |
| 310 } | |
| 311 } else { | |
| 312 info.fAlphaType = kOpaque_SkAlphaType; | |
| 313 } | |
| 314 return decodedBitmap->setConfig(info); | |
| 315 } | 303 } |
| 316 | 304 |
| 317 bool SkWEBPImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, | 305 bool SkWEBPImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, |
| 318 int *width, int *height) { | 306 int *width, int *height) { |
| 319 int origWidth, origHeight, hasAlpha; | 307 int origWidth, origHeight, hasAlpha; |
| 320 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { | 308 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { |
| 321 return false; | 309 return false; |
| 322 } | 310 } |
| 323 | 311 |
| 324 if (!stream->rewind()) { | 312 if (!stream->rewind()) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 return SkImageDecoder::kUnknown_Format; | 674 return SkImageDecoder::kUnknown_Format; |
| 687 } | 675 } |
| 688 | 676 |
| 689 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 677 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
| 690 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 678 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
| 691 } | 679 } |
| 692 | 680 |
| 693 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 681 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
| 694 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 682 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
| 695 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 683 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
| OLD | NEW |