| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 WEBPImageDecoder::~WEBPImageDecoder() | 138 WEBPImageDecoder::~WEBPImageDecoder() |
| 139 { | 139 { |
| 140 clear(); | 140 clear(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WEBPImageDecoder::clear() | 143 void WEBPImageDecoder::clear() |
| 144 { | 144 { |
| 145 WebPDemuxDelete(m_demux); | 145 WebPDemuxDelete(m_demux); |
| 146 m_demux = 0; | 146 m_demux = 0; |
| 147 m_consolidatedData.clear(); |
| 147 clearDecoder(); | 148 clearDecoder(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void WEBPImageDecoder::clearDecoder() | 151 void WEBPImageDecoder::clearDecoder() |
| 151 { | 152 { |
| 152 WebPIDelete(m_decoder); | 153 WebPIDelete(m_decoder); |
| 153 m_decoder = 0; | 154 m_decoder = 0; |
| 154 m_decodedHeight = 0; | 155 m_decodedHeight = 0; |
| 155 m_frameBackgroundHasAlpha = false; | 156 m_frameBackgroundHasAlpha = false; |
| 156 } | 157 } |
| 157 | 158 |
| 158 void WEBPImageDecoder::onSetData(SharedBuffer*) | 159 void WEBPImageDecoder::onSetData(SegmentReader*) |
| 159 { | 160 { |
| 160 m_haveAlreadyParsedThisData = false; | 161 m_haveAlreadyParsedThisData = false; |
| 161 } | 162 } |
| 162 | 163 |
| 163 int WEBPImageDecoder::repetitionCount() const | 164 int WEBPImageDecoder::repetitionCount() const |
| 164 { | 165 { |
| 165 return failed() ? cAnimationLoopOnce : m_repetitionCount; | 166 return failed() ? cAnimationLoopOnce : m_repetitionCount; |
| 166 } | 167 } |
| 167 | 168 |
| 168 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const | 169 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const |
| (...skipping 19 matching lines...) Expand all Loading... |
| 188 if (m_haveAlreadyParsedThisData) | 189 if (m_haveAlreadyParsedThisData) |
| 189 return true; | 190 return true; |
| 190 | 191 |
| 191 m_haveAlreadyParsedThisData = true; | 192 m_haveAlreadyParsedThisData = true; |
| 192 | 193 |
| 193 const unsigned webpHeaderSize = 30; | 194 const unsigned webpHeaderSize = 30; |
| 194 if (m_data->size() < webpHeaderSize) | 195 if (m_data->size() < webpHeaderSize) |
| 195 return false; // Await VP8X header so WebPDemuxPartial succeeds. | 196 return false; // Await VP8X header so WebPDemuxPartial succeeds. |
| 196 | 197 |
| 197 WebPDemuxDelete(m_demux); | 198 WebPDemuxDelete(m_demux); |
| 198 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_data->data()), m_d
ata->size() }; | 199 m_consolidatedData = m_data->getAsSkData(); |
| 200 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_consolidatedData->
data()), m_consolidatedData->size() }; |
| 199 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); | 201 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); |
| 200 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) | 202 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) { |
| 203 if (!m_demux) |
| 204 m_consolidatedData.clear(); |
| 201 return setFailed(); | 205 return setFailed(); |
| 206 } |
| 202 | 207 |
| 203 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); | 208 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); |
| 204 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) | 209 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) |
| 205 return false; // Wait until the encoded image frame data arrives. | 210 return false; // Wait until the encoded image frame data arrives. |
| 206 | 211 |
| 207 if (!isDecodedSizeAvailable()) { | 212 if (!isDecodedSizeAvailable()) { |
| 208 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); | 213 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); |
| 209 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); | 214 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); |
| 210 if (!setSize(width, height)) | 215 if (!setSize(width, height)) |
| 211 return setFailed(); | 216 return setFailed(); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 return false; | 505 return false; |
| 501 } | 506 } |
| 502 // FALLTHROUGH | 507 // FALLTHROUGH |
| 503 default: | 508 default: |
| 504 clear(); | 509 clear(); |
| 505 return setFailed(); | 510 return setFailed(); |
| 506 } | 511 } |
| 507 } | 512 } |
| 508 | 513 |
| 509 } // namespace blink | 514 } // namespace blink |
| OLD | NEW |