Revert "unorm/unorm -> to_unorm/from_unorm"
This reverts commit cd4e5662ac
.
Reason for revert: reverting dependent changes
Original change's description:
> unorm/unorm -> to_unorm/from_unorm
>
> Just better names, no real change.
>
> Change-Id: I7a67ccb49d5367137b6a1f100434cb866f15ea71
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268389
> Auto-Submit: Mike Klein <mtklein@google.com>
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>
TBR=mtklein@google.com,herb@google.com,reed@google.com
Change-Id: I0afc659ad0bb9e5145873aaad559ceaf2b70ee0d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268496
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
c66882ebcd
commit
8feac2d718
@ -824,28 +824,28 @@ namespace skvm {
|
||||
return {this->push(Op::round, x.id)};
|
||||
}
|
||||
|
||||
F32 Builder::from_unorm(int bits, I32 x) {
|
||||
F32 Builder::unorm(int bits, I32 x) {
|
||||
float limit = (1<<bits)-1.0f;
|
||||
return mul(to_f32(x), splat(1/limit));
|
||||
}
|
||||
I32 Builder::to_unorm(int bits, F32 x) {
|
||||
I32 Builder::unorm(int bits, F32 x) {
|
||||
float limit = (1<<bits)-1.0f;
|
||||
return round(mul(x, splat(limit)));
|
||||
}
|
||||
|
||||
Color Builder::unpack_8888(I32 rgba) {
|
||||
return {
|
||||
from_unorm(8, extract(rgba, 0, splat(0xff))),
|
||||
from_unorm(8, extract(rgba, 8, splat(0xff))),
|
||||
from_unorm(8, extract(rgba, 16, splat(0xff))),
|
||||
from_unorm(8, extract(rgba, 24, splat(0xff))),
|
||||
unorm(8, extract(rgba, 0, splat(0xff))),
|
||||
unorm(8, extract(rgba, 8, splat(0xff))),
|
||||
unorm(8, extract(rgba, 16, splat(0xff))),
|
||||
unorm(8, extract(rgba, 24, splat(0xff))),
|
||||
};
|
||||
}
|
||||
Color Builder::unpack_565(I32 bgr) {
|
||||
return {
|
||||
from_unorm(5, extract(bgr, 11, splat(0b011'111))),
|
||||
from_unorm(6, extract(bgr, 5, splat(0b111'111))),
|
||||
from_unorm(5, extract(bgr, 0, splat(0b011'111))),
|
||||
unorm(5, extract(bgr, 11, splat(0b011'111))),
|
||||
unorm(6, extract(bgr, 5, splat(0b111'111))),
|
||||
unorm(5, extract(bgr, 0, splat(0b011'111))),
|
||||
splat(1.0f),
|
||||
};
|
||||
}
|
||||
|
@ -533,8 +533,8 @@ namespace skvm {
|
||||
I32 pack (I32 x, I32 y, int bits); // x | (y << bits), assuming (x & (y << bits)) == 0
|
||||
|
||||
// Common idioms used in several places, worth centralizing for consistency.
|
||||
F32 from_unorm(int bits, I32); // E.g. from_unorm(8, x) -> x * (1/255.0f)
|
||||
I32 to_unorm(int bits, F32); // E.g. to_unorm(8, x) -> round(x * 255)
|
||||
F32 unorm(int bits, I32); // E.g. unorm(8, x) -> x * (1/255.0f)
|
||||
I32 unorm(int bits, F32); // E.g. unorm(8, f) -> round(x * 255)
|
||||
|
||||
Color unpack_8888(I32 rgba);
|
||||
Color unpack_565 (I32 bgr ); // bottom 16 bits
|
||||
|
@ -189,8 +189,8 @@ namespace {
|
||||
uniforms, alloc,
|
||||
x,y, &src.r, &src.g, &src.b, &src.a));
|
||||
if (params.coverage == Coverage::Mask3D) {
|
||||
skvm::F32 M = from_unorm(8, load8(varying<uint8_t>())),
|
||||
A = from_unorm(8, load8(varying<uint8_t>()));
|
||||
skvm::F32 M = unorm(8, load8(varying<uint8_t>())),
|
||||
A = unorm(8, load8(varying<uint8_t>()));
|
||||
|
||||
src.r = min(mad(src.r, M, A), src.a);
|
||||
src.g = min(mad(src.g, M, A), src.a);
|
||||
@ -230,12 +230,12 @@ namespace {
|
||||
case Coverage::Full: return false;
|
||||
|
||||
case Coverage::UniformA8: cov->r = cov->g = cov->b = cov->a =
|
||||
from_unorm(8, uniform8(uniform(), 0));
|
||||
unorm(8, uniform8(uniform(), 0));
|
||||
return true;
|
||||
|
||||
case Coverage::Mask3D:
|
||||
case Coverage::MaskA8: cov->r = cov->g = cov->b = cov->a =
|
||||
from_unorm(8, load8(varying<uint8_t>()));
|
||||
unorm(8, load8(varying<uint8_t>()));
|
||||
return true;
|
||||
|
||||
case Coverage::MaskLCD16:
|
||||
@ -367,17 +367,17 @@ namespace {
|
||||
default: SkUNREACHABLE;
|
||||
|
||||
case kRGB_565_SkColorType:
|
||||
store16(dst_ptr, pack(pack(to_unorm(5,src.b),
|
||||
to_unorm(6,src.g), 5),
|
||||
to_unorm(5,src.r),11));
|
||||
store16(dst_ptr, pack(pack(unorm(5,src.b),
|
||||
unorm(6,src.g), 5),
|
||||
unorm(5,src.r),11));
|
||||
break;
|
||||
|
||||
case kBGRA_8888_SkColorType: std::swap(src.r, src.b); // fallthrough
|
||||
case kRGBA_8888_SkColorType:
|
||||
store32(dst_ptr, pack(pack(to_unorm(8, src.r),
|
||||
to_unorm(8, src.g), 8),
|
||||
pack(to_unorm(8, src.b),
|
||||
to_unorm(8, src.a), 8), 16));
|
||||
store32(dst_ptr, pack(pack(unorm(8, src.r),
|
||||
unorm(8, src.g), 8),
|
||||
pack(unorm(8, src.b),
|
||||
unorm(8, src.a), 8), 16));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ public:
|
||||
|
||||
auto apply_table_to_component = [&](skvm::F32 c, const uint8_t* bytePtr) -> skvm::F32 {
|
||||
c = p->clamp(c, p->splat(0.f), p->splat(1.0f));
|
||||
skvm::I32 index = p->to_unorm(8, c);
|
||||
skvm::I32 index = p->unorm(8, c);
|
||||
|
||||
skvm::Builder::Uniform table = uniforms->pushPtr(bytePtr);
|
||||
skvm::I32 byte = p->gather8(table, index);
|
||||
return p->from_unorm(8, byte);
|
||||
return p->unorm(8, byte);
|
||||
};
|
||||
|
||||
p->unpremul(r,g,b,*a);
|
||||
|
Loading…
Reference in New Issue
Block a user