| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDecoder::Alp
haPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 161 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDecoder::Alp
haPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 162 // getYUVComponentSizes was already called and was successful, so ImageDecod
er::create must succeed. | 162 // getYUVComponentSizes was already called and was successful, so ImageDecod
er::create must succeed. |
| 163 ASSERT(decoder); | 163 ASSERT(decoder); |
| 164 | 164 |
| 165 decoder->setData(data, true); | 165 decoder->setData(data, true); |
| 166 | 166 |
| 167 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes)
); | 167 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes)
); |
| 168 decoder->setImagePlanes(imagePlanes.release()); | 168 decoder->setImagePlanes(std::move(imagePlanes)); |
| 169 | 169 |
| 170 ASSERT(decoder->canDecodeToYUV()); | 170 ASSERT(decoder->canDecodeToYUV()); |
| 171 | 171 |
| 172 if (decoder->decodeToYUV()) { | 172 if (decoder->decodeToYUV()) { |
| 173 setHasAlpha(0, false); // YUV is always opaque | 173 setHasAlpha(0, false); // YUV is always opaque |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 ASSERT(decoder->failed()); | 177 ASSERT(decoder->failed()); |
| 178 m_yuvDecodingFailed = true; | 178 m_yuvDecodingFailed = true; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 else if (index == m_frameCount - 1) | 227 else if (index == m_frameCount - 1) |
| 228 decoder->clearCacheExceptFrame(kNotFound); | 228 decoder->clearCacheExceptFrame(kNotFound); |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (resumeDecoding) { | 231 if (resumeDecoding) { |
| 232 if (removeDecoder) | 232 if (removeDecoder) |
| 233 ImageDecodingStore::instance().removeDecoder(this, decoder); | 233 ImageDecodingStore::instance().removeDecoder(this, decoder); |
| 234 else | 234 else |
| 235 ImageDecodingStore::instance().unlockDecoder(this, decoder); | 235 ImageDecodingStore::instance().unlockDecoder(this, decoder); |
| 236 } else if (!removeDecoder) { | 236 } else if (!removeDecoder) { |
| 237 ImageDecodingStore::instance().insertDecoder(this, decoderContainer.rele
ase()); | 237 ImageDecodingStore::instance().insertDecoder(this, std::move(decoderCont
ainer)); |
| 238 } | 238 } |
| 239 return fullSizeImage; | 239 return fullSizeImage; |
| 240 } | 240 } |
| 241 | 241 |
| 242 void ImageFrameGenerator::setHasAlpha(size_t index, bool hasAlpha) | 242 void ImageFrameGenerator::setHasAlpha(size_t index, bool hasAlpha) |
| 243 { | 243 { |
| 244 MutexLocker lock(m_alphaMutex); | 244 MutexLocker lock(m_alphaMutex); |
| 245 if (index >= m_hasAlpha.size()) { | 245 if (index >= m_hasAlpha.size()) { |
| 246 const size_t oldSize = m_hasAlpha.size(); | 246 const size_t oldSize = m_hasAlpha.size(); |
| 247 m_hasAlpha.resize(index + 1); | 247 m_hasAlpha.resize(index + 1); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 if (m_yuvDecodingFailed) | 325 if (m_yuvDecodingFailed) |
| 326 return false; | 326 return false; |
| 327 | 327 |
| 328 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDecoder::Alp
haPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 328 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDecoder::Alp
haPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
| 329 if (!decoder) | 329 if (!decoder) |
| 330 return false; | 330 return false; |
| 331 | 331 |
| 332 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. | 332 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. |
| 333 decoder->setData(data, true); | 333 decoder->setData(data, true); |
| 334 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); | 334 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); |
| 335 decoder->setImagePlanes(dummyImagePlanes.release()); | 335 decoder->setImagePlanes(std::move(dummyImagePlanes)); |
| 336 | 336 |
| 337 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, sizeInfo->fW
idthBytes); | 337 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, sizeInfo->fW
idthBytes); |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |