Commit b9b9a8a5 authored by Stephen Chenney's avatar Stephen Chenney Committed by Chromium LUCI CQ

[DarkMode] Do not invert shader-based images

Code in DarkModeFilter was applying a dark mode color filter
to any painted content that had some other shader associated
with it. Such shaders come from gradients, mostly, but also
tiled images and some background images.

This patch limits the application of the dark mode color filter
shaders that are not images or paint records. The former because
we should not be applying a naive color filter to images, and
the latter because they should already have filters dark mode
filters applied.

Fixes: 1160239
Change-Id: Id7dfbf999d43d7a9f5953d1f5a5edc5a1c92fe07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622989
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842366}
parent dfd8c905
......@@ -158,7 +158,12 @@ base::Optional<cc::PaintFlags> DarkModeFilter::ApplyToFlagsIfNeeded(
cc::PaintFlags dark_mode_flags = flags;
if (flags.HasShader()) {
dark_mode_flags.setColorFilter(immutable_.color_filter->ToSkColorFilter());
PaintShader::Type shader_type = flags.getShader()->shader_type();
if (shader_type != PaintShader::Type::kImage &&
shader_type != PaintShader::Type::kPaintRecord) {
dark_mode_flags.setColorFilter(
immutable_.color_filter->ToSkColorFilter());
}
} else if (ShouldApplyToColor(flags.getColor(), role)) {
dark_mode_flags.setColor(inverted_color_cache_->GetInvertedColor(
immutable_.color_filter.get(), flags.getColor()));
......
<!DOCTYPE html>
<html>
<head>
<style>
html {
background: #000 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2NgYGD4DwABBAEAcCBlCwAAAABJRU5ErkJggg==) repeat 0 0;
}
div {
background-color: white;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment