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

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

Issue 1400343005: Reenable warnings in src/codec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Removed Google3 code from SkJpegCodec, fixed skip_scanlines fallback code, fixed additional warning… Created 5 years, 2 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 "SkCodec_libgif.h" 8 #include "SkCodec_libgif.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 12 matching lines...) Expand all
23 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || 23 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
24 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) 24 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0)
25 { 25 {
26 return true; 26 return true;
27 } 27 }
28 } 28 }
29 return false; 29 return false;
30 } 30 }
31 31
32 /* 32 /*
33 * Warning reporting function
34 */
35 static void gif_warning(const char* msg) {
36 SkCodecPrintf("Gif Warning: %s\n", msg);
37 }
38
39 /*
40 * Error function 33 * Error function
41 */ 34 */
42 static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCod ec::kInvalidInput) { 35 static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCod ec::kInvalidInput) {
43 SkCodecPrintf("Gif Error: %s\n", msg); 36 SkCodecPrintf("Gif Error: %s\n", msg);
44 return result; 37 return result;
45 } 38 }
46 39
47 40
48 /* 41 /*
49 * Read function that will be passed to gif_lib 42 * Read function that will be passed to gif_lib
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return codec; 223 return codec;
231 } 224 }
232 return nullptr; 225 return nullptr;
233 } 226 }
234 227
235 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType * gif, 228 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType * gif,
236 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset) 229 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset)
237 : INHERITED(srcInfo, stream) 230 : INHERITED(srcInfo, stream)
238 , fGif(gif) 231 , fGif(gif)
239 , fSrcBuffer(new uint8_t[this->getInfo().width()]) 232 , fSrcBuffer(new uint8_t[this->getInfo().width()])
233 , fFrameRect(frameRect)
240 // If it is valid, fTransIndex will be used to set fFillIndex. We don't kno w if 234 // If it is valid, fTransIndex will be used to set fFillIndex. We don't kno w if
241 // fTransIndex is valid until we process the color table, since fTransIndex may 235 // fTransIndex is valid until we process the color table, since fTransIndex may
242 // be greater than the size of the color table. 236 // be greater than the size of the color table.
243 , fTransIndex(transIndex) 237 , fTransIndex(transIndex)
244 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid, or if 238 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid, or if
245 // there is a valid background color. 239 // there is a valid background color.
246 , fFillIndex(0) 240 , fFillIndex(0)
247 , fFrameRect(frameRect)
248 , fFrameIsSubset(frameIsSubset) 241 , fFrameIsSubset(frameIsSubset)
242 , fSwizzler(NULL)
249 , fColorTable(NULL) 243 , fColorTable(NULL)
250 , fSwizzler(NULL)
251 {} 244 {}
252 245
253 bool SkGifCodec::onRewind() { 246 bool SkGifCodec::onRewind() {
254 GifFileType* gifOut = nullptr; 247 GifFileType* gifOut = nullptr;
255 if (!ReadHeader(this->stream(), nullptr, &gifOut)) { 248 if (!ReadHeader(this->stream(), nullptr, &gifOut)) {
256 return false; 249 return false;
257 } 250 }
258 251
259 SkASSERT(nullptr != gifOut); 252 SkASSERT(nullptr != gifOut);
260 fGif.reset(gifOut); 253 fGif.reset(gifOut);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 353
361 // Ensure that the decode dimensions are large enough to contain the frame 354 // Ensure that the decode dimensions are large enough to contain the frame
362 width = SkTMax(width, frameWidth + frameLeft); 355 width = SkTMax(width, frameWidth + frameLeft);
363 height = SkTMax(height, frameHeight + frameTop); 356 height = SkTMax(height, frameHeight + frameTop);
364 357
365 // All of these dimensions should be positive, as they are encoded as unsign ed 16-bit integers. 358 // All of these dimensions should be positive, as they are encoded as unsign ed 16-bit integers.
366 // It is unclear why giflib casts them to ints. We will go ahead and check that they are 359 // It is unclear why giflib casts them to ints. We will go ahead and check that they are
367 // in fact positive. 360 // in fact positive.
368 if (frameLeft < 0 || frameTop < 0 || frameWidth < 0 || frameHeight < 0 || wi dth <= 0 || 361 if (frameLeft < 0 || frameTop < 0 || frameWidth < 0 || frameHeight < 0 || wi dth <= 0 ||
369 height <= 0) { 362 height <= 0) {
363 size->set(0, 0);
364 frameRect->setXYWH(0, 0, 0, 0);
370 return false; 365 return false;
371 } 366 }
372 367
373 frameRect->setXYWH(frameLeft, frameTop, frameWidth, frameHeight); 368 frameRect->setXYWH(frameLeft, frameTop, frameWidth, frameHeight);
374 size->set(width, height); 369 size->set(width, height);
375 return true; 370 return true;
376 } 371 }
377 372
378 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inp utColorPtr, 373 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inp utColorPtr,
379 int* inputColorCount) { 374 int* inputColorCount) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 582
588 int SkGifCodec::onOutputScanline(int inputScanline) const { 583 int SkGifCodec::onOutputScanline(int inputScanline) const {
589 if (fGif->Image.Interlace) { 584 if (fGif->Image.Interlace) {
590 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott om()) { 585 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott om()) {
591 return inputScanline; 586 return inputScanline;
592 } 587 }
593 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram eRect.height()); 588 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram eRect.height());
594 } 589 }
595 return inputScanline; 590 return inputScanline;
596 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698