SkScalar SkSRGBLuminance::fromLuma(SkScalar luma) const {
    //The magic numbers are derived from the sRGB specification.
    //See http://www.color.org/chardata/rgb/srgb.xalter .
    if (luma <= SkFloatToScalar(0.0031308f)) {
        return luma * SkFloatToScalar(12.92f);
    }
    return SkFloatToScalar(1.055f) * SkScalarPow(luma, SkScalarInvert(SkFloatToScalar(2.4f)))
           - SkFloatToScalar(0.055f);
}
SkScalar SkSRGBLuminance::toLuma(SkScalar luminance) const {
    //The magic numbers are derived from the sRGB specification.
    //See http://www.color.org/chardata/rgb/srgb.xalter .
    if (luminance <= SkFloatToScalar(0.04045f)) {
        return luminance / SkFloatToScalar(12.92f);
    }
    return SkScalarPow((luminance + SkFloatToScalar(0.055f)) / SkFloatToScalar(1.055f),
                       SkFloatToScalar(2.4f));
}
Example #3
0
 SkScalar fromLuma(SkScalar SkDEBUGCODE(gamma), SkScalar luma) const override {
     SkASSERT(0 == gamma);
     //The magic numbers are derived from the sRGB specification.
     //See http://www.color.org/chardata/rgb/srgb.xalter .
     if (luma <= 0.0031308f) {
         return luma * 12.92f;
     }
     return 1.055f * SkScalarPow(luma, SkScalarInvert(2.4f))
            - 0.055f;
 }
Example #4
0
 SkScalar toLuma(SkScalar SkDEBUGCODE(gamma), SkScalar luminance) const override {
     SkASSERT(0 == gamma);
     //The magic numbers are derived from the sRGB specification.
     //See http://www.color.org/chardata/rgb/srgb.xalter .
     if (luminance <= 0.04045f) {
         return luminance / 12.92f;
     }
     return SkScalarPow((luminance + 0.055f) / 1.055f,
                     2.4f);
 }
Example #5
0
 SkScalar fromLuma(SkScalar gamma, SkScalar luma) const override {
     return SkScalarPow(luma, SkScalarInvert(gamma));
 }
Example #6
0
 SkScalar toLuma(SkScalar gamma, SkScalar luminance) const override {
     return SkScalarPow(luminance, gamma);
 }
SkScalar SkGammaLuminance::fromLuma(SkScalar luma) const {
    return SkScalarPow(luma, fGammaInverse);
}
SkScalar SkGammaLuminance::toLuma(SkScalar luminance) const {
    return SkScalarPow(luminance, fGamma);
}
Example #9
0
static SkScalar SkScalarCubeRoot(SkScalar x) {
    return SkScalarPow(x, 0.3333333f);
}