OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |