| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 return newSize; | 128 return newSize; |
| 129 } | 129 } |
| 130 | 130 |
| 131 ImageFrame* ImageDecoder::frameBufferAtIndex(size_t index) | 131 ImageFrame* ImageDecoder::frameBufferAtIndex(size_t index) |
| 132 { | 132 { |
| 133 if (index >= frameCount()) | 133 if (index >= frameCount()) |
| 134 return 0; | 134 return 0; |
| 135 | 135 |
| 136 ImageFrame* frame = &m_frameBufferCache[index]; | 136 ImageFrame* frame = &m_frameBufferCache[index]; |
| 137 if (frame->status() != ImageFrame::FrameComplete) { | 137 if (frame->getStatus() != ImageFrame::FrameComplete) { |
| 138 PlatformInstrumentation::willDecodeImage(filenameExtension()); | 138 PlatformInstrumentation::willDecodeImage(filenameExtension()); |
| 139 decode(index); | 139 decode(index); |
| 140 PlatformInstrumentation::didDecodeImage(); | 140 PlatformInstrumentation::didDecodeImage(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 frame->notifyBitmapIfPixelsChanged(); | 143 frame->notifyBitmapIfPixelsChanged(); |
| 144 return frame; | 144 return frame; |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const | 147 bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const |
| 148 { | 148 { |
| 149 return !frameIsCompleteAtIndex(index) || m_frameBufferCache[index].hasAlpha(
); | 149 return !frameIsCompleteAtIndex(index) || m_frameBufferCache[index].hasAlpha(
); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const | 152 bool ImageDecoder::frameIsCompleteAtIndex(size_t index) const |
| 153 { | 153 { |
| 154 return (index < m_frameBufferCache.size()) && | 154 return (index < m_frameBufferCache.size()) && |
| 155 (m_frameBufferCache[index].status() == ImageFrame::FrameComplete); | 155 (m_frameBufferCache[index].getStatus() == ImageFrame::FrameComplete); |
| 156 } | 156 } |
| 157 | 157 |
| 158 size_t ImageDecoder::frameBytesAtIndex(size_t index) const | 158 size_t ImageDecoder::frameBytesAtIndex(size_t index) const |
| 159 { | 159 { |
| 160 if (index >= m_frameBufferCache.size() || m_frameBufferCache[index].status()
== ImageFrame::FrameEmpty) | 160 if (index >= m_frameBufferCache.size() || m_frameBufferCache[index].getStatu
s() == ImageFrame::FrameEmpty) |
| 161 return 0; | 161 return 0; |
| 162 | 162 |
| 163 struct ImageSize { | 163 struct ImageSize { |
| 164 | 164 |
| 165 explicit ImageSize(IntSize size) | 165 explicit ImageSize(IntSize size) |
| 166 { | 166 { |
| 167 area = static_cast<uint64_t>(size.width()) * size.height(); | 167 area = static_cast<uint64_t>(size.width()) * size.height(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 uint64_t area; | 170 uint64_t area; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 201 | 201 |
| 202 size_t ImageDecoder::findRequiredPreviousFrame(size_t frameIndex, bool frameRect
IsOpaque) | 202 size_t ImageDecoder::findRequiredPreviousFrame(size_t frameIndex, bool frameRect
IsOpaque) |
| 203 { | 203 { |
| 204 ASSERT(frameIndex <= m_frameBufferCache.size()); | 204 ASSERT(frameIndex <= m_frameBufferCache.size()); |
| 205 if (!frameIndex) { | 205 if (!frameIndex) { |
| 206 // The first frame doesn't rely on any previous data. | 206 // The first frame doesn't rely on any previous data. |
| 207 return kNotFound; | 207 return kNotFound; |
| 208 } | 208 } |
| 209 | 209 |
| 210 const ImageFrame* currBuffer = &m_frameBufferCache[frameIndex]; | 210 const ImageFrame* currBuffer = &m_frameBufferCache[frameIndex]; |
| 211 if ((frameRectIsOpaque || currBuffer->alphaBlendSource() == ImageFrame::Blen
dAtopBgcolor) | 211 if ((frameRectIsOpaque || currBuffer->getAlphaBlendSource() == ImageFrame::B
lendAtopBgcolor) |
| 212 && currBuffer->originalFrameRect().contains(IntRect(IntPoint(), size()))
) | 212 && currBuffer->originalFrameRect().contains(IntRect(IntPoint(), size()))
) |
| 213 return kNotFound; | 213 return kNotFound; |
| 214 | 214 |
| 215 // The starting state for this frame depends on the previous frame's | 215 // The starting state for this frame depends on the previous frame's |
| 216 // disposal method. | 216 // disposal method. |
| 217 size_t prevFrame = frameIndex - 1; | 217 size_t prevFrame = frameIndex - 1; |
| 218 const ImageFrame* prevBuffer = &m_frameBufferCache[prevFrame]; | 218 const ImageFrame* prevBuffer = &m_frameBufferCache[prevFrame]; |
| 219 | 219 |
| 220 switch (prevBuffer->disposalMethod()) { | 220 switch (prevBuffer->getDisposalMethod()) { |
| 221 case ImageFrame::DisposeNotSpecified: | 221 case ImageFrame::DisposeNotSpecified: |
| 222 case ImageFrame::DisposeKeep: | 222 case ImageFrame::DisposeKeep: |
| 223 // prevFrame will be used as the starting state for this frame. | 223 // prevFrame will be used as the starting state for this frame. |
| 224 // FIXME: Be even smarter by checking the frame sizes and/or alpha-conta
ining regions. | 224 // FIXME: Be even smarter by checking the frame sizes and/or alpha-conta
ining regions. |
| 225 return prevFrame; | 225 return prevFrame; |
| 226 case ImageFrame::DisposeOverwritePrevious: | 226 case ImageFrame::DisposeOverwritePrevious: |
| 227 // Frames that use the DisposeOverwritePrevious method are effectively | 227 // Frames that use the DisposeOverwritePrevious method are effectively |
| 228 // no-ops in terms of changing the starting state of a frame compared to | 228 // no-ops in terms of changing the starting state of a frame compared to |
| 229 // the starting state of the previous frame, so skip over them and | 229 // the starting state of the previous frame, so skip over them and |
| 230 // return the required previous frame of it. | 230 // return the required previous frame of it. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return m_planes[i]; | 265 return m_planes[i]; |
| 266 } | 266 } |
| 267 | 267 |
| 268 size_t ImagePlanes::rowBytes(int i) const | 268 size_t ImagePlanes::rowBytes(int i) const |
| 269 { | 269 { |
| 270 ASSERT((i >= 0) && i < 3); | 270 ASSERT((i >= 0) && i < 3); |
| 271 return m_rowBytes[i]; | 271 return m_rowBytes[i]; |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace blink | 274 } // namespace blink |
| OLD | NEW |