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

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

Issue 1866243003: Revert of Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h ('k') | 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) 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 WEBPImageDecoder::~WEBPImageDecoder() 138 WEBPImageDecoder::~WEBPImageDecoder()
139 { 139 {
140 clear(); 140 clear();
141 } 141 }
142 142
143 void WEBPImageDecoder::clear() 143 void WEBPImageDecoder::clear()
144 { 144 {
145 WebPDemuxDelete(m_demux); 145 WebPDemuxDelete(m_demux);
146 m_demux = 0; 146 m_demux = 0;
147 m_consolidatedData.clear();
148 clearDecoder(); 147 clearDecoder();
149 } 148 }
150 149
151 void WEBPImageDecoder::clearDecoder() 150 void WEBPImageDecoder::clearDecoder()
152 { 151 {
153 WebPIDelete(m_decoder); 152 WebPIDelete(m_decoder);
154 m_decoder = 0; 153 m_decoder = 0;
155 m_decodedHeight = 0; 154 m_decodedHeight = 0;
156 m_frameBackgroundHasAlpha = false; 155 m_frameBackgroundHasAlpha = false;
157 } 156 }
158 157
159 void WEBPImageDecoder::onSetData(SegmentReader*) 158 void WEBPImageDecoder::onSetData(SharedBuffer*)
160 { 159 {
161 m_haveAlreadyParsedThisData = false; 160 m_haveAlreadyParsedThisData = false;
162 } 161 }
163 162
164 int WEBPImageDecoder::repetitionCount() const 163 int WEBPImageDecoder::repetitionCount() const
165 { 164 {
166 return failed() ? cAnimationLoopOnce : m_repetitionCount; 165 return failed() ? cAnimationLoopOnce : m_repetitionCount;
167 } 166 }
168 167
169 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const 168 bool WEBPImageDecoder::frameIsCompleteAtIndex(size_t index) const
(...skipping 19 matching lines...) Expand all
189 if (m_haveAlreadyParsedThisData) 188 if (m_haveAlreadyParsedThisData)
190 return true; 189 return true;
191 190
192 m_haveAlreadyParsedThisData = true; 191 m_haveAlreadyParsedThisData = true;
193 192
194 const unsigned webpHeaderSize = 30; 193 const unsigned webpHeaderSize = 30;
195 if (m_data->size() < webpHeaderSize) 194 if (m_data->size() < webpHeaderSize)
196 return false; // Await VP8X header so WebPDemuxPartial succeeds. 195 return false; // Await VP8X header so WebPDemuxPartial succeeds.
197 196
198 WebPDemuxDelete(m_demux); 197 WebPDemuxDelete(m_demux);
199 m_consolidatedData = m_data->getAsSkData(); 198 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_data->data()), m_d ata->size() };
200 WebPData inputData = { reinterpret_cast<const uint8_t*>(m_consolidatedData-> data()), m_consolidatedData->size() };
201 m_demux = WebPDemuxPartial(&inputData, &m_demuxState); 199 m_demux = WebPDemuxPartial(&inputData, &m_demuxState);
202 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE)) { 200 if (!m_demux || (isAllDataReceived() && m_demuxState != WEBP_DEMUX_DONE))
203 if (!m_demux)
204 m_consolidatedData.clear();
205 return setFailed(); 201 return setFailed();
206 }
207 202
208 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER); 203 ASSERT(m_demuxState > WEBP_DEMUX_PARSING_HEADER);
209 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT)) 204 if (!WebPDemuxGetI(m_demux, WEBP_FF_FRAME_COUNT))
210 return false; // Wait until the encoded image frame data arrives. 205 return false; // Wait until the encoded image frame data arrives.
211 206
212 if (!isDecodedSizeAvailable()) { 207 if (!isDecodedSizeAvailable()) {
213 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH); 208 int width = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_WIDTH);
214 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT); 209 int height = WebPDemuxGetI(m_demux, WEBP_FF_CANVAS_HEIGHT);
215 if (!setSize(width, height)) 210 if (!setSize(width, height))
216 return setFailed(); 211 return setFailed();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return false; 500 return false;
506 } 501 }
507 // FALLTHROUGH 502 // FALLTHROUGH
508 default: 503 default:
509 clear(); 504 clear();
510 return setFailed(); 505 return setFailed();
511 } 506 }
512 } 507 }
513 508
514 } // namespace blink 509 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698