gpu: Add flag to enable JPEG YUV decoding.
Similar to the work done for WebP YUV decoding, we would like to
implement direct decoding of JPEG 4:2:0 images to YUV rather than RGB
for non progressive JPEGs.
BUG: 919627
Change-Id: Ie6522e51204a0013b1db7b0635bed5cdb847baa7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768817
Commit-Queue: Sasha McIntosh <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Reviewed-by: Daniele Castagna <[email protected]>
Cr-Commit-Position: refs/heads/master@{#692845}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 23100fe..1a7aad72 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -4421,6 +4421,11 @@
FEATURE_VALUE_TYPE(
autofill::features::kAutofillUpdatedCardUnmaskPromptUi)},
+ {"decode-jpeg-images-to-yuv",
+ flag_descriptions::kDecodeJpeg420ImagesToYUVName,
+ flag_descriptions::kDecodeJpeg420ImagesToYUVDescription, kOsAll,
+ FEATURE_VALUE_TYPE(blink::features::kDecodeJpeg420ImagesToYUV)},
+
{"decode-webp-images-to-yuv",
flag_descriptions::kDecodeLossyWebPImagesToYUVName,
flag_descriptions::kDecodeLossyWebPImagesToYUVDescription, kOsAll,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index eefedee5..a9fe92c5 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -569,6 +569,11 @@
"expiry_milestone": 88
},
{
+ "name": "decode-jpeg-images-to-yuv",
+ "owners": [ "sashamcintosh", "[email protected]" ],
+ "expiry_milestone": 88
+ },
+ {
"name": "decode-webp-images-to-yuv",
"owners": [ "andrescj", "[email protected]" ],
"expiry_milestone": 80
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index b381081c..ffd8dcb 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -279,6 +279,11 @@
"print server, instead of the cloud print interface in the Print "
"Preview WebUI.";
+const char kDecodeJpeg420ImagesToYUVName[] = "YUV decoding for JPEG";
+const char kDecodeJpeg420ImagesToYUVDescription[] =
+ "Decode and render 4:2:0 formatted jpeg images from YUV instead of RGB."
+ "This feature requires GPU or OOP rasterization to also be enabled.";
+
const char kDecodeLossyWebPImagesToYUVName[] = "YUV Decoding for WebP";
const char kDecodeLossyWebPImagesToYUVDescription[] =
"Decode and render lossy WebP images from YUV instead of RGB. "
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index b9b3f38..1daa47b2 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -181,6 +181,9 @@
extern const char kCloudPrinterHandlerName[];
extern const char kCloudPrinterHandlerDescription[];
+extern const char kDecodeJpeg420ImagesToYUVName[];
+extern const char kDecodeJpeg420ImagesToYUVDescription[];
+
extern const char kDecodeLossyWebPImagesToYUVName[];
extern const char kDecodeLossyWebPImagesToYUVDescription[];
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
index 108f5ba..f18baef 100644
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -101,6 +101,12 @@
if (!command_line.HasSwitch(switches::kDisableYUVImageDecoding) &&
base::FeatureList::IsEnabled(
+ blink::features::kDecodeJpeg420ImagesToYUV)) {
+ WebRuntimeFeatures::EnableDecodeJpeg420ImagesToYUV(true);
+ }
+
+ if (!command_line.HasSwitch(switches::kDisableYUVImageDecoding) &&
+ base::FeatureList::IsEnabled(
blink::features::kDecodeLossyWebPImagesToYUV)) {
WebRuntimeFeatures::EnableDecodeLossyWebPImagesToYUV(true);
}
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index e42beb7..b1590bd 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -249,6 +249,12 @@
const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
"optionally-blockable";
+// Decodes jpeg 4:2:0 formatted images to YUV instead of RGBX and stores in this
+// format in the image decode cache. See crbug.com/919627 for details on the
+// feature.
+const base::Feature kDecodeJpeg420ImagesToYUV{
+ "DecodeJpeg420ImagesToYUV", base::FEATURE_DISABLED_BY_DEFAULT};
+
// Decodes lossy WebP images to YUV instead of RGBX and stores in this format
// in the image decode cache. See crbug.com/900264 for details on the feature.
const base::Feature kDecodeLossyWebPImagesToYUV{
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h
index cb3dff26..12efaab 100644
--- a/third_party/blink/public/common/features.h
+++ b/third_party/blink/public/common/features.h
@@ -70,6 +70,7 @@
BLINK_COMMON_EXPORT extern const char
kMixedContentAutoupgradeModeOptionallyBlockable[];
+BLINK_COMMON_EXPORT extern const base::Feature kDecodeJpeg420ImagesToYUV;
BLINK_COMMON_EXPORT extern const base::Feature kDecodeLossyWebPImagesToYUV;
BLINK_COMMON_EXPORT extern const base::Feature
diff --git a/third_party/blink/public/platform/web_runtime_features.h b/third_party/blink/public/platform/web_runtime_features.h
index 2b5d114..785fda8 100644
--- a/third_party/blink/public/platform/web_runtime_features.h
+++ b/third_party/blink/public/platform/web_runtime_features.h
@@ -93,6 +93,7 @@
BLINK_PLATFORM_EXPORT static void EnableScrollTopLeftInterop(bool);
BLINK_PLATFORM_EXPORT static void EnableKeyboardFocusableScrollers(bool);
BLINK_PLATFORM_EXPORT static void EnableDatabase(bool);
+ BLINK_PLATFORM_EXPORT static void EnableDecodeJpeg420ImagesToYUV(bool);
BLINK_PLATFORM_EXPORT static void EnableDecodeLossyWebPImagesToYUV(bool);
BLINK_PLATFORM_EXPORT static void EnableDisplayCutoutAPI(bool);
BLINK_PLATFORM_EXPORT static void EnableDocumentPolicy(bool);
diff --git a/third_party/blink/renderer/platform/exported/web_runtime_features.cc b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
index 98b9377..f52bb1d 100644
--- a/third_party/blink/renderer/platform/exported/web_runtime_features.cc
+++ b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
@@ -168,6 +168,10 @@
RuntimeEnabledFeatures::SetDatabaseEnabled(enable);
}
+void WebRuntimeFeatures::EnableDecodeJpeg420ImagesToYUV(bool enable) {
+ RuntimeEnabledFeatures::SetDecodeJpeg420ImagesToYUVEnabled(enable);
+}
+
void WebRuntimeFeatures::EnableDecodeLossyWebPImagesToYUV(bool enable) {
RuntimeEnabledFeatures::SetDecodeLossyWebPImagesToYUVEnabled(enable);
}
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
index e897cfd..f870d04a 100644
--- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
+++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -494,6 +494,10 @@
status: "stable",
},
{
+ name: "DecodeJpeg420ImagesToYUV",
+ status: "test"
+ },
+ {
name: "DecodeLossyWebPImagesToYUV",
status: "test",
},
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index e7e4832..cf85bde 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -34523,6 +34523,7 @@
<int value="-1985452239" label="SmartDim20190221:disabled"/>
<int value="-1985239289" label="AutofillRichMetadataQueries:enabled"/>
<int value="-1985025593" label="file-manager-enable-new-gallery"/>
+ <int value="-1983891525" label="DecodeJpeg420ImagesToYUV:disabled"/>
<int value="-1983569861" label="WebXROrientationSensorDevice:disabled"/>
<int value="-1982700103" label="EnableAppsGridGapFeature:enabled"/>
<int value="-1980328793" label="trace-upload-url"/>
@@ -36605,6 +36606,7 @@
<int value="821192723" label="show-fps-counter"/>
<int value="824961931" label="use-simple-cache-backend"/>
<int value="828092263" label="TemporaryUnexpireFlagsM78:enabled"/>
+ <int value="830282555" label="DecodeJpeg420ImagesToYUV:enabled"/>
<int value="832142463" label="WebAssemblyStreaming:enabled"/>
<int value="834033186" label="enable-data-reduction-proxy-dev"/>
<int value="834326277" label="enable-answers-in-suggest"/>