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

Unified Diff: src/images/SkJpegUtility.cpp

Issue 21561002: Fixes for JPEG subset decoding. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Remove reference to unused file from the gyp Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkJpegUtility.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkJpegUtility.cpp
diff --git a/src/images/SkJpegUtility.cpp b/src/images/SkJpegUtility.cpp
index 89a0472380b444118e422e28ee2e9aaea8c5d891..1f426f21d4ba9ef2bda40b053dd88ebecf43d61d 100644
--- a/src/images/SkJpegUtility.cpp
+++ b/src/images/SkJpegUtility.cpp
@@ -29,15 +29,16 @@ static void sk_init_source(j_decompress_ptr cinfo) {
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
static boolean sk_seek_input_data(j_decompress_ptr cinfo, long byte_offset) {
skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
+ size_t bo = (size_t) byte_offset;
- if (byte_offset > src->current_offset) {
- (void)src->fStream->skip(byte_offset - src->current_offset);
+ if (bo > src->current_offset) {
+ (void)src->fStream->skip(bo - src->current_offset);
} else {
src->fStream->rewind();
- (void)src->fStream->skip(byte_offset);
+ (void)src->fStream->skip(bo);
}
- src->current_offset = byte_offset;
+ src->current_offset = bo;
src->next_input_byte = (const JOCTET*)src->fBuffer;
src->bytes_in_buffer = 0;
return true;
@@ -109,12 +110,9 @@ static void sk_term_source(j_decompress_ptr /*cinfo*/) {}
///////////////////////////////////////////////////////////////////////////////
-skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder,
- bool ownStream) : fStream(stream) {
- fDecoder = decoder;
- fMemoryBase = NULL;
- fUnrefStream = ownStream;
- fMemoryBaseSize = 0;
+skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder)
+ : fStream(SkRef(stream))
+ , fDecoder(decoder) {
init_source = sk_init_source;
fill_input_buffer = sk_fill_input_buffer;
@@ -128,12 +126,7 @@ skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder,
}
skjpeg_source_mgr::~skjpeg_source_mgr() {
- if (fMemoryBase) {
- sk_free(fMemoryBase);
- }
- if (fUnrefStream) {
- fStream->unref();
- }
+ SkSafeUnref(fStream);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/images/SkJpegUtility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698