diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-07 19:53:53 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-07 19:53:53 +0000 |
commit | d79277f67824392876b82cf5635cc11f819e64df (patch) | |
tree | 6edef887bf97ff87059e29669148b11b2a4fb122 | |
parent | 28621517f42682f1e028cbbf87c6afbf6e27a0f6 (diff) |
Support decoding subsets from JPG on Android.
Previously we only supported it for the framework. Making this
change allows us to test subset decoding in skimage, to make sure
we don't break it.
Will require rebaselining android skimage results.
R=djsollen@google.com
Review URL: https://codereview.chromium.org/21612003
git-svn-id: http://skia.googlecode.com/svn/trunk@10625 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/images/SkImageDecoder_libjpeg.cpp | 19 | ||||
-rw-r--r-- | src/images/SkJpegUtility.cpp | 17 | ||||
-rw-r--r-- | tests/ImageDecodingTest.cpp | 4 |
3 files changed, 12 insertions, 28 deletions
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp index 81904ae530..d4047f1973 100644 --- a/src/images/SkImageDecoder_libjpeg.cpp +++ b/src/images/SkImageDecoder_libjpeg.cpp @@ -1,4 +1,3 @@ - /* * Copyright 2007 The Android Open Source Project * @@ -26,12 +25,6 @@ extern "C" { #include "jerror.h" } -// Uncomment to enable the code path used by the Android framework with their -// custom image decoders. -//#if defined(SK_BUILD_FOR_ANDROID) && defined(SK_DEBUG) -// #define SK_BUILD_FOR_ANDROID_FRAMEWORK -//#endif - // These enable timing code that report milliseconds for an encoding/decoding //#define TIME_ENCODE //#define TIME_DECODE @@ -68,7 +61,7 @@ public: : fSrcMgr(stream, decoder) {} ~SkJPEGImageIndex() { -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID jpeg_destroy_huffman_index(&fHuffmanIndex); #endif jpeg_finish_decompress(&fCInfo); @@ -87,14 +80,14 @@ public: jpeg_decompress_struct* cinfo() { return &fCInfo; } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID huffman_index* huffmanIndex() { return &fHuffmanIndex; } #endif private: skjpeg_source_mgr fSrcMgr; jpeg_decompress_struct fCInfo; -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID huffman_index fHuffmanIndex; #endif }; @@ -116,7 +109,7 @@ public: } protected: -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID virtual bool onBuildTileIndex(SkStream *stream, int *width, int *height) SK_OVERRIDE; virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRIDE; #endif @@ -180,7 +173,7 @@ static bool skip_src_rows(jpeg_decompress_struct* cinfo, void* buffer, int count return true; } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID static bool skip_src_rows_tile(jpeg_decompress_struct* cinfo, huffman_index *index, void* buffer, int count) { for (int i = 0; i < count; i++) { @@ -479,7 +472,7 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { return true; } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID bool SkJPEGImageDecoder::onBuildTileIndex(SkStream* stream, int *width, int *height) { SkJPEGImageIndex* imageIndex = SkNEW_ARGS(SkJPEGImageIndex, (stream, this)); diff --git a/src/images/SkJpegUtility.cpp b/src/images/SkJpegUtility.cpp index 1f426f21d4..8d8f62f5a2 100644 --- a/src/images/SkJpegUtility.cpp +++ b/src/images/SkJpegUtility.cpp @@ -1,4 +1,3 @@ - /* * Copyright 2010 The Android Open Source Project * @@ -9,24 +8,18 @@ #include "SkJpegUtility.h" -// Uncomment to enable the code path used by the Android framework with their -// custom image decoders. -//#if defined(SK_BUILD_FOR_ANDROID) && defined(SK_DEBUG) -// #define SK_BUILD_FOR_ANDROID_FRAMEWORK -//#endif - ///////////////////////////////////////////////////////////////////// static void sk_init_source(j_decompress_ptr cinfo) { skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src; src->next_input_byte = (const JOCTET*)src->fBuffer; src->bytes_in_buffer = 0; -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID src->current_offset = 0; #endif src->fStream->rewind(); } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID 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; @@ -57,7 +50,7 @@ static boolean sk_fill_input_buffer(j_decompress_ptr cinfo) { return FALSE; } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID src->current_offset += bytes; #endif src->next_input_byte = (const JOCTET*)src->fBuffer; @@ -77,7 +70,7 @@ static void sk_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { cinfo->err->error_exit((j_common_ptr)cinfo); return; } -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID src->current_offset += bytes; #endif bytesToSkip -= bytes; @@ -119,7 +112,7 @@ skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder) skip_input_data = sk_skip_input_data; resync_to_restart = sk_resync_to_restart; term_source = sk_term_source; -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID seek_input_data = sk_seek_input_data; #endif // SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBaseSize); diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp index 2cf3e527a5..afab02f7a5 100644 --- a/tests/ImageDecodingTest.cpp +++ b/tests/ImageDecodingTest.cpp @@ -225,10 +225,8 @@ static SkStream* create_image_stream(SkImageEncoder::Type type) { // Only runs in debug mode since we are testing for a crash. static void test_stream_life() { const SkImageEncoder::Type gTypes[] = { -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK - SkImageEncoder::kJPEG_Type, -#endif #ifdef SK_BUILD_FOR_ANDROID + SkImageEncoder::kJPEG_Type, SkImageEncoder::kPNG_Type, #endif SkImageEncoder::kWEBP_Type, |