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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 WebPFreeDecBuffer(&config->output); | 194 WebPFreeDecBuffer(&config->output); |
195 return false; | 195 return false; |
196 } | 196 } |
197 | 197 |
198 if (!stream->rewind()) { | 198 if (!stream->rewind()) { |
199 SkDebugf("Failed to rewind webp stream!"); | 199 SkDebugf("Failed to rewind webp stream!"); |
200 return false; | 200 return false; |
201 } | 201 } |
202 const size_t readBufferSize = stream->hasLength() ? | 202 const size_t readBufferSize = stream->hasLength() ? |
203 SkTMin(stream->getLength(), WEBP_IDECODE_BUFFER_SZ) : WEBP_IDECODE_B
UFFER_SZ; | 203 SkTMin(stream->getLength(), WEBP_IDECODE_BUFFER_SZ) : WEBP_IDECODE_B
UFFER_SZ; |
204 SkAutoMalloc srcStorage(readBufferSize); | 204 SkAutoTMalloc<unsigned char> srcStorage(readBufferSize); |
205 unsigned char* input = (uint8_t*)srcStorage.get(); | 205 unsigned char* input = srcStorage.get(); |
206 if (nullptr == input) { | 206 if (nullptr == input) { |
207 WebPIDelete(idec); | 207 WebPIDelete(idec); |
208 WebPFreeDecBuffer(&config->output); | 208 WebPFreeDecBuffer(&config->output); |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
212 bool success = true; | 212 bool success = true; |
213 VP8StatusCode status = VP8_STATUS_SUSPENDED; | 213 VP8StatusCode status = VP8_STATUS_SUSPENDED; |
214 do { | 214 do { |
215 const size_t bytesRead = stream->read(input, readBufferSize); | 215 const size_t bytesRead = stream->read(input, readBufferSize); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 return SkImageDecoder::kUnknown_Format; | 550 return SkImageDecoder::kUnknown_Format; |
551 } | 551 } |
552 | 552 |
553 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 553 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
554 return (SkImageEncoder::kWEBP_Type == t) ? new SkWEBPImageEncoder : nullptr; | 554 return (SkImageEncoder::kWEBP_Type == t) ? new SkWEBPImageEncoder : nullptr; |
555 } | 555 } |
556 | 556 |
557 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 557 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
558 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 558 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
559 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 559 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
OLD | NEW |