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

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

Issue 1011343003: Enabling ico decoding with use of png and bmp decoders (Closed) Base URL: https://skia.googlesource.com/skia.git@swizzle
Patch Set: Clean up before public review Created 5 years, 9 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
« src/codec/SkCodec_libico.cpp ('K') | « src/codec/SkCodec_libico.cpp ('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 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_libpng.h" 8 #include "SkCodec_libpng.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 *colorPtr = colorPtr[-1]; 181 *colorPtr = colorPtr[-1];
182 } 182 }
183 183
184 return SkNEW_ARGS(SkColorTable, (colorStorage, colorCount)); 184 return SkNEW_ARGS(SkColorTable, (colorStorage, colorCount));
185 } 185 }
186 186
187 /////////////////////////////////////////////////////////////////////////////// 187 ///////////////////////////////////////////////////////////////////////////////
188 // Creation 188 // Creation
189 /////////////////////////////////////////////////////////////////////////////// 189 ///////////////////////////////////////////////////////////////////////////////
190 190
191 #define PNG_BYTES_TO_CHECK 4
192
193 bool SkPngCodec::IsPng(SkStream* stream) { 191 bool SkPngCodec::IsPng(SkStream* stream) {
194 char buf[PNG_BYTES_TO_CHECK]; 192 char buf[PNG_BYTES_TO_CHECK];
195 if (stream->read(buf, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK) { 193 if (stream->read(buf, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK) {
196 return false; 194 return false;
197 } 195 }
198 if (png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) { 196 if (png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
199 return false; 197 return false;
200 } 198 }
201 return true; 199 return true;
202 } 200 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 478
481 // FIXME: do we need substituteTranspColor? 479 // FIXME: do we need substituteTranspColor?
482 480
483 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) { 481 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) {
484 // FIXME: We want to alert the caller. Is this the right way? 482 // FIXME: We want to alert the caller. Is this the right way?
485 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo); 483 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo);
486 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType); 484 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType);
487 } 485 }
488 return kSuccess; 486 return kSuccess;
489 } 487 }
OLDNEW
« src/codec/SkCodec_libico.cpp ('K') | « src/codec/SkCodec_libico.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698