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

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

Issue 2225903004: 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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« 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...) Expand 10 before | Expand all | Expand 10 after
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 if (index < m_frameData.size()) { 101 DCHECK(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::PixelDa ta); 106 frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData);
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()));
121 } 111 }
122 112
123 PassRefPtr<SharedBuffer> DeferredImageDecoder::data() 113 PassRefPtr<SharedBuffer> DeferredImageDecoder::data()
124 { 114 {
125 if (!m_rwBuffer) 115 if (!m_rwBuffer)
126 return nullptr; 116 return nullptr;
127 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot()); 117 RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot());
128 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(); 118 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create();
129 SkROBuffer::Iter it(roBuffer.get()); 119 SkROBuffer::Iter it(roBuffer.get());
130 do { 120 do {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 329 }
340 330
341 } // namespace blink 331 } // namespace blink
342 332
343 namespace WTF { 333 namespace WTF {
344 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> { 334 template<> struct VectorTraits<blink::DeferredFrameData> : public SimpleClassVec torTraits<blink::DeferredFrameData> {
345 STATIC_ONLY(VectorTraits); 335 STATIC_ONLY(VectorTraits);
346 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0. 336 static const bool canInitializeWithMemset = false; // Not all DeferredFrameD ata members initialize to 0.
347 }; 337 };
348 } 338 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698