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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void WEBPImageDecoder::onSetData(SharedBuffer*) | 158 void WEBPImageDecoder::onSetData(SharedBuffer*) |
159 { | 159 { |
160 m_haveAlreadyParsedThisData = false; | 160 m_haveAlreadyParsedThisData = false; |
161 } | 161 } |
162 | 162 |
163 int WEBPImageDecoder::repetitionCount() const | 163 int WEBPImageDecoder::repetitionCount() const |
164 { | 164 { |
165 return failed() ? cAnimationLoopOnce : m_repetitionCount; | 165 return failed() ? cAnimationLoopOnce : m_repetitionCount; |
166 } | 166 } |
167 | 167 |
168 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const | 168 bool WEBPImageDecoder::frameIsFullyReceivedAtIndex(size_t index) const |
169 { | 169 { |
170 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER) | 170 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER) |
171 return false; | 171 return false; |
172 if (!(m_formatFlags & ANIMATION_FLAG)) | 172 if (!(m_formatFlags & ANIMATION_FLAG)) |
173 return ImageDecoder::frameIsCompleteAtIndex(index); | 173 return ImageDecoder::frameIsFullyReceivedAtIndex(index); |
174 bool frameIsLoadedAtIndex = index < m_frameBufferCache.size(); | 174 bool frameIsLoadedAtIndex = index < m_frameBufferCache.size(); |
175 return frameIsLoadedAtIndex; | 175 return frameIsLoadedAtIndex; |
176 } | 176 } |
177 | 177 |
178 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const | 178 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const |
179 { | 179 { |
180 return index < m_frameBufferCache.size() ? m_frameBufferCache[index].duratio
n() : 0; | 180 return index < m_frameBufferCache.size() ? m_frameBufferCache[index].duratio
n() : 0; |
181 } | 181 } |
182 | 182 |
183 bool WEBPImageDecoder::updateDemuxer() | 183 bool WEBPImageDecoder::updateDemuxer() |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 m_decoderBuffer.u.RGBA.rgba = reinterpret_cast<uint8_t*>(buffer.getAddr(fram
eRect.x(), frameRect.y())); | 488 m_decoderBuffer.u.RGBA.rgba = reinterpret_cast<uint8_t*>(buffer.getAddr(fram
eRect.x(), frameRect.y())); |
489 | 489 |
490 switch (WebPIUpdate(m_decoder, dataBytes, dataSize)) { | 490 switch (WebPIUpdate(m_decoder, dataBytes, dataSize)) { |
491 case VP8_STATUS_OK: | 491 case VP8_STATUS_OK: |
492 applyPostProcessing(frameIndex); | 492 applyPostProcessing(frameIndex); |
493 buffer.setHasAlpha((m_formatFlags & ALPHA_FLAG) || m_frameBackgroundHasA
lpha); | 493 buffer.setHasAlpha((m_formatFlags & ALPHA_FLAG) || m_frameBackgroundHasA
lpha); |
494 buffer.setStatus(ImageFrame::FrameComplete); | 494 buffer.setStatus(ImageFrame::FrameComplete); |
495 clearDecoder(); | 495 clearDecoder(); |
496 return true; | 496 return true; |
497 case VP8_STATUS_SUSPENDED: | 497 case VP8_STATUS_SUSPENDED: |
498 if (!isAllDataReceived() && !frameIsCompleteAtIndex(frameIndex)) { | 498 if (!isAllDataReceived() && !frameIsFullyReceivedAtIndex(frameIndex)) { |
499 applyPostProcessing(frameIndex); | 499 applyPostProcessing(frameIndex); |
500 return false; | 500 return false; |
501 } | 501 } |
502 // FALLTHROUGH | 502 // FALLTHROUGH |
503 default: | 503 default: |
504 clear(); | 504 clear(); |
505 return setFailed(); | 505 return setFailed(); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 } // namespace blink | 509 } // namespace blink |
OLD | NEW |