| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 bool DeferredImageDecoder::enabled() | 81 bool DeferredImageDecoder::enabled() |
| 82 { | 82 { |
| 83 return s_enabled; | 83 return s_enabled; |
| 84 } | 84 } |
| 85 | 85 |
| 86 String DeferredImageDecoder::filenameExtension() const | 86 String DeferredImageDecoder::filenameExtension() const |
| 87 { | 87 { |
| 88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; | 88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx
tension; |
| 89 } | 89 } |
| 90 | 90 |
| 91 PassRefPtr<NativeImageSkia> DeferredImageDecoder::createFrameAtIndex(size_t inde
x) | 91 SkBitmap DeferredImageDecoder::createFrameAtIndex(size_t index) |
| 92 { | 92 { |
| 93 prepareLazyDecodedFrames(); | 93 prepareLazyDecodedFrames(); |
| 94 if (index < m_frameData.size()) { | 94 if (index < m_frameData.size()) { |
| 95 // ImageFrameGenerator has the latest known alpha state. There will | 95 // ImageFrameGenerator has the latest known alpha state. There will |
| 96 // be a performance boost if this frame is opaque. | 96 // be a performance boost if this frame is opaque. |
| 97 SkBitmap bitmap = createBitmap(index); | 97 SkBitmap bitmap = createBitmap(index); |
| 98 if (m_frameGenerator->hasAlpha(index)) { | 98 if (m_frameGenerator->hasAlpha(index)) { |
| 99 m_frameData[index].m_hasAlpha = true; | 99 m_frameData[index].m_hasAlpha = true; |
| 100 bitmap.setAlphaType(kPremul_SkAlphaType); | 100 bitmap.setAlphaType(kPremul_SkAlphaType); |
| 101 } else { | 101 } else { |
| 102 m_frameData[index].m_hasAlpha = false; | 102 m_frameData[index].m_hasAlpha = false; |
| 103 bitmap.setAlphaType(kOpaque_SkAlphaType); | 103 bitmap.setAlphaType(kOpaque_SkAlphaType); |
| 104 } | 104 } |
| 105 m_frameData[index].m_frameBytes = m_size.area() * sizeof(ImageFrame::Pi
xelData); | 105 m_frameData[index].m_frameBytes = m_size.area() * sizeof(ImageFrame::Pi
xelData); |
| 106 return NativeImageSkia::create(bitmap); | 106 return bitmap; |
| 107 } | 107 } |
| 108 if (m_actualDecoder) { | 108 if (m_actualDecoder) { |
| 109 ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index); | 109 ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index); |
| 110 if (!buffer || buffer->status() == ImageFrame::FrameEmpty) | 110 if (!buffer || buffer->status() == ImageFrame::FrameEmpty) |
| 111 return nullptr; | 111 return SkBitmap(); |
| 112 return buffer->asNewNativeImage(); | 112 return buffer->bitmap(); |
| 113 } | 113 } |
| 114 return nullptr; | 114 return SkBitmap(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) | 117 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) |
| 118 { | 118 { |
| 119 if (m_actualDecoder) { | 119 if (m_actualDecoder) { |
| 120 m_data = RefPtr<SharedBuffer>(data); | 120 m_data = RefPtr<SharedBuffer>(data); |
| 121 m_lastDataSize = data.size(); | 121 m_lastDataSize = data.size(); |
| 122 m_allDataReceived = allDataReceived; | 122 m_allDataReceived = allDataReceived; |
| 123 m_actualDecoder->setData(&data, allDataReceived); | 123 m_actualDecoder->setData(&data, allDataReceived); |
| 124 prepareLazyDecodedFrames(); | 124 prepareLazyDecodedFrames(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return bitmap; | 294 return bitmap; |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const | 297 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const |
| 298 { | 298 { |
| 299 // TODO: Implement. | 299 // TODO: Implement. |
| 300 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; | 300 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace blink | 303 } // namespace blink |
| OLD | NEW |