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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp

Issue 1972683002: Early reporting of opaqueness by decoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 else if (m_reader && m_reader->loopCount() != cLoopCountNotSeen) 81 else if (m_reader && m_reader->loopCount() != cLoopCountNotSeen)
82 m_repetitionCount = m_reader->loopCount(); 82 m_repetitionCount = m_reader->loopCount();
83 return m_repetitionCount; 83 return m_repetitionCount;
84 } 84 }
85 85
86 bool GIFImageDecoder::frameIsCompleteAtIndex(size_t index) const 86 bool GIFImageDecoder::frameIsCompleteAtIndex(size_t index) const
87 { 87 {
88 return m_reader && (index < m_reader->imagesCount()) && m_reader->frameConte xt(index)->isComplete(); 88 return m_reader && (index < m_reader->imagesCount()) && m_reader->frameConte xt(index)->isComplete();
89 } 89 }
90 90
91 bool GIFImageDecoder::frameHasAlphaAtIndex(size_t index) const
92 {
93 if (!frameIsCompleteAtIndex(index))
94 return true;
95 if (m_reader) {
96 const GIFFrameContext& frameContext = *m_reader->frameContext(index);
97 const GIFColorMap::Table& colorTable = frameContext.localColorMap().isDe fined() ? frameContext.localColorMap().getTable() : m_reader->globalColorMap().g etTable();
98 if (frameContext.transparentPixel() >= colorTable.size())
scroggo_chromium 2016/05/16 20:38:20 Isn't it also possible that this frame does not co
99 return false;
100 }
101 return m_frameBufferCache[index].hasAlpha();
102 }
103
91 float GIFImageDecoder::frameDurationAtIndex(size_t index) const 104 float GIFImageDecoder::frameDurationAtIndex(size_t index) const
92 { 105 {
93 return (m_reader && (index < m_reader->imagesCount()) && 106 return (m_reader && (index < m_reader->imagesCount()) &&
94 m_reader->frameContext(index)->isHeaderDefined()) ? 107 m_reader->frameContext(index)->isHeaderDefined()) ?
95 m_reader->frameContext(index)->delayTime() : 0; 108 m_reader->frameContext(index)->delayTime() : 0;
96 } 109 }
97 110
98 bool GIFImageDecoder::setFailed() 111 bool GIFImageDecoder::setFailed()
99 { 112 {
100 m_reader.clear(); 113 m_reader.clear();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 381
369 // Update our status to be partially complete. 382 // Update our status to be partially complete.
370 buffer->setStatus(ImageFrame::FramePartial); 383 buffer->setStatus(ImageFrame::FramePartial);
371 384
372 // Reset the alpha pixel tracker for this frame. 385 // Reset the alpha pixel tracker for this frame.
373 m_currentBufferSawAlpha = false; 386 m_currentBufferSawAlpha = false;
374 return true; 387 return true;
375 } 388 }
376 389
377 } // namespace blink 390 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698