Chromium Code Reviews

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

Issue 2240073002: Revert of Refactoring: Remove dead code in DeferredImageDecoder::createFrameAtIndex (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80 matching lines...)
91 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx tension; 91 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx tension;
92 } 92 }
93 93
94 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) 94 PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index)
95 { 95 {
96 if (m_frameGenerator && m_frameGenerator->decodeFailed()) 96 if (m_frameGenerator && m_frameGenerator->decodeFailed())
97 return nullptr; 97 return nullptr;
98 98
99 prepareLazyDecodedFrames(); 99 prepareLazyDecodedFrames();
100 100
101 DCHECK(index < m_frameData.size()); 101 if (index < m_frameData.size()) {
102 DeferredFrameData* frameData = &m_frameData[index]; 102 DeferredFrameData* frameData = &m_frameData[index];
103 if (m_actualDecoder) 103 if (m_actualDecoder)
104 frameData->m_frameBytes = m_actualDecoder->frameBytesAtIndex(index); 104 frameData->m_frameBytes = m_actualDecoder->frameBytesAtIndex(index);
105 else 105 else
106 frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData); 106 frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelDa ta);
107 // ImageFrameGenerator has the latest known alpha state. There will be a 107 // ImageFrameGenerator has the latest known alpha state. There will be a
108 // performance boost if this frame is opaque. 108 // performance boost if this frame is opaque.
109 DCHECK(m_frameGenerator); 109 DCHECK(m_frameGenerator);
110 return createFrameImageAtIndex(index, !m_frameGenerator->hasAlpha(index)); 110 return createFrameImageAtIndex(index, !m_frameGenerator->hasAlpha(index) );
111 }
112
113 if (!m_actualDecoder || m_actualDecoder->failed())
114 return nullptr;
115
116 ImageFrame* frame = m_actualDecoder->frameBufferAtIndex(index);
117 if (!frame || frame->getStatus() == ImageFrame::FrameEmpty)
118 return nullptr;
119
120 return fromSkSp(SkImage::MakeFromBitmap(frame->bitmap()));
111 } 121 }
112 122
113 PassRefPtr<SharedBuffer> DeferredImageDecoder::data() 123 PassRefPtr<SharedBuffer> DeferredImageDecoder::data()
114 { 124 {
115 if (!m_rwBuffer) 125 if (!m_rwBuffer)
116 return nullptr; 126 return nullptr;
117 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot()); 127 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot());
118 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(); 128 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create();
119 SkROBuffer::Iter it(roBuffer.get()); 129 SkROBuffer::Iter it(roBuffer.get());
120 do { 130 do {
(...skipping 208 matching lines...)
329 } 339 }
330 340
331 } // namespace blink 341 } // namespace blink
332 342
333 namespace WTF { 343 namespace WTF {
334 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> { 344 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> {
335 STATIC_ONLY(VectorTraits); 345 STATIC_ONLY(VectorTraits);
336 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0. 346 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0.
337 }; 347 };
338 } 348 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine