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

Unified Diff: src/images/SkJpegUtility.cpp

Issue 12438025: Upstream changes from Android for decoding jpeg images. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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
« src/images/SkImageDecoder_libjpeg.cpp ('K') | « 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 19db0186d27fd392f9c58605b9d6d4f127de88f1..0689ed986c701fc44635306af721037219d71035 100644
--- a/src/images/SkJpegUtility.cpp
+++ b/src/images/SkJpegUtility.cpp
@@ -9,14 +9,39 @@
#include "SkJpegUtility.h"
+#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
+ src->current_offset = 0;
+#endif
src->fStream->rewind();
}
+#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;
+
+ if (byte_offset > src->current_offset) {
+ (void)src->fStream->skip(byte_offset - src->current_offset);
+ } else {
+ src->fStream->rewind();
+ (void)src->fStream->skip(byte_offset);
+ }
+
+ src->current_offset = byte_offset;
+ src->next_input_byte = (const JOCTET*)src->fBuffer;
+ src->bytes_in_buffer = 0;
robertphillips 2013/03/19 13:15:21 true?
djsollen 2013/03/19 15:38:25 Done.
+ return TRUE;
+}
+#endif
+
static boolean sk_fill_input_buffer(j_decompress_ptr cinfo) {
skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
if (src->fDecoder != NULL && src->fDecoder->shouldCancelDecode()) {
@@ -29,6 +54,9 @@ static boolean sk_fill_input_buffer(j_decompress_ptr cinfo) {
return FALSE;
}
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ src->current_offset += bytes;
+#endif
src->next_input_byte = (const JOCTET*)src->fBuffer;
src->bytes_in_buffer = bytes;
return TRUE;
@@ -46,6 +74,9 @@ 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
+ src->current_offset += bytes;
+#endif
bytesToSkip -= bytes;
}
src->next_input_byte = (const JOCTET*)src->fBuffer;
@@ -74,40 +105,11 @@ static boolean sk_resync_to_restart(j_decompress_ptr cinfo, int desired) {
static void sk_term_source(j_decompress_ptr /*cinfo*/) {}
-#if 0 // UNUSED
-static void skmem_init_source(j_decompress_ptr cinfo) {
- skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
- src->next_input_byte = (const JOCTET*)src->fMemoryBase;
- src->bytes_in_buffer = src->fMemoryBaseSize;
-}
-
-static boolean skmem_fill_input_buffer(j_decompress_ptr cinfo) {
- SkDebugf("xxxxxxxxxxxxxx skmem_fill_input_buffer called\n");
- return FALSE;
-}
-
-static void skmem_skip_input_data(j_decompress_ptr cinfo, long num_bytes) {
- skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src;
-// SkDebugf("xxxxxxxxxxxxxx skmem_skip_input_data called %d\n", num_bytes);
- src->next_input_byte = (const JOCTET*)((const char*)src->next_input_byte + num_bytes);
- src->bytes_in_buffer -= num_bytes;
-}
-
-static boolean skmem_resync_to_restart(j_decompress_ptr cinfo, int desired) {
- SkDebugf("xxxxxxxxxxxxxx skmem_resync_to_restart called\n");
- return TRUE;
-}
-
-static void skmem_term_source(j_decompress_ptr /*cinfo*/) {}
-#endif
-
-
///////////////////////////////////////////////////////////////////////////////
skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder,
bool ownStream) : fStream(stream) {
fDecoder = decoder;
- // const void* baseAddr = stream->getMemoryBase();
fMemoryBase = NULL;
fUnrefStream = ownStream;
fMemoryBaseSize = 0;
@@ -117,6 +119,9 @@ 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
+ seek_input_data = sk_seek_input_data;
+#endif
// SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBaseSize);
}
« src/images/SkImageDecoder_libjpeg.cpp ('K') | « src/images/SkJpegUtility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698