| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (m_decodeFailed) | 153 if (m_decodeFailed) |
| 154 return false; | 154 return false; |
| 155 | 155 |
| 156 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", sta
tic_cast<int>(index)); | 156 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", sta
tic_cast<int>(index)); |
| 157 | 157 |
| 158 if (!planes || !planes[0] || !planes[1] || !planes[2] | 158 if (!planes || !planes[0] || !planes[1] || !planes[2] |
| 159 || !rowBytes || !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { | 159 || !rowBytes || !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { |
| 160 return false; | 160 return false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDec
oder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 163 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecoder::d
etermineImageType(*data), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaA
ndColorProfileApplied); |
| 164 // getYUVComponentSizes was already called and was successful, so ImageDecod
er::create must succeed. | 164 // getYUVComponentSizes was already called and was successful, so ImageDecod
er::create must succeed. |
| 165 ASSERT(decoder); | 165 ASSERT(decoder); |
| 166 | 166 |
| 167 decoder->setData(data, true); | 167 decoder->setData(data, true); |
| 168 | 168 |
| 169 std::unique_ptr<ImagePlanes> imagePlanes = wrapUnique(new ImagePlanes(planes
, rowBytes)); | 169 std::unique_ptr<ImagePlanes> imagePlanes = wrapUnique(new ImagePlanes(planes
, rowBytes)); |
| 170 decoder->setImagePlanes(std::move(imagePlanes)); | 170 decoder->setImagePlanes(std::move(imagePlanes)); |
| 171 | 171 |
| 172 ASSERT(decoder->canDecodeToYUV()); | 172 ASSERT(decoder->canDecodeToYUV()); |
| 173 | 173 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 // Try to create an ImageDecoder if we are not given one. | 261 // Try to create an ImageDecoder if we are not given one. |
| 262 ASSERT(decoder); | 262 ASSERT(decoder); |
| 263 bool newDecoder = false; | 263 bool newDecoder = false; |
| 264 if (!*decoder) { | 264 if (!*decoder) { |
| 265 newDecoder = true; | 265 newDecoder = true; |
| 266 if (m_imageDecoderFactory) | 266 if (m_imageDecoderFactory) |
| 267 *decoder = m_imageDecoderFactory->create().release(); | 267 *decoder = m_imageDecoderFactory->create().release(); |
| 268 | 268 |
| 269 if (!*decoder) | 269 if (!*decoder) |
| 270 *decoder = ImageDecoder::create(*data, ImageDecoder::AlphaPremultipl
ied, ImageDecoder::GammaAndColorProfileApplied).release(); | 270 *decoder = ImageDecoder::create(ImageDecoder::determineImageType(*da
ta), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied
).release(); |
| 271 | 271 |
| 272 if (!*decoder) | 272 if (!*decoder) |
| 273 return false; | 273 return false; |
| 274 } | 274 } |
| 275 | 275 |
| 276 if (!m_isMultiFrame && newDecoder && allDataReceived) { | 276 if (!m_isMultiFrame && newDecoder && allDataReceived) { |
| 277 // If we're using an external memory allocator that means we're decoding | 277 // If we're using an external memory allocator that means we're decoding |
| 278 // directly into the output memory and we can save one memcpy. | 278 // directly into the output memory and we can save one memcpy. |
| 279 ASSERT(allocator); | 279 ASSERT(allocator); |
| 280 (*decoder)->setMemoryAllocator(allocator); | 280 (*decoder)->setMemoryAllocator(allocator); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 return true; | 320 return true; |
| 321 } | 321 } |
| 322 | 322 |
| 323 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data, SkYUVSizeInf
o* sizeInfo) | 323 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data, SkYUVSizeInf
o* sizeInfo) |
| 324 { | 324 { |
| 325 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width",
m_fullSize.width(), "height", m_fullSize.height()); | 325 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width",
m_fullSize.width(), "height", m_fullSize.height()); |
| 326 | 326 |
| 327 if (m_yuvDecodingFailed) | 327 if (m_yuvDecodingFailed) |
| 328 return false; | 328 return false; |
| 329 | 329 |
| 330 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageDec
oder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); | 330 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(ImageDecoder::d
etermineImageType(*data), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaA
ndColorProfileApplied); |
| 331 if (!decoder) | 331 if (!decoder) |
| 332 return false; | 332 return false; |
| 333 | 333 |
| 334 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. | 334 // Setting a dummy ImagePlanes object signals to the decoder that we want to
do YUV decoding. |
| 335 decoder->setData(data, true); | 335 decoder->setData(data, true); |
| 336 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); | 336 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); |
| 337 decoder->setImagePlanes(std::move(dummyImagePlanes)); | 337 decoder->setImagePlanes(std::move(dummyImagePlanes)); |
| 338 | 338 |
| 339 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, sizeInfo->fW
idthBytes); | 339 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, sizeInfo->fW
idthBytes); |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace blink | 342 } // namespace blink |
| OLD | NEW |