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

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: Response to comments 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
« no previous file with comments | « src/codec/SkBmpStandardCodec.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | 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 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 175 }
183 // If reading the image descriptor is successful, the image count will be 176 // If reading the image descriptor is successful, the image count will be
184 // incremented. 177 // incremented.
185 SkASSERT(gif->ImageCount >= 1); 178 SkASSERT(gif->ImageCount >= 1);
186 179
187 if (nullptr != codecOut) { 180 if (nullptr != codecOut) {
188 SkISize size; 181 SkISize size;
189 SkIRect frameRect; 182 SkIRect frameRect;
190 if (!GetDimensions(gif, &size, &frameRect)) { 183 if (!GetDimensions(gif, &size, &frameRect)) {
191 gif_error("Invalid gif size.\n"); 184 gif_error("Invalid gif size.\n");
185 return false;
192 } 186 }
193 bool frameIsSubset = (size != frameRect.size()); 187 bool frameIsSubset = (size != frameRect.size());
194 188
195 // Determine the recommended alpha type. The transIndex might be valid if it less 189 // Determine the recommended alpha type. The transIndex might be valid if it less
196 // than 256. We are not certain that the index is valid until we proces s the color 190 // than 256. We are not certain that the index is valid until we proces s the color
197 // table, since some gifs have color tables with less than 256 colors. If 191 // table, since some gifs have color tables with less than 256 colors. If
198 // there might be a valid transparent index, we must indicate that the i mage has 192 // there might be a valid transparent index, we must indicate that the i mage has
199 // alpha. 193 // alpha.
200 // In the case where we must support alpha, we have the option to set th e 194 // In the case where we must support alpha, we have the option to set th e
201 // suggested alpha type to kPremul or kUnpremul. Both are valid since t he alpha 195 // suggested alpha type to kPremul or kUnpremul. Both are valid since t he alpha
(...skipping 28 matching lines...) Expand all
230 return codec; 224 return codec;
231 } 225 }
232 return nullptr; 226 return nullptr;
233 } 227 }
234 228
235 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType * gif, 229 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType * gif,
236 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset) 230 uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset)
237 : INHERITED(srcInfo, stream) 231 : INHERITED(srcInfo, stream)
238 , fGif(gif) 232 , fGif(gif)
239 , fSrcBuffer(new uint8_t[this->getInfo().width()]) 233 , fSrcBuffer(new uint8_t[this->getInfo().width()])
234 , fFrameRect(frameRect)
240 // If it is valid, fTransIndex will be used to set fFillIndex. We don't kno w if 235 // 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 236 // fTransIndex is valid until we process the color table, since fTransIndex may
242 // be greater than the size of the color table. 237 // be greater than the size of the color table.
243 , fTransIndex(transIndex) 238 , fTransIndex(transIndex)
244 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid, or if 239 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid, or if
245 // there is a valid background color. 240 // there is a valid background color.
246 , fFillIndex(0) 241 , fFillIndex(0)
247 , fFrameRect(frameRect)
248 , fFrameIsSubset(frameIsSubset) 242 , fFrameIsSubset(frameIsSubset)
243 , fSwizzler(NULL)
249 , fColorTable(NULL) 244 , fColorTable(NULL)
250 , fSwizzler(NULL)
251 {} 245 {}
252 246
253 bool SkGifCodec::onRewind() { 247 bool SkGifCodec::onRewind() {
254 GifFileType* gifOut = nullptr; 248 GifFileType* gifOut = nullptr;
255 if (!ReadHeader(this->stream(), nullptr, &gifOut)) { 249 if (!ReadHeader(this->stream(), nullptr, &gifOut)) {
256 return false; 250 return false;
257 } 251 }
258 252
259 SkASSERT(nullptr != gifOut); 253 SkASSERT(nullptr != gifOut);
260 fGif.reset(gifOut); 254 fGif.reset(gifOut);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 581
588 int SkGifCodec::onOutputScanline(int inputScanline) const { 582 int SkGifCodec::onOutputScanline(int inputScanline) const {
589 if (fGif->Image.Interlace) { 583 if (fGif->Image.Interlace) {
590 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott om()) { 584 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bott om()) {
591 return inputScanline; 585 return inputScanline;
592 } 586 }
593 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram eRect.height()); 587 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFram eRect.height());
594 } 588 }
595 return inputScanline; 589 return inputScanline;
596 } 590 }
OLDNEW
« no previous file with comments | « src/codec/SkBmpStandardCodec.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698