| 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 return decodedBitmap->setConfig(config, width, height, 0, | 301 SkImageInfo info; |
| 302 fHasAlpha ? kPremul_SkAlphaType : kOpaque_Sk
AlphaType); | 302 info.fWidth = width; |
| 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); |
| 303 } | 315 } |
| 304 | 316 |
| 305 bool SkWEBPImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, | 317 bool SkWEBPImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, |
| 306 int *width, int *height) { | 318 int *width, int *height) { |
| 307 int origWidth, origHeight, hasAlpha; | 319 int origWidth, origHeight, hasAlpha; |
| 308 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { | 320 if (!webp_parse_header(stream, &origWidth, &origHeight, &hasAlpha)) { |
| 309 return false; | 321 return false; |
| 310 } | 322 } |
| 311 | 323 |
| 312 if (!stream->rewind()) { | 324 if (!stream->rewind()) { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 return SkImageDecoder::kUnknown_Format; | 698 return SkImageDecoder::kUnknown_Format; |
| 687 } | 699 } |
| 688 | 700 |
| 689 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 701 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
| 690 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 702 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
| 691 } | 703 } |
| 692 | 704 |
| 693 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 705 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
| 694 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 706 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
| 695 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 707 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
| OLD | NEW |