From c8c901fc36816b9a2603a8c129cdca1d2b4d7fe2 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Tue, 24 Jan 2017 16:16:33 -0500 Subject: [PATCH] Use appropriate options in SkJpegCodec readRows() b/34637813 Change-Id: Ibebac2ef8cfe004beb2272c266b580946cedcb08 Reviewed-on: https://skia-review.googlesource.com/7451 Commit-Queue: Matt Sarett Reviewed-by: Leon Scroggins --- src/codec/SkJpegCodec.cpp | 9 +++++---- src/codec/SkJpegCodec.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 8295236258..ce36073b9a 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -485,7 +485,8 @@ bool SkJpegCodec::onDimensionsSupported(const SkISize& size) { return true; } -int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count) { +int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, + const Options& opts) { // Set the jump location for libjpeg-turbo errors if (setjmp(fDecoderMgr->getJmpBuf())) { return 0; @@ -502,7 +503,7 @@ int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes uint32_t* swizzleDst = (uint32_t*) dst; size_t decodeDstRowBytes = rowBytes; size_t swizzleDstRowBytes = rowBytes; - int dstWidth = this->options().fSubset ? this->options().fSubset->width() : dstInfo.width(); + int dstWidth = opts.fSubset ? opts.fSubset->width() : dstInfo.width(); if (fSwizzleSrcRow && fColorXformSrcRow) { decodeDst = (JSAMPLE*) fSwizzleSrcRow; swizzleDst = fColorXformSrcRow; @@ -590,7 +591,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, this->allocateStorage(dstInfo); - int rows = this->readRows(dstInfo, dst, dstRowBytes, dstInfo.height()); + int rows = this->readRows(dstInfo, dst, dstRowBytes, dstInfo.height(), options); if (rows < dstInfo.height()) { *rowsDecoded = rows; return fDecoderMgr->returnFailure("Incomplete image data", kIncompleteInput); @@ -733,7 +734,7 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, } int SkJpegCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) { - int rows = this->readRows(this->dstInfo(), dst, dstRowBytes, count); + int rows = this->readRows(this->dstInfo(), dst, dstRowBytes, count, this->options()); if (rows < count) { // This allows us to skip calling jpeg_finish_decompress(). fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height(); diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h index 9a34aa6a26..af795ceefc 100644 --- a/src/codec/SkJpegCodec.h +++ b/src/codec/SkJpegCodec.h @@ -105,7 +105,7 @@ private: void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options); void allocateStorage(const SkImageInfo& dstInfo); - int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count); + int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, const Options&); /* * Scanline decoding.