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

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 1687863003: Make SkJpegCodec compatible with libjpeg (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 4 years, 10 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/codec/SkCodec.cpp ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index aefe264f1ad9b1963e0359da4d51801b35b3d734..ad08fb671d3e233bf06e82c6f3d1a167aa516680 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -86,7 +86,12 @@ SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream,
* Return the row bytes of a particular image type and width
*/
static size_t get_row_bytes(const j_decompress_ptr dinfo) {
- size_t colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_color_components;
+#ifdef TURBO_HAS_565
+ const size_t colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 :
+ dinfo->out_color_components;
+#else
+ const size_t colorBytes = dinfo->out_color_components;
+#endif
return dinfo->output_width * colorBytes;
}
@@ -186,10 +191,12 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
} else {
// Check the byte ordering of the RGBA color space for the
// current platform
-#if defined(SK_PMCOLOR_IS_RGBA)
+#if defined(SK_PMCOLOR_IS_RGBA) && defined(LIBJPEG_TURBO_VERSION)
scroggo 2016/02/12 17:25:29 Why not: #ifdef LIBJPEG_TURBO_VERSION #ifdef SK
msarett 2016/02/12 18:03:52 Done.
fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA;
-#else
+#elif defined(LIBJPEG_TURBO_VERSION)
fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA;
+#else
+ fDecoderMgr->dinfo()->out_color_space = JCS_RGB;
#endif
}
return true;
@@ -197,8 +204,12 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
if (isCMYK) {
fDecoderMgr->dinfo()->out_color_space = JCS_CMYK;
} else {
+#ifdef TURBO_HAS_565
fDecoderMgr->dinfo()->dither_mode = JDITHER_NONE;
fDecoderMgr->dinfo()->out_color_space = JCS_RGB565;
+#else
+ fDecoderMgr->dinfo()->out_color_space = JCS_RGB;
+#endif
}
return true;
case kGray_8_SkColorType:
@@ -290,7 +301,12 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
// If it's not, we want to know because it means our strategy is not optimal.
SkASSERT(1 == dinfo->rec_outbuf_height);
- if (JCS_CMYK == dinfo->out_color_space) {
+ J_COLOR_SPACE colorSpace = dinfo->out_color_space;
+#ifdef TURBO_HAS_565
msarett 2016/02/12 18:03:52 Also removing this ifdef
+ if (JCS_CMYK == colorSpace) {
+#else
+ if (JCS_CMYK == colorSpace || JCS_RGB == colorSpace) {
+#endif
this->initializeSwizzler(dstInfo, options);
}
@@ -353,6 +369,12 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
}
}
+#ifndef TURBO_HAS_565
scroggo 2016/02/12 17:25:29 For simplicity, I think we can drop the #ifndef an
msarett 2016/02/12 18:03:52 Yeah you're right. I know we like to get rid of #
+ if (JCS_RGB == fDecoderMgr->dinfo()->out_color_space) {
+ srcConfig = SkSwizzler::kRGB;
+ }
+#endif
+
fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, dstInfo, options));
fStorage.reset(get_row_bytes(fDecoderMgr->dinfo()));
fSrcRow = fStorage.get();
@@ -394,7 +416,12 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
// We will need a swizzler if we are performing a subset decode or
// converting from CMYK.
- if (options.fSubset || JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) {
+ J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->out_color_space;
+#ifdef TURBO_HAS_565
scroggo 2016/02/12 17:25:29 Same here
msarett 2016/02/12 18:03:52 Done.
+ if (options.fSubset || JCS_CMYK == colorSpace) {
+#else
+ if (options.fSubset || JCS_CMYK == colorSpace || JCS_RGB == colorSpace) {
+#endif
this->initializeSwizzler(dstInfo, options);
}
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | tools/BUILD.public.expected » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698