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

Side by Side Diff: src/images/SkImageDecoder_libpng.cpp

Issue 1040453002: Add SkPngChunkReader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkImageDecoder_empty Created 5 years 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/images/SkImageDecoder.cpp ('k') | src/ports/SkImageDecoder_empty.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
9 #include "SkImageEncoder.h" 9 #include "SkImageEncoder.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) { 117 static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
118 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); 118 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
119 size_t bytes = sk_stream->read(data, length); 119 size_t bytes = sk_stream->read(data, length);
120 if (bytes != length) { 120 if (bytes != length) {
121 png_error(png_ptr, "Read Error!"); 121 png_error(png_ptr, "Read Error!");
122 } 122 }
123 } 123 }
124 124
125 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 125 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
126 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { 126 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) {
127 SkImageDecoder::Peeker* peeker = 127 SkPngChunkReader* peeker = (SkPngChunkReader*)png_get_user_chunk_ptr(png_ptr );
128 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr); 128 // readChunk() returning true means continue decoding
129 // peek() returning true means continue decoding 129 return peeker->readChunk((const char*)chunk->name, chunk->data, chunk->size) ?
130 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ?
131 1 : -1; 130 1 : -1;
132 } 131 }
133 #endif 132 #endif
134 133
135 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { 134 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) {
136 SkDEBUGF(("------ png error %s\n", msg)); 135 SkDEBUGF(("------ png error %s\n", msg));
137 longjmp(png_jmpbuf(png_ptr), 1); 136 longjmp(png_jmpbuf(png_ptr), 1);
138 } 137 }
139 138
140 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) { 139 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) {
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 return SkImageDecoder::kUnknown_Format; 996 return SkImageDecoder::kUnknown_Format;
998 } 997 }
999 998
1000 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 999 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
1001 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; 1000 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr;
1002 } 1001 }
1003 1002
1004 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); 1003 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
1005 static SkImageDecoder_FormatReg gFormatReg(get_format_png); 1004 static SkImageDecoder_FormatReg gFormatReg(get_format_png);
1006 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); 1005 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/ports/SkImageDecoder_empty.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698