| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 int WEBPImageDecoder::repetitionCount() const { | 158 int WEBPImageDecoder::repetitionCount() const { |
| 159 return failed() ? cAnimationLoopOnce : m_repetitionCount; | 159 return failed() ? cAnimationLoopOnce : m_repetitionCount; |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const { | 162 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const { |
| 163 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER) | 163 if (!m_demux || m_demuxState <= WEBP_DEMUX_PARSING_HEADER) |
| 164 return false; | 164 return false; |
| 165 if (!(m_formatFlags & ANIMATION_FLAG)) | 165 if (!(m_formatFlags & ANIMATION_FLAG)) |
| 166 return ImageDecoder::frameIsCompleteAtIndex(index); | 166 return ImageDecoder::frameIsCompleteAtIndex(index); |
| 167 bool frameIsLoadedAtIndex = index < m_frameBufferCache.size(); | 167 bool frameIsReceivedAtIndex = index < m_frameBufferCache.size(); |
| 168 return frameIsLoadedAtIndex; | 168 return frameIsReceivedAtIndex; |
| 169 } | 169 } |
| 170 | 170 |
| 171 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const { | 171 float WEBPImageDecoder::frameDurationAtIndex(size_t index) const { |
| 172 return index < m_frameBufferCache.size() | 172 return index < m_frameBufferCache.size() |
| 173 ? m_frameBufferCache[index].duration() | 173 ? m_frameBufferCache[index].duration() |
| 174 : 0; | 174 : 0; |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool WEBPImageDecoder::updateDemuxer() { | 177 bool WEBPImageDecoder::updateDemuxer() { |
| 178 if (failed()) | 178 if (failed()) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 410 } |
| 411 | 411 |
| 412 void WEBPImageDecoder::decode(size_t index) { | 412 void WEBPImageDecoder::decode(size_t index) { |
| 413 if (failed()) | 413 if (failed()) |
| 414 return; | 414 return; |
| 415 | 415 |
| 416 Vector<size_t> framesToDecode = findFramesToDecode(index); | 416 Vector<size_t> framesToDecode = findFramesToDecode(index); |
| 417 | 417 |
| 418 DCHECK(m_demux); | 418 DCHECK(m_demux); |
| 419 for (auto i = framesToDecode.rbegin(); i != framesToDecode.rend(); ++i) { | 419 for (auto i = framesToDecode.rbegin(); i != framesToDecode.rend(); ++i) { |
| 420 if ((m_formatFlags & ANIMATION_FLAG) && !initFrameBuffer(*i)) | 420 if ((m_formatFlags & ANIMATION_FLAG) && !initFrameBuffer(*i)) { |
| 421 setFailed(); |
| 421 return; | 422 return; |
| 423 } |
| 424 |
| 422 WebPIterator webpFrame; | 425 WebPIterator webpFrame; |
| 423 if (!WebPDemuxGetFrame(m_demux, *i + 1, &webpFrame)) { | 426 if (!WebPDemuxGetFrame(m_demux, *i + 1, &webpFrame)) { |
| 424 setFailed(); | 427 setFailed(); |
| 425 } else { | 428 } else { |
| 426 decodeSingleFrame(webpFrame.fragment.bytes, webpFrame.fragment.size, *i); | 429 decodeSingleFrame(webpFrame.fragment.bytes, webpFrame.fragment.size, *i); |
| 427 WebPDemuxReleaseIterator(&webpFrame); | 430 WebPDemuxReleaseIterator(&webpFrame); |
| 428 } | 431 } |
| 429 if (failed()) | 432 if (failed()) |
| 430 return; | 433 return; |
| 431 | 434 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 return false; | 512 return false; |
| 510 } | 513 } |
| 511 // FALLTHROUGH | 514 // FALLTHROUGH |
| 512 default: | 515 default: |
| 513 clear(); | 516 clear(); |
| 514 return setFailed(); | 517 return setFailed(); |
| 515 } | 518 } |
| 516 } | 519 } |
| 517 | 520 |
| 518 } // namespace blink | 521 } // namespace blink |
| OLD | NEW |