mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-08 05:25:33 +00:00
Add clamping to our pixels
This commit is contained in:
parent
86678c0cfe
commit
3dd1444ff6
|
@ -163,6 +163,13 @@ class Pixel : public Vector4<uint16> {
|
|||
|
||||
// Tests for equality by comparing the values and the bit depths.
|
||||
bool operator==(const Pixel &) const;
|
||||
|
||||
// Clamps the pixel to the range [0,255]
|
||||
void ClampByte() {
|
||||
for(uint32 i = 0; i < 4; i++) {
|
||||
vec[i] = (vec[i] < 0)? 0 : ((vec[i] > 255)? 255 : vec[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_VECTOR_TYPE(Pixel);
|
||||
|
||||
|
|
|
@ -306,6 +306,16 @@ TEST(Pixel, ScaleColor) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(Pixel, ByteClamp) {
|
||||
FasTC::Pixel p(256, 3, -2, 10);
|
||||
p.ClampByte();
|
||||
EXPECT_EQ(p.A(), 255);
|
||||
EXPECT_EQ(p.R(), 3);
|
||||
EXPECT_EQ(p.G(), 255);
|
||||
EXPECT_EQ(p.B(), 10);
|
||||
}
|
||||
|
||||
|
||||
TEST(YCoCgPixel, Conversion) {
|
||||
|
||||
FasTC::Pixel p;
|
||||
|
|
Loading…
Reference in a new issue