Switching Skia to chromium's libjpeg-turbo

Compile SkJpegCodec and SkImageDecoder_libjpeg with
chromium's libjpeg-turbo.  SkImageDecoder_libjpeg still uses
libjpeg on Android and the Android framework.  SkJpegCodec is
still not compiled on the Android framework.

BUG=skia:

Review URL: https://codereview.chromium.org/1275773004
This commit is contained in:
msarett 2015-08-11 13:32:54 -07:00 коммит произвёл Commit bot
Родитель 7cdfa8a3f4
Коммит fcaaadee71
7 изменённых файлов: 106 добавлений и 192 удалений

3
DEPS
Просмотреть файл

@ -13,7 +13,6 @@ deps = {
"third_party/externals/gyp" : "https://chromium.googlesource.com/external/gyp.git@08429da7955a98ef764fafa223dd7de73f654b2d",
"third_party/externals/harfbuzz": "https://skia.googlesource.com/third_party/harfbuzz.git@0.9.35",
"third_party/externals/jsoncpp" : "https://chromium.googlesource.com/external/jsoncpp/jsoncpp.git@1afff032c83e26ddf7f2776e8b43de5ad666c1fa",
"third_party/externals/libjpeg" : "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@034e9a9747e0983bc19808ea70e469bc8342081f",
"third_party/externals/libwebp" : "https://chromium.googlesource.com/webm/libwebp.git@v0.4.3",
"third_party/externals/nanomsg" : "https://skia.googlesource.com/third_party/nanomsg.git@0.4-beta",
"third_party/externals/zlib" : "https://chromium.googlesource.com/chromium/src/third_party/zlib@4ba7cdd0e7bf49d671645264f839838fc56e1492",
@ -21,7 +20,7 @@ deps = {
"third_party/externals/libpng" : "https://skia.googlesource.com/third_party/libpng.git@070a616b8275277e18ef8ee91e2ca23f7bdc67d5",
"third_party/externals/giflib" : "https://android.googlesource.com/platform/external/giflib.git@android-5.1.0_r3",
"third_party/externals/libjpeg-turbo" : "https://skia.googlesource.com/third_party/libjpeg-turbo.git@trunk+fixvalgrind",
"third_party/externals/libjpeg-turbo" : "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@631e2dd119d49794e3572b6ca3f16ee39d59f372",
# libjpeg-turbo depends on yasm to compile .asm files
"third_party/externals/yasm/source/patched-yasm/" : "https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm.git@4671120cd8558ce62ee8672ebf3eb6f5216f909b",
"third_party/externals/yasm/binaries" : "https://chromium.googlesource.com/chromium/deps/yasm/binaries.git@52f9b3f4b0aa06da24ef8b123058bb61ee468881",

Просмотреть файл

@ -53,10 +53,8 @@
],
},
'sources': [
'../third_party/externals/libjpeg-turbo/jaricom.c',
'../third_party/externals/libjpeg-turbo/jcapimin.c',
'../third_party/externals/libjpeg-turbo/jcapistd.c',
'../third_party/externals/libjpeg-turbo/jcarith.c',
'../third_party/externals/libjpeg-turbo/jccoefct.c',
'../third_party/externals/libjpeg-turbo/jccolor.c',
'../third_party/externals/libjpeg-turbo/jcdctmgr.c',
@ -68,14 +66,12 @@
'../third_party/externals/libjpeg-turbo/jcmaster.c',
'../third_party/externals/libjpeg-turbo/jcomapi.c',
'../third_party/externals/libjpeg-turbo/jconfig.h',
'../third_party/externals/libjpeg-turbo/jconfigint.h',
'../third_party/externals/libjpeg-turbo/jcparam.c',
'../third_party/externals/libjpeg-turbo/jcphuff.c',
'../third_party/externals/libjpeg-turbo/jcprepct.c',
'../third_party/externals/libjpeg-turbo/jcsample.c',
'../third_party/externals/libjpeg-turbo/jdapimin.c',
'../third_party/externals/libjpeg-turbo/jdapistd.c',
'../third_party/externals/libjpeg-turbo/jdarith.c',
'../third_party/externals/libjpeg-turbo/jdcoefct.c',
'../third_party/externals/libjpeg-turbo/jdcolor.c',
'../third_party/externals/libjpeg-turbo/jdct.h',
@ -134,59 +130,59 @@
[ 'skia_arch_type == "x86" and (skia_os != "android" or host_os == "linux")', {
'sources': [
'../third_party/externals/libjpeg-turbo/simd/jsimd_i386.c',
'../third_party/externals/libjpeg-turbo/simd/jccolor-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jccolor-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgray-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgray-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsample-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsample-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolor-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolor-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmerge-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmerge-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsample-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsample-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctflt-3dn.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctflt-sse.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctfst-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctfst-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctint-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctint-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctflt-3dn.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctflt-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctflt-sse.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctfst-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctfst-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctint-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctint-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctred-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctred-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jquant-3dn.asm',
'../third_party/externals/libjpeg-turbo/simd/jquantf-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jquanti-sse2.asm',
'../third_party/externals/libjpeg-turbo/simd/jquant-mmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jquant-sse.asm',
'../third_party/externals/libjpeg-turbo/simd/jccolmmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jccolss2.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgrammx.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgrass2.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqnt3dn.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqntmmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqnts2f.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqnts2i.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqntsse.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsammmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsamss2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolmmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolss2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmermmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmerss2.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsammmx.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsamss2.asm',
'../third_party/externals/libjpeg-turbo/simd/jf3dnflt.asm',
'../third_party/externals/libjpeg-turbo/simd/jfmmxfst.asm',
'../third_party/externals/libjpeg-turbo/simd/jfmmxint.asm',
'../third_party/externals/libjpeg-turbo/simd/jfss2fst.asm',
'../third_party/externals/libjpeg-turbo/simd/jfss2int.asm',
'../third_party/externals/libjpeg-turbo/simd/jfsseflt.asm',
'../third_party/externals/libjpeg-turbo/simd/ji3dnflt.asm',
'../third_party/externals/libjpeg-turbo/simd/jimmxfst.asm',
'../third_party/externals/libjpeg-turbo/simd/jimmxint.asm',
'../third_party/externals/libjpeg-turbo/simd/jimmxred.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2flt.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2fst.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2int.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2red.asm',
'../third_party/externals/libjpeg-turbo/simd/jisseflt.asm',
'../third_party/externals/libjpeg-turbo/simd/jsimdcpu.asm',
],
}],
[ 'skia_arch_type == "x86_64" and (skia_os != "android" or host_os == "linux")', {
'sources': [
'../third_party/externals/libjpeg-turbo/simd/jsimd_x86_64.c',
'../third_party/externals/libjpeg-turbo/simd/jccolor-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgray-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsample-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolor-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmerge-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsample-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctflt-sse-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctfst-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfdctint-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctflt-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctfst-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctint-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jidctred-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jquantf-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jquanti-sse2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jccolss2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcgrass2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqnts2f-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcqnts2i-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jcsamss2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdcolss2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdmerss2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jdsamss2-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfss2fst-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfss2int-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jfsseflt-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2flt-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2fst-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2int-64.asm',
'../third_party/externals/libjpeg-turbo/simd/jiss2red-64.asm',
],
}],
[ 'skia_arch_type == "arm64"', {
@ -209,14 +205,9 @@
}],
],
}],
[ 'skia_arch_type == "mips64"', {
'sources': [
'../third_party/externals/libjpeg-turbo/simd/jsimd_mips.c',
'../third_party/externals/libjpeg-turbo/simd/jsimd_mips_dspr2_asm.h',
'../third_party/externals/libjpeg-turbo/simd/jsimd_mips_dspr2.S',
],
}],
[ 'skia_arch_type == "mips32"', {
# mips simd is supported in later versions of libjpeg-turbo. If we
# choose to update our copy of libjpeg-turbo we can enable mips simd.
[ '"mips" in skia_arch_type', {
'sources': [
'../third_party/externals/libjpeg-turbo/jsimd_none.c',
],
@ -239,7 +230,7 @@
'-D__x86__',
'-DWIN32',
'-DMSVC',
'-Iwin/'
'-I../third_party/externals/libjpeg-turbo/win/'
],
}, {
'yasm_format': '-fwin64',
@ -247,7 +238,7 @@
'-D__x86_64__',
'-DWIN64',
'-DMSVC',
'-Iwin/'
'-I../third_party/externals/libjpeg-turbo/win/'
],
}],
],
@ -266,14 +257,14 @@
'yasm_flags': [
'-D__x86__',
'-DELF',
'-Ilinux/'
'-I../third_party/externals/libjpeg-turbo/linux/'
],
}, {
'yasm_format': '-felf64',
'yasm_flags': [
'-D__x86_64__',
'-DELF',
'-Ilinux/'
'-I../third_party/externals/libjpeg-turbo/linux/'
],
}],
],
@ -292,14 +283,14 @@
'yasm_flags': [
'-D__x86__',
'-DMACHO',
'-Imac/'
'-I../third_party/externals/libjpeg-turbo/mac/'
],
}, {
'yasm_format': '-fmacho64',
'yasm_flags': [
'-D__x86_64__',
'-DMACHO',
'-Imac/'
'-I../third_party/externals/libjpeg-turbo/mac/'
],
}],
],
@ -318,14 +309,14 @@
'yasm_flags': [
'-D__x86__',
'-DELF',
'-Ilinux/'
'-I../third_party/externals/libjpeg-turbo/linux/'
],
}, {
'yasm_format': '-felf64',
'yasm_flags': [
'-D__x86_64__',
'-DELF',
'-Ilinux/'
'-I../third_party/externals/libjpeg-turbo/linux/'
],
}],
],
@ -349,7 +340,6 @@
'<@(yasm_flags)',
'-DRGBX_FILLER_0XFF',
'-DSTRICT_MEMORY_ACCESS',
'-Isimd/',
'-o', '<(shared_generated_dir)/<(RULE_INPUT_ROOT).<(object_suffix)',
'<(RULE_INPUT_PATH)',
],

