chromium/ui/gfx/color_transform.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/354829279): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/gfx/color_transform.h"

#include <algorithm>
#include <cmath>
#include <list>
#include <memory>
#include <sstream>
#include <utility>

#include "base/logging.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/modules/skcms/skcms.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/skia_color_space_util.h"

abs;
copysign;
endl;
exp;
log;
max;
min;
pow;
sqrt;

namespace gfx {

namespace {

// The maximum brightness of the reference display for HLG computations.
static constexpr float kHLGRefMaxLumNits =;

// The maximum reference brightness of a PQ signal.
static constexpr float kPQRefMaxLumNits =;

// The luminance vector in rec2020 linear space.
static constexpr float kLr =;
static constexpr float kLg =;
static constexpr float kLb =;

// Return true if HLG and PQ tonemapping is unified (HLG is transcoded to a
// 1,000 nit PQ signal and then rendered like PQ).
bool IsHlgPqUnifiedTonemapEnabled() {}

// Return true if input HLG and PQ signals are SDR relative. This applies
// only to Windows, where they can be absolute (they are otherwise always
// SDR relative).
bool IsHlgPqSdrRelative() {}

struct SkShaderUniforms {};

void InitStringStream(std::stringstream* ss) {}

std::string Str(float f) {}

SkM44 Invert(const SkM44& t) {}

float FromLinear(ColorSpace::TransferID id, float v) {}

float ToLinear(ColorSpace::TransferID id, float v) {}

}  // namespace

BASE_FEATURE();

BASE_FEATURE();

class ColorTransformMatrix;
class ColorTransformSkTransferFn;
class ColorTransformFromLinear;
class ColorTransformNull;

class ColorTransformStep {};

class ColorTransformInternal : public ColorTransform {};

class ColorTransformNull : public ColorTransformStep {};

class ColorTransformMatrix : public ColorTransformStep {};

class ColorTransformPerChannelTransferFn : public ColorTransformStep {};

// This class represents the piecewise-HDR function using three new parameters,
// P, Q, and R. The function is defined as:
//            0         : x < 0
//     T(x) = sRGB(x/P) : x < P
//            Q*x+R     : x >= P
// This then expands to
//            0                : x < 0
//     T(x) = C*x/P+F          : x < P*D
//            (A*x/P+B)**G + E : x < P
//            Q*x+R            : else
class ColorTransformPiecewiseHDR : public ColorTransformPerChannelTransferFn {};

class ColorTransformSkTransferFn : public ColorTransformPerChannelTransferFn {};

// Applies the HLG OETF formulation that maps [0, 12] to [0, 1].
class ColorTransformHLG_OETF : public ColorTransformPerChannelTransferFn {};

class ColorTransformPQFromLinear : public ColorTransformPerChannelTransferFn {};

// Applies the HLG inverse OETF formulation that maps [0, 1] to [0, 1].
class ColorTransformHLG_InvOETF : public ColorTransformPerChannelTransferFn {};

class ColorTransformPQToLinear : public ColorTransformPerChannelTransferFn {};

class ColorTransformFromLinear : public ColorTransformPerChannelTransferFn {};

class ColorTransformToLinear : public ColorTransformPerChannelTransferFn {};

// Apply the HLG OOTF for a specified maximum luminance.
class ColorTransformHLG_OOTF : public ColorTransformStep {};

// Apply the HLG OOTF for a 1,000 nit reference display.
class ColorTransformHLG_RefOOTF : public ColorTransformStep {};

// Scale the color such that the luminance `input_max_value` maps to
// `output_max_value`.
class ColorTransformToneMapInRec2020Linear : public ColorTransformStep {};

// Converts from nits-relative (where 1.0 is `unity_nits` nits) to SDR-relative
// (where 1.0 is SDR white). If `use_src_sdr_white` is true then use 203 nits
// for SDR white, otherwise use `RuntimeOptions::dst_sdr_max_luminance_nits`
// for SDR white.
class ColorTransformSrcNitsToSdrRelative : public ColorTransformStep {};

// Converts from SDR-relative (where 1.0 is SDR white) to nits-relative (where
// 1.0 is `unity_nits` nits). Use `RuntimeOptions::dst_sdr_max_luminance_nits`
// for the number of nits of SDR white.
class ColorTransformSdrToDstNitsRelative : public ColorTransformStep {};

void ColorTransformInternal::AppendColorSpaceToColorSpaceTransform(
    const ColorSpace& src,
    const ColorSpace& dst,
    const Options& options) {}

ColorTransformInternal::ColorTransformInternal(const ColorSpace& src,
                                               const ColorSpace& dst,
                                               const Options& options)
    :{}

sk_sp<SkRuntimeEffect> ColorTransformInternal::GetSkRuntimeEffect() const {}

sk_sp<SkData> ColorTransformInternal::GetSkShaderUniforms(
    const RuntimeOptions& options) const {}

ColorTransformInternal::~ColorTransformInternal() {}

void ColorTransformInternal::Simplify() {}

// static
std::unique_ptr<ColorTransform> ColorTransform::NewColorTransform(
    const ColorSpace& src,
    const ColorSpace& dst) {}

// static
std::unique_ptr<ColorTransform> ColorTransform::NewColorTransform(
    const ColorSpace& src,
    const ColorSpace& dst,
    const Options& options) {}

ColorTransform::ColorTransform() {}
ColorTransform::~ColorTransform() {}

}  // namespace gfx