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

Side by Side Diff: src/codec/SkWebpCodec.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkWebpCodec.h" 9 #include "SkWebpCodec.h"
10 #include "SkTemplates.h" 10 #include "SkTemplates.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 SkAutoTCallVProc<WebPIDecoder, WebPIDelete> idec(WebPIDecode(nullptr, 0, &co nfig)); 224 SkAutoTCallVProc<WebPIDecoder, WebPIDelete> idec(WebPIDecode(nullptr, 0, &co nfig));
225 if (!idec) { 225 if (!idec) {
226 return kInvalidInput; 226 return kInvalidInput;
227 } 227 }
228 228
229 SkAutoMalloc storage(BUFFER_SIZE); 229 SkAutoMalloc storage(BUFFER_SIZE);
230 uint8_t* buffer = static_cast<uint8_t*>(storage.get()); 230 uint8_t* buffer = static_cast<uint8_t*>(storage.get());
231 while (true) { 231 while (true) {
232 const size_t bytesRead = stream()->read(buffer, BUFFER_SIZE); 232 const size_t bytesRead = stream()->read(buffer, BUFFER_SIZE);
233 if (0 == bytesRead) { 233 if (0 == bytesRead) {
234 // FIXME: Maybe this is an incomplete image? How to decide? Based 234 int rowsDecoded;
235 // on the number of rows decoded? We can know the number of rows 235 WebPIDecGetRGB(idec, &rowsDecoded, NULL, NULL, NULL);
236 // decoded using WebPIDecGetRGB. 236 this->setIncompleteScanlines(dstDimensions.height() - rowsDecoded);
237 return kInvalidInput; 237 return kIncompleteInput;
238 } 238 }
239 239
240 switch (WebPIAppend(idec, buffer, bytesRead)) { 240 switch (WebPIAppend(idec, buffer, bytesRead)) {
241 case VP8_STATUS_OK: 241 case VP8_STATUS_OK:
242 return kSuccess; 242 return kSuccess;
243 case VP8_STATUS_SUSPENDED: 243 case VP8_STATUS_SUSPENDED:
244 // Break out of the switch statement. Continue the loop. 244 // Break out of the switch statement. Continue the loop.
245 break; 245 break;
246 default: 246 default:
247 return kInvalidInput; 247 return kInvalidInput;
248 } 248 }
249 } 249 }
250 } 250 }
251 251
252 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) 252 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream)
253 : INHERITED(info, stream) {} 253 : INHERITED(info, stream) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698