| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return s_enabled; | 77 return s_enabled; |
| 78 } | 78 } |
| 79 | 79 |
| 80 String DeferredImageDecoder::filenameExtension() const | 80 String DeferredImageDecoder::filenameExtension() const |
| 81 { | 81 { |
| 82 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; | 82 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; |
| 83 } | 83 } |
| 84 | 84 |
| 85 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) | 85 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) |
| 86 { | 86 { |
| 87 if (m_frameGenerator && m_frameGenerator->decodeFailed()) |
| 88 return nullptr; |
| 89 |
| 87 prepareLazyDecodedFrames(); | 90 prepareLazyDecodedFrames(); |
| 88 | 91 |
| 89 if (index < m_frameData.size()) { | 92 if (index < m_frameData.size()) { |
| 93 FrameData* frameData = &m_frameData[index]; |
| 90 // ImageFrameGenerator has the latest known alpha state. There will be a | 94 // ImageFrameGenerator has the latest known alpha state. There will be a |
| 91 // performance boost if this frame is opaque. | 95 // performance boost if this frame is opaque. |
| 92 FrameData* frameData = &m_frameData[index]; | 96 ASSERT(m_frameGenerator); |
| 93 frameData->m_hasAlpha = m_frameGenerator->hasAlpha(index); | 97 frameData->m_hasAlpha = m_frameGenerator->hasAlpha(index); |
| 94 frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData); | 98 frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData); |
| 95 return createFrameImageAtIndex(index, !frameData->m_hasAlpha); | 99 return createFrameImageAtIndex(index, !frameData->m_hasAlpha); |
| 96 } | 100 } |
| 97 | 101 |
| 98 if (!m_actualDecoder) | 102 if (!m_actualDecoder || m_actualDecoder->failed()) |
| 99 return nullptr; | 103 return nullptr; |
| 100 | 104 |
| 101 ImageFrame* frame = m_actualDecoder->frameBufferAtIndex(index); | 105 ImageFrame* frame = m_actualDecoder->frameBufferAtIndex(index); |
| 102 if (!frame || frame->status() == ImageFrame::FrameEmpty) | 106 if (!frame || frame->status() == ImageFrame::FrameEmpty) |
| 103 return nullptr; | 107 return nullptr; |
| 104 | 108 |
| 105 return adoptRef(SkImage::NewFromBitmap(frame->bitmap())); | 109 return adoptRef(SkImage::NewFromBitmap(frame->bitmap())); |
| 106 } | 110 } |
| 107 | 111 |
| 108 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) | 112 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return image.release(); | 291 return image.release(); |
| 288 } | 292 } |
| 289 | 293 |
| 290 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 294 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
| 291 { | 295 { |
| 292 // TODO: Implement. | 296 // TODO: Implement. |
| 293 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 297 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
| 294 } | 298 } |
| 295 | 299 |
| 296 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |