Commit 1fc127c5 authored by Brian Osman's avatar Brian Osman Committed by Commit Bot

Apply SDR white level scaling to YUV quads in Skia renderer

This is the same strategy used by gl_renderer. It's potentially expensive,
because the transform matrix values are baked into the shader source, so
dragging the slider could cause many shaders to be generated.

A better solution might be to inject a scale step in the ColorTransform
that refers to a uniform. Doing so would require changing the signature
of NewColorTransform (or adding NewScaledColorTransform), and creates a
leaky abstraction that may not be worth it, given the rarity of this case.

Bug: chromium:985500
Change-Id: Ifae5e595fa76c84b0535ae6ca222bf7bf088883f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1919419Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Cr-Commit-Position: refs/heads/master@{#715812}
parent 65401431
...@@ -2096,12 +2096,20 @@ sk_sp<SkColorFilter> SkiaRenderer::GetColorFilter(const gfx::ColorSpace& src, ...@@ -2096,12 +2096,20 @@ sk_sp<SkColorFilter> SkiaRenderer::GetColorFilter(const gfx::ColorSpace& src,
const gfx::ColorSpace& dst, const gfx::ColorSpace& dst,
float resource_offset, float resource_offset,
float resource_multiplier) { float resource_multiplier) {
gfx::ColorSpace adjusted_src = src;
float sdr_white_level = current_frame()->sdr_white_level;
if (src.IsValid() && !src.IsHDR() &&
sdr_white_level != gfx::ColorSpace::kDefaultSDRWhiteLevel) {
adjusted_src = src.GetScaledColorSpace(
sdr_white_level / gfx::ColorSpace::kDefaultSDRWhiteLevel);
}
std::unique_ptr<SkRuntimeColorFilterFactory>& factory = std::unique_ptr<SkRuntimeColorFilterFactory>& factory =
color_filter_cache_[dst][src]; color_filter_cache_[dst][adjusted_src];
if (!factory) { if (!factory) {
std::unique_ptr<gfx::ColorTransform> transform = std::unique_ptr<gfx::ColorTransform> transform =
gfx::ColorTransform::NewColorTransform( gfx::ColorTransform::NewColorTransform(
src, dst, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL); adjusted_src, dst, gfx::ColorTransform::Intent::INTENT_PERCEPTUAL);
// TODO(backer): Support lookup table transforms (e.g. // TODO(backer): Support lookup table transforms (e.g.
// COLOR_CONVERSION_MODE_LUT). // COLOR_CONVERSION_MODE_LUT).
if (!transform->CanGetShaderSource()) if (!transform->CanGetShaderSource())
......
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