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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp

Issue 1962563002: Fix ImageDecoder::frameIsCompleteAtIndex - fully received instead of decoded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 25 matching lines...) Expand all
36 36
37 namespace blink { 37 namespace blink {
38 38
39 struct DeferredFrameData { 39 struct DeferredFrameData {
40 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 40 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
41 WTF_MAKE_NONCOPYABLE(DeferredFrameData); 41 WTF_MAKE_NONCOPYABLE(DeferredFrameData);
42 public: 42 public:
43 DeferredFrameData() 43 DeferredFrameData()
44 : m_orientation(DefaultImageOrientation) 44 : m_orientation(DefaultImageOrientation)
45 , m_duration(0) 45 , m_duration(0)
46 , m_isComplete(false) 46 , m_isFullyReceived(false)
47 , m_frameBytes(0) 47 , m_frameBytes(0)
48 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID) 48 , m_uniqueID(DecodingImageGenerator::kNeedNewImageUniqueID)
49 {} 49 {}
50 50
51 ImageOrientation m_orientation; 51 ImageOrientation m_orientation;
52 float m_duration; 52 float m_duration;
53 bool m_isComplete; 53 bool m_isFullyReceived;
54 size_t m_frameBytes; 54 size_t m_frameBytes;
55 uint32_t m_uniqueID; 55 uint32_t m_uniqueID;
56 }; 56 };
57 57
58 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer & data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfil eOption colorOptions) 58 PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::create(const SharedBuffer & data, ImageDecoder::AlphaOption alphaOption, ImageDecoder::GammaAndColorProfil eOption colorOptions)
59 { 59 {
60 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption, colorOptions); 60 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(data, alphaOption, colorOptions);
61 61
62 if (!actualDecoder) 62 if (!actualDecoder)
63 return nullptr; 63 return nullptr;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const 187 bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const
188 { 188 {
189 if (m_actualDecoder) 189 if (m_actualDecoder)
190 return m_actualDecoder->frameHasAlphaAtIndex(index); 190 return m_actualDecoder->frameHasAlphaAtIndex(index);
191 if (!m_frameGenerator->isMultiFrame()) 191 if (!m_frameGenerator->isMultiFrame())
192 return m_frameGenerator->hasAlpha(index); 192 return m_frameGenerator->hasAlpha(index);
193 return true; 193 return true;
194 } 194 }
195 195
196 bool DeferredImageDecoder::frameIsCompleteAtIndex(size_t index) const 196 bool DeferredImageDecoder::frameIsFullyReceivedAtIndex(size_t index) const
197 { 197 {
198 if (m_actualDecoder) 198 if (m_actualDecoder)
199 return m_actualDecoder->frameIsCompleteAtIndex(index); 199 return m_actualDecoder->frameIsFullyReceivedAtIndex(index);
200 if (index < m_frameData.size()) 200 if (index < m_frameData.size())
201 return m_frameData[index].m_isComplete; 201 return m_frameData[index].m_isFullyReceived;
202 return false; 202 return false;
203 } 203 }
204 204
205 float DeferredImageDecoder::frameDurationAtIndex(size_t index) const 205 float DeferredImageDecoder::frameDurationAtIndex(size_t index) const
206 { 206 {
207 if (m_actualDecoder) 207 if (m_actualDecoder)
208 return m_actualDecoder->frameDurationAtIndex(index); 208 return m_actualDecoder->frameDurationAtIndex(index);
209 if (index < m_frameData.size()) 209 if (index < m_frameData.size())
210 return m_frameData[index].m_duration; 210 return m_frameData[index].m_duration;
211 return 0; 211 return 0;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 const size_t previousSize = m_frameData.size(); 257 const size_t previousSize = m_frameData.size();
258 m_frameData.resize(m_actualDecoder->frameCount()); 258 m_frameData.resize(m_actualDecoder->frameCount());
259 259
260 // We have encountered a broken image file. Simply bail. 260 // We have encountered a broken image file. Simply bail.
261 if (m_frameData.size() < previousSize) 261 if (m_frameData.size() < previousSize)
262 return; 262 return;
263 263
264 for (size_t i = previousSize; i < m_frameData.size(); ++i) { 264 for (size_t i = previousSize; i < m_frameData.size(); ++i) {
265 m_frameData[i].m_duration = m_actualDecoder->frameDurationAtIndex(i); 265 m_frameData[i].m_duration = m_actualDecoder->frameDurationAtIndex(i);
266 m_frameData[i].m_orientation = m_actualDecoder->orientation(); 266 m_frameData[i].m_orientation = m_actualDecoder->orientation();
267 m_frameData[i].m_isComplete = m_actualDecoder->frameIsCompleteAtIndex(i) ; 267 m_frameData[i].m_isFullyReceived = m_actualDecoder->frameIsFullyReceived AtIndex(i);
268 } 268 }
269 269
270 // The last lazy decoded frame created from previous call might be 270 // The last lazy decoded frame created from previous call might be
271 // incomplete so update its state. 271 // incomplete so update its state.
272 if (previousSize) { 272 if (previousSize) {
273 const size_t lastFrame = previousSize - 1; 273 const size_t lastFrame = previousSize - 1;
274 m_frameData[lastFrame].m_isComplete = m_actualDecoder->frameIsCompleteAt Index(lastFrame); 274 m_frameData[lastFrame].m_isFullyReceived = m_actualDecoder->frameIsFully ReceivedAtIndex(lastFrame);
275 } 275 }
276 276
277 if (m_allDataReceived) { 277 if (m_allDataReceived) {
278 m_repetitionCount = m_actualDecoder->repetitionCount(); 278 m_repetitionCount = m_actualDecoder->repetitionCount();
279 m_actualDecoder.reset(); 279 m_actualDecoder.reset();
280 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex. 280 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex.
281 } 281 }
282 } 282 }
283 283
284 inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownToBeOpaqu e) 284 inline SkImageInfo imageInfoFrom(const SkISize& decodedSize, bool knownToBeOpaqu e)
(...skipping 10 matching lines...) Expand all
295 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot()); 295 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot());
296 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkROBuffer(ro Buffer.release()); 296 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkROBuffer(ro Buffer.release());
297 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, imageInfoFrom(decodedSize, knownToBeOpaque), segmentReader.release(), m_all DataReceived, index, m_frameData[index].m_uniqueID); 297 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, imageInfoFrom(decodedSize, knownToBeOpaque), segmentReader.release(), m_all DataReceived, index, m_frameData[index].m_uniqueID);
298 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); // S kImage takes ownership of the generator. 298 RefPtr<SkImage> image = adoptRef(SkImage::NewFromGenerator(generator)); // S kImage takes ownership of the generator.
299 if (!image) 299 if (!image)
300 return nullptr; 300 return nullptr;
301 301
302 // We can consider decoded bitmap constant and reuse uniqueID only after all 302 // We can consider decoded bitmap constant and reuse uniqueID only after all
303 // data is received. We reuse it also for multiframe images when image data 303 // data is received. We reuse it also for multiframe images when image data
304 // is partially received but the frame data is fully received. 304 // is partially received but the frame data is fully received.
305 if (m_allDataReceived || m_frameData[index].m_isComplete) { 305 if (m_allDataReceived || m_frameData[index].m_isFullyReceived) {
306 DCHECK(m_frameData[index].m_uniqueID == DecodingImageGenerator::kNeedNew ImageUniqueID || m_frameData[index].m_uniqueID == image->uniqueID()); 306 DCHECK(m_frameData[index].m_uniqueID == DecodingImageGenerator::kNeedNew ImageUniqueID || m_frameData[index].m_uniqueID == image->uniqueID());
307 m_frameData[index].m_uniqueID = image->uniqueID(); 307 m_frameData[index].m_uniqueID = image->uniqueID();
308 } 308 }
309 309
310 generator->setCanYUVDecode(m_canYUVDecode); 310 generator->setCanYUVDecode(m_canYUVDecode);
311 311
312 return image.release(); 312 return image.release();
313 } 313 }
314 314
315 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 315 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
316 { 316 {
317 // TODO: Implement. 317 // TODO: Implement.
318 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 318 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
319 } 319 }
320 320
321 } // namespace blink 321 } // namespace blink
322 322
323 namespace WTF { 323 namespace WTF {
324 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> { 324 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> {
325 STATIC_ONLY(VectorTraits); 325 STATIC_ONLY(VectorTraits);
326 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0. 326 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0.
327 }; 327 };
328 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698