Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 } | 155 } |
| 156 | 156 |
| 157 void WEBPImageDecoder::clearDecoder() | 157 void WEBPImageDecoder::clearDecoder() |
| 158 { | 158 { |
| 159 WebPIDelete(m_decoder); | 159 WebPIDelete(m_decoder); |
| 160 m_decoder = 0; | 160 m_decoder = 0; |
| 161 m_decodedHeight = 0; | 161 m_decodedHeight = 0; |
| 162 m_frameBackgroundHasAlpha = false; | 162 m_frameBackgroundHasAlpha = false; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void WEBPImageDecoder::onSetData(SharedBuffer*) | 165 void WEBPImageDecoder::onSetData(SegmentReader*) |
| 166 { | 166 { |
| 167 m_haveAlreadyParsedThisData = false; | 167 m_haveAlreadyParsedThisData = false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 int WEBPImageDecoder::repetitionCount() const | 170 int WEBPImageDecoder::repetitionCount() const |
| 171 { | 171 { |
| 172 return failed() ? cAnimationLoopOnce : m_repetitionCount; | 172 return failed() ? cAnimationLoopOnce : m_repetitionCount; |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const | 175 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 195 if (m_haveAlreadyParsedThisData) | 195 if (m_haveAlreadyParsedThisData) |
| 196 return true; | 196 return true; |
| 197 | 197 |
| 198 m_haveAlreadyParsedThisData = true; | 198 m_haveAlreadyParsedThisData = true; |
| 199 | 199 |
| 200 const unsigned webpHeaderSize = 30; | 200 const unsigned webpHeaderSize = 30; |
| 201 if (m_data->size() < webpHeaderSize) | 201 if (m_data->size() < webpHeaderSize) |
| 202 return false; // Await VP8X header so WebPDemuxPartial succeeds. | 202 return false; // Await VP8X header so WebPDemuxPartial succeeds. |
| 203 | 203 |
| 204 WebPDemuxDelete(m_demux); | 204 WebPDemuxDelete(m_demux); |
| 205 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_data->data()), m_d ata->size() }; | 205 m_encodedData = skia::AdoptRef(m_data->getAsSkData().leakRef()); |
|
Peter Kasting
2016/03/23 02:42:59
Is AdoptRef(leakRef()) really the only way to do t
f(malita)
2016/03/23 16:41:58
If we switch to RefPtr, this should simplify to m_
scroggo_chromium
2016/03/24 13:59:46
Done.
| |
| 206 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_encodedData->data( )), m_encodedData->size() }; | |
| 206 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); | 207 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); |
| 207 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) | 208 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) |
| 208 return setFailed(); | 209 return setFailed(); |
| 209 | 210 |
| 210 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); | 211 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); |
| 211 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) | 212 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) |
| 212 return false; // Wait until the encoded image frame data arrives. | 213 return false; // Wait until the encoded image frame data arrives. |
| 213 | 214 |
| 214 if (!isDecodedSizeAvailable()) { | 215 if (!isDecodedSizeAvailable()) { |
| 215 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); | 216 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 return false; | 557 return false; |
| 557 } | 558 } |
| 558 // FALLTHROUGH | 559 // FALLTHROUGH |
| 559 default: | 560 default: |
| 560 clear(); | 561 clear(); |
| 561 return setFailed(); | 562 return setFailed(); |
| 562 } | 563 } |
| 563 } | 564 } |
| 564 | 565 |
| 565 } // namespace blink | 566 } // namespace blink |
| OLD | NEW |