Supply separate flags for onBuildTileIndex
Since png and jpeg's implementations of onBuildTileIndex rely on modifications to their underlying libraries, rather than whether we are running on Android, use separate flags that can be disabled independently. This will allow us to easily turn off the feature. It also is a step towards building and running on other platforms for testing (e.g. valgrind/ASAN to find memory leaks etc). Review URL: https://codereview.chromium.org/1401283003
This commit is contained in:
parent
94dd7a52d3
commit
8e48ed51ba
@ -54,6 +54,10 @@ SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderErrors,
|
||||
"Suppress most JPG error messages when decode "
|
||||
"function fails.");
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_JPEG_NO_INDEX_SUPPORTED)
|
||||
#define SK_JPEG_INDEX_SUPPORTED
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -85,7 +89,7 @@ static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
class SkJPEGImageIndex {
|
||||
public:
|
||||
// Takes ownership of stream.
|
||||
@ -203,7 +207,7 @@ private:
|
||||
|
||||
class SkJPEGImageDecoder : public SkImageDecoder {
|
||||
public:
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
SkJPEGImageDecoder() {
|
||||
fImageIndex = nullptr;
|
||||
fImageWidth = 0;
|
||||
@ -218,7 +222,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) override;
|
||||
bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) override;
|
||||
#endif
|
||||
@ -228,7 +232,7 @@ protected:
|
||||
SkYUVColorSpace* colorSpace) override;
|
||||
|
||||
private:
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
SkJPEGImageIndex* fImageIndex;
|
||||
int fImageWidth;
|
||||
int fImageHeight;
|
||||
@ -295,7 +299,7 @@ static bool skip_src_rows(jpeg_decompress_struct* cinfo, void* buffer, int count
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
static bool skip_src_rows_tile(jpeg_decompress_struct* cinfo,
|
||||
huffman_index *index, void* buffer, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
@ -329,7 +333,7 @@ static bool return_false(const jpeg_decompress_struct& cinfo,
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
static bool return_false(const jpeg_decompress_struct& cinfo,
|
||||
const SkBitmap& bm, const char caller[]) {
|
||||
print_jpeg_decoder_errors(cinfo, bm.width(), bm.height(), caller);
|
||||
@ -939,7 +943,7 @@ bool SkJPEGImageDecoder::onDecodeYUV8Planes(SkStream* stream, SkISize componentS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_JPEG_INDEX_SUPPORTED
|
||||
bool SkJPEGImageDecoder::onBuildTileIndex(SkStreamRewindable* stream, int *width, int *height) {
|
||||
SkAutoTDelete<SkJPEGImageIndex> imageIndex(new SkJPEGImageIndex(stream, this));
|
||||
|
||||
|
@ -52,7 +52,9 @@ SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings,
|
||||
"Suppress most PNG warnings when calling image decode "
|
||||
"functions.");
|
||||
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_PNG_NO_INDEX_SUPPORTED)
|
||||
#define SK_PNG_INDEX_SUPPORTED
|
||||
#endif
|
||||
|
||||
class SkPNGImageIndex {
|
||||
public:
|
||||
@ -88,7 +90,7 @@ public:
|
||||
virtual ~SkPNGImageDecoder() { delete fImageIndex; }
|
||||
|
||||
protected:
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_PNG_INDEX_SUPPORTED
|
||||
bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) override;
|
||||
bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& region) override;
|
||||
#endif
|
||||
@ -132,7 +134,7 @@ static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_PNG_INDEX_SUPPORTED
|
||||
static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) {
|
||||
SkStreamRewindable* sk_stream = (SkStreamRewindable*) png_get_io_ptr(png_ptr);
|
||||
if (!sk_stream->rewind()) {
|
||||
@ -262,7 +264,7 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
|
||||
* png_init_io() here you would call:
|
||||
*/
|
||||
png_set_read_fn(png_ptr, (void *)sk_stream, sk_read_fn);
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_PNG_INDEX_SUPPORTED
|
||||
png_set_seek_fn(png_ptr, sk_seek_fn);
|
||||
#endif
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
@ -726,7 +728,7 @@ bool SkPNGImageDecoder::decodePalette(png_structp png_ptr, png_infop info_ptr,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_BUILD_FOR_ANDROID
|
||||
#ifdef SK_PNG_INDEX_SUPPORTED
|
||||
|
||||
bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *width, int *height) {
|
||||
SkAutoTDelete<SkStreamRewindable> streamDeleter(sk_stream);
|
||||
|
Loading…
Reference in New Issue
Block a user