jumper, to_2dot2 and from_2dot2
Nothing too tricky here. Change-Id: I2a10548efc75a6fd875fcb242790880d9b9a28fd Reviewed-on: https://skia-review.googlesource.com/11388 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
d9836f44fb
commit
7125ac6036
@ -78,6 +78,8 @@ static K kConstants = {
|
||||
M(unpremul) \
|
||||
M(from_srgb) \
|
||||
M(to_srgb) \
|
||||
M(from_2dot2) \
|
||||
M(to_2dot2) \
|
||||
M(scale_1_float) \
|
||||
M(scale_u8) \
|
||||
M(lerp_1_float) \
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -484,6 +484,35 @@ STAGE(to_srgb) {
|
||||
b = fn(b);
|
||||
}
|
||||
|
||||
STAGE(from_2dot2) {
|
||||
auto fn = [](F x) {
|
||||
// x^(141/64) = x^(2.20312) is a great approximation of the true value, x^(2.2).
|
||||
// (note: x^(35/16) = x^(2.1875) is an okay one as well and would be quicker)
|
||||
F x16 = rsqrt(rsqrt(rsqrt(rsqrt(x)))), // x^(1/16) = x^(4/64);
|
||||
x64 = rsqrt(rsqrt(x16)); // x^(1/64)
|
||||
|
||||
// 141/64 = 128/64 + 12/64 + 1/64
|
||||
return max((x*x) * (x16*x16*x16) * x64, 0);
|
||||
};
|
||||
r = fn(r);
|
||||
g = fn(g);
|
||||
b = fn(b);
|
||||
}
|
||||
STAGE(to_2dot2) {
|
||||
auto fn = [](F x) {
|
||||
// x^(29/64) is a very good approximation of the true value, x^(1/2.2).
|
||||
F x2 = rsqrt(x), // x^(-1/2)
|
||||
x32 = rsqrt(rsqrt(rsqrt(rsqrt(x2)))), // x^(-1/32)
|
||||
x64 = rsqrt(x32); // x^(+1/64)
|
||||
|
||||
// 29/64 = 32/64 - 2/64 - 1/64
|
||||
return max(rcp(x2) * x32 * rcp(x64), 0);
|
||||
};
|
||||
r = fn(r);
|
||||
g = fn(g);
|
||||
b = fn(b);
|
||||
}
|
||||
|
||||
STAGE(scale_1_float) {
|
||||
auto c = *(const float*)ctx;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user