Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
SkGainmapInfo Struct Reference

#include <SkGainmapInfo.h>

Public Types

enum class  BaseImageType { kSDR , kHDR }
 
enum class  Type { kDefault }
 

Public Member Functions

bool operator== (const SkGainmapInfo &other) const
 
bool operator!= (const SkGainmapInfo &other) const
 

Public Attributes

SkColor4f fGainmapRatioMin = {1.f, 1.f, 1.f, 1.0}
 
SkColor4f fGainmapRatioMax = {2.f, 2.f, 2.f, 1.0}
 
SkColor4f fGainmapGamma = {1.f, 1.f, 1.f, 1.f}
 
SkColor4f fEpsilonSdr = {0.f, 0.f, 0.f, 1.0}
 
SkColor4f fEpsilonHdr = {0.f, 0.f, 0.f, 1.0}
 
float fDisplayRatioSdr = 1.f
 
float fDisplayRatioHdr = 2.f
 
BaseImageType fBaseImageType = BaseImageType::kSDR
 
sk_sp< SkColorSpacefGainmapMathColorSpace = nullptr
 
Type fType = Type::kDefault
 

Detailed Description

Gainmap rendering parameters. Suppose our display has HDR to SDR ratio of H and we wish to display an image with gainmap on this display. Let B be the pixel value from the base image in a color space that has the primaries of the base image and a linear transfer function. Let G be the pixel value from the gainmap. Let D be the output pixel in the same color space as B. The value of D is computed as follows:

First, let W be a weight parameter determing how much the gainmap will be applied. W = clamp((log(H) - log(fDisplayRatioSdr)) / (log(fDisplayRatioHdr) - log(fDisplayRatioSdr), 0, 1)

Next, let L be the gainmap value in log space. We compute this from the value G that was sampled from the texture as follows: L = mix(log(fGainmapRatioMin), log(fGainmapRatioMax), pow(G, fGainmapGamma))

Finally, apply the gainmap to compute D, the displayed pixel. If the base image is SDR then compute: D = (B + fEpsilonSdr) * exp(L * W) - fEpsilonHdr If the base image is HDR then compute: D = (B + fEpsilonHdr) * exp(L * (W - 1)) - fEpsilonSdr

In the above math, log() is a natural logarithm and exp() is natural exponentiation. Note, however, that the base used for the log() and exp() functions does not affect the results of the computation (it cancels out, as long as the same base is used throughout).

This product includes Gain Map technology under license by Adobe.

Definition at line 41 of file SkGainmapInfo.h.

Member Enumeration Documentation

◆ BaseImageType

enum class SkGainmapInfo::BaseImageType
strong

Whether the base image is the SDR image or the HDR image.

Enumerator
kSDR 
kHDR 

Definition at line 69 of file SkGainmapInfo.h.

◆ Type

enum class SkGainmapInfo::Type
strong
Enumerator
kDefault 

Definition at line 94 of file SkGainmapInfo.h.

94 {
96 };

Member Function Documentation

◆ operator!=()

bool SkGainmapInfo::operator!= ( const SkGainmapInfo other) const
inline

Definition at line 91 of file SkGainmapInfo.h.

91{ return !(*this == other); }

◆ operator==()

bool SkGainmapInfo::operator== ( const SkGainmapInfo other) const
inline

Definition at line 81 of file SkGainmapInfo.h.

81 {
82 return fGainmapRatioMin == other.fGainmapRatioMin &&
84 fEpsilonSdr == other.fEpsilonSdr && fEpsilonHdr == other.fEpsilonHdr &&
90 }
static bool Equals(const SkColorSpace *, const SkColorSpace *)
T * get() const
Definition SkRefCnt.h:303
SkColor4f fGainmapRatioMax
SkColor4f fEpsilonSdr
SkColor4f fGainmapGamma
sk_sp< SkColorSpace > fGainmapMathColorSpace
SkColor4f fGainmapRatioMin
BaseImageType fBaseImageType
float fDisplayRatioSdr
SkColor4f fEpsilonHdr
float fDisplayRatioHdr

Member Data Documentation

◆ fBaseImageType

BaseImageType SkGainmapInfo::fBaseImageType = BaseImageType::kSDR

Definition at line 73 of file SkGainmapInfo.h.

◆ fDisplayRatioHdr

float SkGainmapInfo::fDisplayRatioHdr = 2.f

Definition at line 64 of file SkGainmapInfo.h.

◆ fDisplayRatioSdr

float SkGainmapInfo::fDisplayRatioSdr = 1.f

If the output display's HDR to SDR ratio is less or equal than fDisplayRatioSdr then the SDR rendition is displayed. If the output display's HDR to SDR ratio is greater or equal than fDisplayRatioHdr then the HDR rendition is displayed. If the output display's HDR to SDR ratio is between these values then an interpolation between the two is displayed using the math above.

Definition at line 63 of file SkGainmapInfo.h.

◆ fEpsilonHdr

SkColor4f SkGainmapInfo::fEpsilonHdr = {0.f, 0.f, 0.f, 1.0}

Definition at line 54 of file SkGainmapInfo.h.

54{0.f, 0.f, 0.f, 1.0};

◆ fEpsilonSdr

SkColor4f SkGainmapInfo::fEpsilonSdr = {0.f, 0.f, 0.f, 1.0}

Parameters sometimes used in gainmap computation to avoid numerical instability.

Definition at line 53 of file SkGainmapInfo.h.

53{0.f, 0.f, 0.f, 1.0};

◆ fGainmapGamma

SkColor4f SkGainmapInfo::fGainmapGamma = {1.f, 1.f, 1.f, 1.f}

Definition at line 48 of file SkGainmapInfo.h.

48{1.f, 1.f, 1.f, 1.f};

◆ fGainmapMathColorSpace

sk_sp<SkColorSpace> SkGainmapInfo::fGainmapMathColorSpace = nullptr

If specified, color space to apply the gainmap in, otherwise the base image's color space is used. Only the color primaries are used, the transfer function is irrelevant.

Definition at line 79 of file SkGainmapInfo.h.

◆ fGainmapRatioMax

SkColor4f SkGainmapInfo::fGainmapRatioMax = {2.f, 2.f, 2.f, 1.0}

Definition at line 47 of file SkGainmapInfo.h.

47{2.f, 2.f, 2.f, 1.0};

◆ fGainmapRatioMin

SkColor4f SkGainmapInfo::fGainmapRatioMin = {1.f, 1.f, 1.f, 1.0}

Parameters for converting the gainmap from its image encoding to log space. These are specified per color channel. The alpha value is unused.

Definition at line 46 of file SkGainmapInfo.h.

46{1.f, 1.f, 1.f, 1.0};

◆ fType

Type SkGainmapInfo::fType = Type::kDefault

Definition at line 97 of file SkGainmapInfo.h.


The documentation for this struct was generated from the following file: