| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void ImageDecoder::clearFrameBuffer(size_t frameIndex) | 150 void ImageDecoder::clearFrameBuffer(size_t frameIndex) |
| 151 { | 151 { |
| 152 m_frameBufferCache[frameIndex].clearPixelData(); | 152 m_frameBufferCache[frameIndex].clearPixelData(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 size_t ImageDecoder::findRequiredPreviousFrame(size_t frameIndex, bool frameRect
IsOpaque) | 155 size_t ImageDecoder::findRequiredPreviousFrame(size_t frameIndex, bool frameRect
IsOpaque) |
| 156 { | 156 { |
| 157 ASSERT(frameIndex <= m_frameBufferCache.size()); | 157 ASSERT(frameIndex <= m_frameBufferCache.size()); |
| 158 if (!frameIndex) { | 158 if (!frameIndex) { |
| 159 // The first frame doesn't rely on any previous data. | 159 // The first frame doesn't rely on any previous data. |
| 160 return notFound; | 160 return kNotFound; |
| 161 } | 161 } |
| 162 | 162 |
| 163 const ImageFrame* currBuffer = &m_frameBufferCache[frameIndex]; | 163 const ImageFrame* currBuffer = &m_frameBufferCache[frameIndex]; |
| 164 if ((frameRectIsOpaque || currBuffer->alphaBlendSource() == ImageFrame::Blen
dAtopBgcolor) | 164 if ((frameRectIsOpaque || currBuffer->alphaBlendSource() == ImageFrame::Blen
dAtopBgcolor) |
| 165 && currBuffer->originalFrameRect().contains(IntRect(IntPoint(), size()))
) | 165 && currBuffer->originalFrameRect().contains(IntRect(IntPoint(), size()))
) |
| 166 return notFound; | 166 return kNotFound; |
| 167 | 167 |
| 168 // The starting state for this frame depends on the previous frame's | 168 // The starting state for this frame depends on the previous frame's |
| 169 // disposal method. | 169 // disposal method. |
| 170 size_t prevFrame = frameIndex - 1; | 170 size_t prevFrame = frameIndex - 1; |
| 171 const ImageFrame* prevBuffer = &m_frameBufferCache[prevFrame]; | 171 const ImageFrame* prevBuffer = &m_frameBufferCache[prevFrame]; |
| 172 ASSERT(prevBuffer->requiredPreviousFrameIndexValid()); | 172 ASSERT(prevBuffer->requiredPreviousFrameIndexValid()); |
| 173 | 173 |
| 174 switch (prevBuffer->disposalMethod()) { | 174 switch (prevBuffer->disposalMethod()) { |
| 175 case ImageFrame::DisposeNotSpecified: | 175 case ImageFrame::DisposeNotSpecified: |
| 176 case ImageFrame::DisposeKeep: | 176 case ImageFrame::DisposeKeep: |
| 177 // prevFrame will be used as the starting state for this frame. | 177 // prevFrame will be used as the starting state for this frame. |
| 178 // FIXME: Be even smarter by checking the frame sizes and/or alpha-conta
ining regions. | 178 // FIXME: Be even smarter by checking the frame sizes and/or alpha-conta
ining regions. |
| 179 return prevFrame; | 179 return prevFrame; |
| 180 case ImageFrame::DisposeOverwritePrevious: | 180 case ImageFrame::DisposeOverwritePrevious: |
| 181 // Frames that use the DisposeOverwritePrevious method are effectively | 181 // Frames that use the DisposeOverwritePrevious method are effectively |
| 182 // no-ops in terms of changing the starting state of a frame compared to | 182 // no-ops in terms of changing the starting state of a frame compared to |
| 183 // the starting state of the previous frame, so skip over them and | 183 // the starting state of the previous frame, so skip over them and |
| 184 // return the required previous frame of it. | 184 // return the required previous frame of it. |
| 185 return prevBuffer->requiredPreviousFrameIndex(); | 185 return prevBuffer->requiredPreviousFrameIndex(); |
| 186 case ImageFrame::DisposeOverwriteBgcolor: | 186 case ImageFrame::DisposeOverwriteBgcolor: |
| 187 // If the previous frame fills the whole image, then the current frame | 187 // If the previous frame fills the whole image, then the current frame |
| 188 // can be decoded alone. Likewise, if the previous frame could be | 188 // can be decoded alone. Likewise, if the previous frame could be |
| 189 // decoded without reference to any prior frame, the starting state for | 189 // decoded without reference to any prior frame, the starting state for |
| 190 // this frame is a blank frame, so it can again be decoded alone. | 190 // this frame is a blank frame, so it can again be decoded alone. |
| 191 // Otherwise, the previous frame contributes to this frame. | 191 // Otherwise, the previous frame contributes to this frame. |
| 192 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz
e())) | 192 return (prevBuffer->originalFrameRect().contains(IntRect(IntPoint(), siz
e())) |
| 193 || (prevBuffer->requiredPreviousFrameIndex() == notFound)) ? notFoun
d : prevFrame; | 193 || (prevBuffer->requiredPreviousFrameIndex() == kNotFound)) ? kNotFo
und : prevFrame; |
| 194 default: | 194 default: |
| 195 ASSERT_NOT_REACHED(); | 195 ASSERT_NOT_REACHED(); |
| 196 return notFound; | 196 return kNotFound; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace WebCore | 200 } // namespace WebCore |
| OLD | NEW |