Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/platform/graphics/ImageFrameGenerator.cpp

Issue 544323002: Non DCTSIZE multiple width support for JPEG YUV decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ASSERT(bitmap.height() == scaledSize.height()); 126 ASSERT(bitmap.height() == scaledSize.height());
127 127
128 bool result = true; 128 bool result = true;
129 // Check to see if decoder has written directly to the memory provided 129 // Check to see if decoder has written directly to the memory provided
130 // by Skia. If not make a copy. 130 // by Skia. If not make a copy.
131 if (bitmap.getPixels() != pixels) 131 if (bitmap.getPixels() != pixels)
132 result = bitmap.copyPixelsTo(pixels, rowBytes * info.fHeight, rowBytes); 132 result = bitmap.copyPixelsTo(pixels, rowBytes * info.fHeight, rowBytes);
133 return result; 133 return result;
134 } 134 }
135 135
136 bool ImageFrameGenerator::decodeToYUV(void* planes[3], size_t rowBytes[3]) 136 bool ImageFrameGenerator::decodeToYUV(SkISize componentSizes[3], void* planes[3] , size_t rowBytes[3])
137 { 137 {
138 // This method is called to populate a discardable memory owned by Skia. 138 // This method is called to populate a discardable memory owned by Skia.
139 139
140 // Prevents concurrent decode or scale operations on the same image data. 140 // Prevents concurrent decode or scale operations on the same image data.
141 MutexLocker lock(m_decodeMutex); 141 MutexLocker lock(m_decodeMutex);
142 142
143 if (m_decodeFailedAndEmpty) 143 if (m_decodeFailedAndEmpty)
144 return false; 144 return false;
145 145
146 TRACE_EVENT2("blink", "ImageFrameGenerator::decodeToYUV", "generator", this, "decodeCount", static_cast<int>(m_decodeCount)); 146 TRACE_EVENT2("blink", "ImageFrameGenerator::decodeToYUV", "generator", this, "decodeCount", static_cast<int>(m_decodeCount));
(...skipping 11 matching lines...) Expand all
158 ASSERT(allDataReceived); 158 ASSERT(allDataReceived);
159 159
160 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph aPremultiplied, ImageSource::GammaAndColorProfileApplied); 160 OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*data, ImageSource::Alph aPremultiplied, ImageSource::GammaAndColorProfileApplied);
161 if (!decoder) 161 if (!decoder)
162 return false; 162 return false;
163 163
164 decoder->setData(data, allDataReceived); 164 decoder->setData(data, allDataReceived);
165 165
166 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes) ); 166 OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes) );
167 decoder->setImagePlanes(imagePlanes.release()); 167 decoder->setImagePlanes(imagePlanes.release());
168 if (decoder->isSizeAvailable())
Noel Gordon 2014/09/08 16:13:32 ASSERT this?
sugoi1 2014/09/09 15:08:15 isSizeAvailable() has to actually get called, beca
169 getYUVComponentSizes(decoder.get(), componentSizes, false); // Update co mponent sizes with real size
168 bool yuvDecoded = decoder->decodeToYUV(); 170 bool yuvDecoded = decoder->decodeToYUV();
169 if (yuvDecoded) 171 if (yuvDecoded)
170 setHasAlpha(0, false); // YUV is always opaque 172 setHasAlpha(0, false); // YUV is always opaque
171 return yuvDecoded; 173 return yuvDecoded;
172 } 174 }
173 175
174 SkBitmap ImageFrameGenerator::tryToResumeDecode(const SkISize& scaledSize, size_ t index) 176 SkBitmap ImageFrameGenerator::tryToResumeDecode(const SkISize& scaledSize, size_ t index)
175 { 177 {
176 TRACE_EVENT1("blink", "ImageFrameGenerator::tryToResumeDecodeAndScale", "ind ex", static_cast<int>(index)); 178 TRACE_EVENT1("blink", "ImageFrameGenerator::tryToResumeDecodeAndScale", "ind ex", static_cast<int>(index));
177 179
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Setting a dummy ImagePlanes object signals to the decoder that we want to do YUV decoding. 314 // Setting a dummy ImagePlanes object signals to the decoder that we want to do YUV decoding.
313 decoder->setData(data, allDataReceived); 315 decoder->setData(data, allDataReceived);
314 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes); 316 OwnPtr<ImagePlanes> dummyImagePlanes = adoptPtr(new ImagePlanes);
315 decoder->setImagePlanes(dummyImagePlanes.release()); 317 decoder->setImagePlanes(dummyImagePlanes.release());
316 318
317 // canDecodeToYUV() has to be called AFTER isSizeAvailable(), 319 // canDecodeToYUV() has to be called AFTER isSizeAvailable(),
318 // otherwise the output color space may not be set in the decoder. 320 // otherwise the output color space may not be set in the decoder.
319 if (!decoder->isSizeAvailable() || !decoder->canDecodeToYUV()) 321 if (!decoder->isSizeAvailable() || !decoder->canDecodeToYUV())
320 return false; 322 return false;
321 323
322 IntSize size = decoder->decodedYUVSize(0); 324 getYUVComponentSizes(decoder.get(), componentSizes, true);
323 componentSizes[0].set(size.width(), size.height());
324 size = decoder->decodedYUVSize(1);
325 componentSizes[1].set(size.width(), size.height());
326 size = decoder->decodedYUVSize(2);
327 componentSizes[2].set(size.width(), size.height());
328 return true; 325 return true;
329 } 326 }
330 327
328 void ImageFrameGenerator::getYUVComponentSizes(const ImageDecoder* decoder, SkIS ize componentSizes[3], bool memoryAllocation)
329 {
330 IntSize size = decoder->decodedYUVSize(0, memoryAllocation);
331 componentSizes[0].set(size.width(), size.height());
332 size = decoder->decodedYUVSize(1, memoryAllocation);
333 componentSizes[1].set(size.width(), size.height());
334 size = decoder->decodedYUVSize(2, memoryAllocation);
335 componentSizes[2].set(size.width(), size.height());
336 }
337
331 } // namespace blink 338 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698