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

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

Issue 22861028: Handle SkStream::rewind properly. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Another comment rewrite. Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkStream.h ('k') | src/images/SkImageDecoder_libwebp.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); 117 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
118 size_t bytes = sk_stream->read(data, length); 118 size_t bytes = sk_stream->read(data, length);
119 if (bytes != length) { 119 if (bytes != length) {
120 png_error(png_ptr, "Read Error!"); 120 png_error(png_ptr, "Read Error!");
121 } 121 }
122 } 122 }
123 123
124 #ifdef SK_BUILD_FOR_ANDROID 124 #ifdef SK_BUILD_FOR_ANDROID
125 static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) { 125 static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) {
126 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); 126 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
127 sk_stream->rewind(); 127 if (!sk_stream->rewind()) {
128 png_error(png_ptr, "Failed to rewind stream!");
129 }
128 (void)sk_stream->skip(offset); 130 (void)sk_stream->skip(offset);
129 } 131 }
130 #endif 132 #endif
131 133
132 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { 134 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) {
133 SkImageDecoder::Peeker* peeker = 135 SkImageDecoder::Peeker* peeker =
134 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr); 136 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr);
135 // peek() returning true means continue decoding 137 // peek() returning true means continue decoding
136 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ? 138 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ?
137 1 : -1; 139 1 : -1;
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 return SkImageDecoder::kUnknown_Format; 1199 return SkImageDecoder::kUnknown_Format;
1198 } 1200 }
1199 1201
1200 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 1202 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
1201 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; 1203 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
1202 } 1204 }
1203 1205
1204 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto ry); 1206 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto ry);
1205 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png) ; 1207 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png) ;
1206 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); 1208 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory);
OLDNEW
« no previous file with comments | « include/core/SkStream.h ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698