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

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

Issue 2618633004: Add support for Animated PNG (Closed)
Patch Set: Fix LayoutTest due to accept header change Created 3 years, 9 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 m_decoderColorBehavior) 300 m_decoderColorBehavior)
301 .release(); 301 .release();
302 // The newly created decoder just grabbed the data. No need to reset it. 302 // The newly created decoder just grabbed the data. No need to reset it.
303 shouldCallSetData = false; 303 shouldCallSetData = false;
304 } 304 }
305 305
306 if (!*decoder) 306 if (!*decoder)
307 return false; 307 return false;
308 } 308 }
309 309
310 if (!m_isMultiFrame && newDecoder && allDataReceived) {
311 // If we're using an external memory allocator that means we're decoding
312 // directly into the output memory and we can save one memcpy.
313 ASSERT(allocator);
314 (*decoder)->setMemoryAllocator(allocator);
315 }
316 310
317 if (shouldCallSetData) 311 if (shouldCallSetData)
318 (*decoder)->setData(data, allDataReceived); 312 (*decoder)->setData(data, allDataReceived);
319 ImageFrame* frame = (*decoder)->frameBufferAtIndex(index); 313
314 bool usingExternalAllocator = false;
320 315
321 // For multi-frame image decoders, we need to know how many frames are 316 // For multi-frame image decoders, we need to know how many frames are
322 // in that image in order to release the decoder when all frames are 317 // in that image in order to release the decoder when all frames are
323 // decoded. frameCount() is reliable only if all data is received and set in 318 // decoded. frameCount() is reliable only if all data is received and set in
324 // decoder, particularly with GIF. 319 // decoder, particularly with GIF.
325 if (allDataReceived) 320 if (allDataReceived) {
326 m_frameCount = (*decoder)->frameCount(); 321 m_frameCount = (*decoder)->frameCount();
322 // TODO (scroggo): If !m_isMultiFrame && newDecoder && allDataReceived, it
323 // should always be the case that 1u == m_frameCount. But it looks like it
324 // is currently possible for m_frameCount to be another value.
325 if (!m_isMultiFrame && newDecoder && 1u == m_frameCount) {
326 // If we're using an external memory allocator that means we're decoding
327 // directly into the output memory and we can save one memcpy.
328 DCHECK(allocator);
329 (*decoder)->setMemoryAllocator(allocator);
330 usingExternalAllocator = true;
331 }
332 }
333
334 ImageFrame* frame = (*decoder)->frameBufferAtIndex(index);
327 335
328 (*decoder)->setData(PassRefPtr<SegmentReader>(nullptr), 336 (*decoder)->setData(PassRefPtr<SegmentReader>(nullptr),
329 false); // Unref SegmentReader from ImageDecoder. 337 false); // Unref SegmentReader from ImageDecoder.
330 (*decoder)->clearCacheExceptFrame(index); 338 (*decoder)->clearCacheExceptFrame(index);
331 (*decoder)->setMemoryAllocator(0); 339 if (usingExternalAllocator)
340 (*decoder)->setMemoryAllocator(0);
332 341
333 if (!frame || frame->getStatus() == ImageFrame::FrameEmpty) 342 if (!frame || frame->getStatus() == ImageFrame::FrameEmpty)
334 return false; 343 return false;
335 344
336 // A cache object is considered complete if we can decode a complete frame. 345 // A cache object is considered complete if we can decode a complete frame.
337 // Or we have received all data. The image might not be fully decoded in 346 // Or we have received all data. The image might not be fully decoded in
338 // the latter case. 347 // the latter case.
339 const bool isDecodeComplete = 348 const bool isDecodeComplete =
340 frame->getStatus() == ImageFrame::FrameComplete || allDataReceived; 349 frame->getStatus() == ImageFrame::FrameComplete || allDataReceived;
341 350
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // do YUV decoding. 383 // do YUV decoding.
375 std::unique_ptr<ImagePlanes> dummyImagePlanes = 384 std::unique_ptr<ImagePlanes> dummyImagePlanes =
376 WTF::wrapUnique(new ImagePlanes); 385 WTF::wrapUnique(new ImagePlanes);
377 decoder->setImagePlanes(std::move(dummyImagePlanes)); 386 decoder->setImagePlanes(std::move(dummyImagePlanes));
378 387
379 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes, 388 return updateYUVComponentSizes(decoder.get(), sizeInfo->fSizes,
380 sizeInfo->fWidthBytes); 389 sizeInfo->fWidthBytes);
381 } 390 }
382 391
383 } // namespace blink 392 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698