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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 1812273003: Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix assertion Created 4 years, 8 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 void WEBPImageDecoder::clearDecoder() 150 void WEBPImageDecoder::clearDecoder()
151 { 151 {
152 WebPIDelete(m_decoder); 152 WebPIDelete(m_decoder);
153 m_decoder = 0; 153 m_decoder = 0;
154 m_decodedHeight = 0; 154 m_decodedHeight = 0;
155 m_frameBackgroundHasAlpha = false; 155 m_frameBackgroundHasAlpha = false;
156 } 156 }
157 157
158 void WEBPImageDecoder::onSetData(SharedBuffer*) 158 void WEBPImageDecoder::onSetData(SegmentReader*)
159 { 159 {
160 m_haveAlreadyParsedThisData = false; 160 m_haveAlreadyParsedThisData = false;
161 } 161 }
162 162
163 int WEBPImageDecoder::repetitionCount() const 163 int WEBPImageDecoder::repetitionCount() const
164 { 164 {
165 return failed() ? cAnimationLoopOnce : m_repetitionCount; 165 return failed() ? cAnimationLoopOnce : m_repetitionCount;
166 } 166 }
167 167
168 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const 168 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const
(...skipping 19 matching lines...) Expand all
188 if (m_haveAlreadyParsedThisData) 188 if (m_haveAlreadyParsedThisData)
189 return true; 189 return true;
190 190
191 m_haveAlreadyParsedThisData = true; 191 m_haveAlreadyParsedThisData = true;
192 192
193 const unsigned webpHeaderSize = 30; 193 const unsigned webpHeaderSize = 30;
194 if (m_data->size() < webpHeaderSize) 194 if (m_data->size() < webpHeaderSize)
195 return false; // Await VP8X header so WebPDemuxPartial succeeds. 195 return false; // Await VP8X header so WebPDemuxPartial succeeds.
196 196
197 WebPDemuxDelete(m_demux); 197 WebPDemuxDelete(m_demux);
198 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_data->data()), m_d ata->size() }; 198 m_encodedData = m_data->getAsSkData();
Peter Kasting 2016/03/25 06:24:37 We never reset this anywhere; won't this mean we n
scroggo 2016/03/25 15:49:53 That looks correct. I've updated the code to clear
199 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_encodedData->data( )), m_encodedData->size() };
199 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); 200 m_demux = WebPDemuxPartial(&inputData, &m_demuxState);
200 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) 201 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE))
201 return setFailed(); 202 return setFailed();
202 203
203 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); 204 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER);
204 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) 205 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT))
205 return false; // Wait until the encoded image frame data arrives. 206 return false; // Wait until the encoded image frame data arrives.
206 207
207 if (!isDecodedSizeAvailable()) { 208 if (!isDecodedSizeAvailable()) {
208 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); 209 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return false; 501 return false;
501 } 502 }
502 // FALLTHROUGH 503 // FALLTHROUGH
503 default: 504 default:
504 clear(); 505 clear();
505 return setFailed(); 506 return setFailed();
506 } 507 }
507 } 508 }
508 509
509 } // namespace blink 510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698