| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", | 167 TRACE_EVENT1("blink", "ImageFrameGenerator::decodeToYUV", "frame index", |
| 168 static_cast<int>(index)); | 168 static_cast<int>(index)); |
| 169 | 169 |
| 170 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes || | 170 if (!planes || !planes[0] || !planes[1] || !planes[2] || !rowBytes || |
| 171 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { | 171 !rowBytes[0] || !rowBytes[1] || !rowBytes[2]) { |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 std::unique_ptr<ImageDecoder> decoder = | 175 std::unique_ptr<ImageDecoder> decoder = |
| 176 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, | 176 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, |
| 177 ImageDecoder::GammaAndColorProfileApplied); | 177 ImageDecoder::ColorSpaceApplied); |
| 178 // getYUVComponentSizes was already called and was successful, so | 178 // getYUVComponentSizes was already called and was successful, so |
| 179 // ImageDecoder::create must succeed. | 179 // ImageDecoder::create must succeed. |
| 180 ASSERT(decoder); | 180 ASSERT(decoder); |
| 181 | 181 |
| 182 std::unique_ptr<ImagePlanes> imagePlanes = | 182 std::unique_ptr<ImagePlanes> imagePlanes = |
| 183 wrapUnique(new ImagePlanes(planes, rowBytes)); | 183 wrapUnique(new ImagePlanes(planes, rowBytes)); |
| 184 decoder->setImagePlanes(std::move(imagePlanes)); | 184 decoder->setImagePlanes(std::move(imagePlanes)); |
| 185 | 185 |
| 186 ASSERT(decoder->canDecodeToYUV()); | 186 ASSERT(decoder->canDecodeToYUV()); |
| 187 | 187 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 bool newDecoder = false; | 289 bool newDecoder = false; |
| 290 bool shouldCallSetData = true; | 290 bool shouldCallSetData = true; |
| 291 if (!*decoder) { | 291 if (!*decoder) { |
| 292 newDecoder = true; | 292 newDecoder = true; |
| 293 if (m_imageDecoderFactory) | 293 if (m_imageDecoderFactory) |
| 294 *decoder = m_imageDecoderFactory->create().release(); | 294 *decoder = m_imageDecoderFactory->create().release(); |
| 295 | 295 |
| 296 if (!*decoder) { | 296 if (!*decoder) { |
| 297 *decoder = ImageDecoder::create(data, allDataReceived, | 297 *decoder = ImageDecoder::create(data, allDataReceived, |
| 298 ImageDecoder::AlphaPremultiplied, | 298 ImageDecoder::AlphaPremultiplied, |
| 299 ImageDecoder::GammaAndColorProfileApplied) | 299 ImageDecoder::ColorSpaceApplied) |
| 300 .release(); | 300 .release(); |
| 301 // The newly created decoder just grabbed the data. No need to reset it. | 301 // The newly created decoder just grabbed the data. No need to reset it. |
| 302 shouldCallSetData = false; | 302 shouldCallSetData = false; |
| 303 } | 303 } |
| 304 | 304 |
| 305 if (!*decoder) | 305 if (!*decoder) |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 | 308 |
| 309 if (!m_isMultiFrame && newDecoder && allDataReceived) { | 309 if (!m_isMultiFrame && newDecoder && allDataReceived) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data, | 359 bool ImageFrameGenerator::getYUVComponentSizes(SegmentReader* data, |
| 360 SkYUVSizeInfo* sizeInfo) { | 360 SkYUVSizeInfo* sizeInfo) { |
| 361 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width", | 361 TRACE_EVENT2("blink", "ImageFrameGenerator::getYUVComponentSizes", "width", |
| 362 m_fullSize.width(), "height", m_fullSize.height()); | 362 m_fullSize.width(), "height", m_fullSize.height()); |
| 363 | 363 |
| 364 if (m_yuvDecodingFailed) | 364 if (m_yuvDecodingFailed) |
| 365 return false; | 365 return false; |
| 366 | 366 |
| 367 std::unique_ptr<ImageDecoder> decoder = | 367 std::unique_ptr<ImageDecoder> decoder = |
| 368 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, | 368 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, |
| 369 ImageDecoder::GammaAndColorProfileApplied); | 369 ImageDecoder::ColorSpaceApplied); |
| 370 if (!decoder) | 370 if (!decoder) |
| 371 return false; | 371 return false; |
| 372 | 372 |
| 373 // Setting a dummy ImagePlanes object signals to the decoder that we want to | 373 // Setting a dummy ImagePlanes object signals to the decoder that we want to |
| 374 // do YUV decoding. | 374 // do YUV decoding. |
| 375 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); | 375 std::unique_ptr<ImagePlanes> dummyImagePlanes = wrapUnique(new ImagePlanes); |
| 376 decoder->setImagePlanes(std::move(dummyImagePlanes)); | 376 decoder->setImagePlanes(std::move(dummyImagePlanes)); |
| 377 | 377 |
| 378 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, | 378 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, |
| 379 sizeInfo->fWidthBytes); | 379 sizeInfo->fWidthBytes); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |