| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  199     } |  199     } | 
|  200  |  200  | 
|  201     fColorTable.reset(new SkColorTable(colorStorage, colorCount)); |  201     fColorTable.reset(new SkColorTable(colorStorage, colorCount)); | 
|  202     return true; |  202     return true; | 
|  203 } |  203 } | 
|  204  |  204  | 
|  205 /////////////////////////////////////////////////////////////////////////////// |  205 /////////////////////////////////////////////////////////////////////////////// | 
|  206 // Creation |  206 // Creation | 
|  207 /////////////////////////////////////////////////////////////////////////////// |  207 /////////////////////////////////////////////////////////////////////////////// | 
|  208  |  208  | 
|  209 #define PNG_BYTES_TO_CHECK 4 |  209 bool SkPngCodec::IsPng(const char* buf, size_t bytesRead) { | 
|  210  |  210     return !png_sig_cmp((png_bytep) buf, (png_size_t)0, bytesRead); | 
|  211 bool SkPngCodec::IsPng(SkStream* stream) { |  | 
|  212     char buf[PNG_BYTES_TO_CHECK]; |  | 
|  213     if (stream->read(buf, PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK) { |  | 
|  214         return false; |  | 
|  215     } |  | 
|  216     if (png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) { |  | 
|  217         return false; |  | 
|  218     } |  | 
|  219     return true; |  | 
|  220 } |  211 } | 
|  221  |  212  | 
|  222 // Reads the header and initializes the output fields, if not NULL. |  213 // Reads the header and initializes the output fields, if not NULL. | 
|  223 // |  214 // | 
|  224 // @param stream Input data. Will be read to get enough information to properly |  215 // @param stream Input data. Will be read to get enough information to properly | 
|  225 //      setup the codec. |  216 //      setup the codec. | 
|  226 // @param chunkReader SkPngChunkReader, for reading unknown chunks. May be NULL. |  217 // @param chunkReader SkPngChunkReader, for reading unknown chunks. May be NULL. | 
|  227 //      If not NULL, png_ptr will hold an *unowned* pointer to it. The caller is |  218 //      If not NULL, png_ptr will hold an *unowned* pointer to it. The caller is | 
|  228 //      expected to continue to own it for the lifetime of the png_ptr. |  219 //      expected to continue to own it for the lifetime of the png_ptr. | 
|  229 // @param png_ptrp Optional output variable. If non-NULL, will be set to a new |  220 // @param png_ptrp Optional output variable. If non-NULL, will be set to a new | 
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  866     } |  857     } | 
|  867  |  858  | 
|  868     if (1 == numberPasses) { |  859     if (1 == numberPasses) { | 
|  869         return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
     Reader, |  860         return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
     Reader, | 
|  870                                         png_ptr, info_ptr, bitDepth); |  861                                         png_ptr, info_ptr, bitDepth); | 
|  871     } |  862     } | 
|  872  |  863  | 
|  873     return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
      chunkReader, |  864     return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
      chunkReader, | 
|  874                                               png_ptr, info_ptr, bitDepth, numbe
     rPasses); |  865                                               png_ptr, info_ptr, bitDepth, numbe
     rPasses); | 
|  875 } |  866 } | 
| OLD | NEW |