Stop creating CodecSrcs with unused scale
Only JPEG and WEBP support native scaling, so only create a CodecSrc with a scale for those types. If I run dm --src image --images resources this cuts down the number of Srcs from 11063 to 8032. All of these trimmed Srcs would have failed quickly for each Sink (3 Sinks with the above flags), but this will avoid creating them. It drops the runtime on my mac from 13.2s to 11.4s, for about a 14% speedup. BUG=skia:5307 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1999103002 Review-Url: https://codereview.chromium.org/1999103002
This commit is contained in:
parent
56f7dfebac
commit
9366aff1fa
21
dm/DM.cpp
21
dm/DM.cpp
@ -481,9 +481,8 @@ static void push_codec_srcs(Path path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Native Scales
|
// native scaling is only supported by WEBP and JPEG
|
||||||
// SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875
|
bool supportsNativeScaling = false;
|
||||||
const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
|
|
||||||
|
|
||||||
SkTArray<CodecSrc::Mode> nativeModes;
|
SkTArray<CodecSrc::Mode> nativeModes;
|
||||||
nativeModes.push_back(CodecSrc::kCodec_Mode);
|
nativeModes.push_back(CodecSrc::kCodec_Mode);
|
||||||
@ -493,9 +492,11 @@ static void push_codec_srcs(Path path) {
|
|||||||
nativeModes.push_back(CodecSrc::kScanline_Mode);
|
nativeModes.push_back(CodecSrc::kScanline_Mode);
|
||||||
nativeModes.push_back(CodecSrc::kStripe_Mode);
|
nativeModes.push_back(CodecSrc::kStripe_Mode);
|
||||||
nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
|
nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
|
||||||
|
supportsNativeScaling = true;
|
||||||
break;
|
break;
|
||||||
case SkEncodedFormat::kWEBP_SkEncodedFormat:
|
case SkEncodedFormat::kWEBP_SkEncodedFormat:
|
||||||
nativeModes.push_back(CodecSrc::kSubset_Mode);
|
nativeModes.push_back(CodecSrc::kSubset_Mode);
|
||||||
|
supportsNativeScaling = true;
|
||||||
break;
|
break;
|
||||||
case SkEncodedFormat::kDNG_SkEncodedFormat:
|
case SkEncodedFormat::kDNG_SkEncodedFormat:
|
||||||
break;
|
break;
|
||||||
@ -529,7 +530,6 @@ static void push_codec_srcs(Path path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CodecSrc::Mode mode : nativeModes) {
|
for (CodecSrc::Mode mode : nativeModes) {
|
||||||
for (float scale : nativeScales) {
|
|
||||||
for (CodecSrc::DstColorType colorType : colorTypes) {
|
for (CodecSrc::DstColorType colorType : colorTypes) {
|
||||||
for (SkAlphaType alphaType : alphaModes) {
|
for (SkAlphaType alphaType : alphaModes) {
|
||||||
// Only test kCroppedScanline_Mode when the alpha type is opaque. The test is
|
// Only test kCroppedScanline_Mode when the alpha type is opaque. The test is
|
||||||
@ -539,18 +539,21 @@ static void push_codec_srcs(Path path) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
push_codec_src(path, mode, colorType, alphaType, 1.0f);
|
||||||
|
|
||||||
// Skip kNonNative on different native scales. It won't be interestingly
|
// Skip kNonNative on different native scales. It won't be interestingly
|
||||||
// different.
|
// different.
|
||||||
if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && 1.0f != scale)
|
if (supportsNativeScaling &&
|
||||||
{
|
CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
|
||||||
continue;
|
// Native Scales
|
||||||
}
|
// SkJpegCodec natively supports scaling to the following:
|
||||||
|
for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
|
||||||
push_codec_src(path, mode, colorType, alphaType, scale);
|
push_codec_src(path, mode, colorType, alphaType, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (FLAGS_simpleCodec) {
|
if (FLAGS_simpleCodec) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user