Просмотреть файл

@ -28,102 +28,17 @@
},
],
}, { # skia_os != android
'conditions': [
['use_system_libjpeg==0', {
'targets': [
{
'target_name': 'libjpeg',
'type': 'static_library',
'sources': [
# we currently build skia's version of libjpeg-turbo without
# SIMD optimizations for simplicity
'../third_party/externals/libjpeg/jsimd_none.c',
'../third_party/externals/libjpeg/jcapimin.c',
'../third_party/externals/libjpeg/jcapistd.c',
'../third_party/externals/libjpeg/jccoefct.c',
'../third_party/externals/libjpeg/jccolor.c',
'../third_party/externals/libjpeg/jcdctmgr.c',
'../third_party/externals/libjpeg/jchuff.c',
'../third_party/externals/libjpeg/jchuff.h',
'../third_party/externals/libjpeg/jcinit.c',
'../third_party/externals/libjpeg/jcmainct.c',
'../third_party/externals/libjpeg/jcmarker.c',
'../third_party/externals/libjpeg/jcmaster.c',
'../third_party/externals/libjpeg/jcomapi.c',
'../third_party/externals/libjpeg/jconfig.h',
'../third_party/externals/libjpeg/jcparam.c',
'../third_party/externals/libjpeg/jcphuff.c',
'../third_party/externals/libjpeg/jcprepct.c',
'../third_party/externals/libjpeg/jcsample.c',
'../third_party/externals/libjpeg/jdapimin.c',
'../third_party/externals/libjpeg/jdapistd.c',
'../third_party/externals/libjpeg/jdatadst.c',
'../third_party/externals/libjpeg/jdatasrc.c',
'../third_party/externals/libjpeg/jdcoefct.c',
'../third_party/externals/libjpeg/jdcolor.c',
'../third_party/externals/libjpeg/jdct.h',
'../third_party/externals/libjpeg/jddctmgr.c',
'../third_party/externals/libjpeg/jdhuff.c',
'../third_party/externals/libjpeg/jdhuff.h',
'../third_party/externals/libjpeg/jdinput.c',
'../third_party/externals/libjpeg/jdmainct.c',
'../third_party/externals/libjpeg/jdmarker.c',
'../third_party/externals/libjpeg/jdmaster.c',
'../third_party/externals/libjpeg/jdmerge.c',
'../third_party/externals/libjpeg/jdphuff.c',
'../third_party/externals/libjpeg/jdpostct.c',
'../third_party/externals/libjpeg/jdsample.c',
'../third_party/externals/libjpeg/jerror.c',
'../third_party/externals/libjpeg/jerror.h',
'../third_party/externals/libjpeg/jfdctflt.c',
'../third_party/externals/libjpeg/jfdctfst.c',
'../third_party/externals/libjpeg/jfdctint.c',
'../third_party/externals/libjpeg/jidctflt.c',
'../third_party/externals/libjpeg/jidctfst.c',
'../third_party/externals/libjpeg/jidctint.c',
'../third_party/externals/libjpeg/jidctred.c',
'../third_party/externals/libjpeg/jinclude.h',
'../third_party/externals/libjpeg/jmemmgr.c',
'../third_party/externals/libjpeg/jmemnobs.c',
'../third_party/externals/libjpeg/jmemsys.h',
'../third_party/externals/libjpeg/jmorecfg.h',
'../third_party/externals/libjpeg/jpegint.h',
'../third_party/externals/libjpeg/jpeglib.h',
'../third_party/externals/libjpeg/jpeglibmangler.h',
'../third_party/externals/libjpeg/jquant1.c',
'../third_party/externals/libjpeg/jquant2.c',
'../third_party/externals/libjpeg/jutils.c',
'../third_party/externals/libjpeg/jversion.h',
],
'direct_dependent_settings': {
'include_dirs': [
'../third_party/externals/libjpeg',
],
},
'cflags': [
'-w', # supresses warnings
],
},
'targets': [
{
'target_name': 'libjpeg',
'type': 'none',
'dependencies': [
'libjpeg-turbo.gyp:*',
],
}, { ## use_system_libjpeg != 0
'targets': [
{
'target_name': 'libjpeg',
'type': 'none',
'direct_dependent_settings': {
'defines': [
'USE_SYSTEM_LIBJPEG',
],
},
'link_settings': {
'libraries': [
'-ljpeg',
],
},
}
'export_dependent_settings': [
'libjpeg-turbo.gyp:*',
],
}],
},
],
}],
],

Просмотреть файл

@ -183,18 +183,22 @@
'../third_party/externals/jpeg/jutils.c',
],
'conditions': [
[ 'arm_neon == 1 and skia_clang_build == 0',
{
'sources' : [
'../third_party/externals/jpeg/armv6_idct.S',
'../third_party/externals/jpeg/jsimd_arm_neon.S',
'../third_party/externals/jpeg/jsimd_neon.c',
],
'defines' : [
'NV_ARM_NEON',
],
},
],
# FIXME (msarett):
# Turn off Arm NEON optimizations to avoid namespace conflicts when
# compiling libjpeg and libjpeg-turbo. This is a temporary step in the
# plan to replace libjpeg with libjpeg-turbo.
#[ 'arm_neon == 1 and skia_clang_build == 0',
# {
# 'sources' : [
# '../third_party/externals/jpeg/armv6_idct.S',
# '../third_party/externals/jpeg/jsimd_arm_neon.S',
# '../third_party/externals/jpeg/jsimd_neon.c',
# ],
# 'defines' : [
# 'NV_ARM_NEON',
# ],
# },
#],
[ '"mips" in skia_arch_type and mips_dsp == 2',
{
'sources' : [

Просмотреть файл

@ -111,7 +111,7 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
decoderMgr->init();
// Read the jpeg header
if (JPEG_HEADER_OK != turbo_jpeg_read_header(decoderMgr->dinfo(), true)) {
if (JPEG_HEADER_OK != chromium_jpeg_read_header(decoderMgr->dinfo(), true)) {
return decoderMgr->returnFalse("read_header");
}
@ -183,7 +183,7 @@ SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
dinfo.num_components = 0;
dinfo.scale_num = num;
dinfo.scale_denom = denom;
turbo_jpeg_calc_output_dimensions(&dinfo);
chromium_jpeg_calc_output_dimensions(&dinfo);
// Return the calculated output dimensions for the given scale
return SkISize::Make(dinfo.output_width, dinfo.output_height);
@ -279,7 +279,7 @@ bool SkJpegCodec::scaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) {
// libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1
fDecoderMgr->dinfo()->scale_denom = 8;
fDecoderMgr->dinfo()->scale_num = 8;
turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
chromium_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
while (fDecoderMgr->dinfo()->output_width != dstWidth ||
fDecoderMgr->dinfo()->output_height != dstHeight) {
@ -292,7 +292,7 @@ bool SkJpegCodec::scaleToDimensions(uint32_t dstWidth, uint32_t dstHeight) {
// Try the next scale
fDecoderMgr->dinfo()->scale_num -= 1;
turbo_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
chromium_jpeg_calc_output_dimensions(fDecoderMgr->dinfo());
}
return true;
}
@ -332,7 +332,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
}
// Now, given valid output dimensions, we can start the decompress
if (!turbo_jpeg_start_decompress(dinfo)) {
if (!chromium_jpeg_start_decompress(dinfo)) {
return fDecoderMgr->returnFailure("startDecompress", kInvalidInput);
}
@ -345,7 +345,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
JSAMPLE* dstRow = (JSAMPLE*) dst;
for (uint32_t y = 0; y < dstHeight; y++) {
// Read rows of the image
uint32_t rowsDecoded = turbo_jpeg_read_scanlines(dinfo, &dstRow, 1);
uint32_t rowsDecoded = chromium_jpeg_read_scanlines(dinfo, &dstRow, 1);
// If we cannot read enough rows, assume the input is incomplete
if (rowsDecoded != 1) {
@ -367,7 +367,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
dinfo->output_scanline = dstHeight;
// Finish the decode and indicate that the input was incomplete.
turbo_jpeg_finish_decompress(dinfo);
chromium_jpeg_finish_decompress(dinfo);
return fDecoderMgr->returnFailure("Incomplete image data", kIncompleteInput);
}
@ -379,7 +379,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
// Move to the next row
dstRow = SkTAddOffset<JSAMPLE>(dstRow, dstRowBytes);
}
turbo_jpeg_finish_decompress(dinfo);
chromium_jpeg_finish_decompress(dinfo);
return kSuccess;
}
@ -420,7 +420,7 @@ public:
}
// Now, given valid output dimensions, we can start the decompress
if (!turbo_jpeg_start_decompress(fCodec->fDecoderMgr->dinfo())) {
if (!chromium_jpeg_start_decompress(fCodec->fDecoderMgr->dinfo())) {
SkCodecPrintf("start decompress failed\n");
return SkCodec::kInvalidInput;
}
@ -439,7 +439,7 @@ public:
// We may not have decoded the entire image. Prevent libjpeg-turbo from failing on a
// partial decode.
fCodec->fDecoderMgr->dinfo()->output_scanline = fCodec->getInfo().height();
turbo_jpeg_finish_decompress(fCodec->fDecoderMgr->dinfo());
chromium_jpeg_finish_decompress(fCodec->fDecoderMgr->dinfo());
}
SkCodec::Result onGetScanlines(void* dst, int count, size_t rowBytes) override {
@ -453,7 +453,7 @@ public:
for (int y = 0; y < count; y++) {
// Read row of the image
uint32_t rowsDecoded =
turbo_jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1);
chromium_jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1);
if (rowsDecoded != 1) {
if (SkCodec::kNo_ZeroInitialized == fOpts.fZeroInitialized ||
kN32_SkColorType == this->dstInfo().colorType()) {
@ -477,11 +477,13 @@ public:
}
#ifndef TURBO_HAS_SKIP
#define turbo_jpeg_skip_scanlines(dinfo, count) \
// TODO (msarett): Make this a member function and avoid reallocating the
// memory buffer on each call to skip.
#define chromium_jpeg_skip_scanlines(dinfo, count) \
SkAutoMalloc storage(dinfo->output_width * dinfo->out_color_components); \
uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); \
for (int y = 0; y < count; y++) { \
turbo_jpeg_read_scanlines(dinfo, &storagePtr, 1); \
chromium_jpeg_read_scanlines(dinfo, &storagePtr, 1); \
}
#endif
@ -491,11 +493,15 @@ public:
return fCodec->fDecoderMgr->returnFailure("setjmp", SkCodec::kInvalidInput);
}
turbo_jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count);
chromium_jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count);
return SkCodec::kSuccess;
}
#ifndef TURBO_HAS_SKIP
#undef chromium_jpeg_skip_scanlines
#endif
private:
SkAutoTDelete<SkJpegCodec> fCodec;
SkCodec::Options fOpts;

Просмотреть файл

@ -51,7 +51,7 @@ JpegDecoderMgr::JpegDecoderMgr(SkStream* stream)
, fInit(false)
{
// Error manager must be set before any calls to libjeg in order to handle failures
fDInfo.err = turbo_jpeg_std_error(&fErrorMgr);
fDInfo.err = chromium_jpeg_std_error(&fErrorMgr);
fErrorMgr.error_exit = skjpeg_err_exit;
}

Просмотреть файл

@ -73,7 +73,7 @@ skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream)
init_source = sk_init_source;
fill_input_buffer = sk_fill_input_buffer;
skip_input_data = sk_skip_input_data;
resync_to_restart = turbo_jpeg_resync_to_restart;
resync_to_restart = chromium_jpeg_resync_to_restart;
term_source = sk_term_source;
}