mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-08 21:55:34 +00:00
Add shuffle operator to pixels.
This commit is contained in:
parent
426d12e5c9
commit
37ffc102d0
|
@ -143,6 +143,17 @@ class Pixel : public Vector4<uint16> {
|
||||||
uint32 Pack() const;
|
uint32 Pack() const;
|
||||||
void Unpack(uint32 rgba);
|
void Unpack(uint32 rgba);
|
||||||
|
|
||||||
|
// Shuffles the pixel values around so that they change their ordering based
|
||||||
|
// on the passed mask. The values are chosen such that each two bits from the
|
||||||
|
// least significant bit define a value from 0-3. From LSB to MSB, the values
|
||||||
|
// are labelled a, b, c, d. From these labels, we store:
|
||||||
|
// m_Pixels[0] = m_Pixels[a]
|
||||||
|
// m_Pixels[1] = m_Pixels[b]
|
||||||
|
// m_Pixels[2] = m_Pixels[c]
|
||||||
|
// m_Pixels[3] = m_Pixels[d]
|
||||||
|
// hence, 0xE4 (11 10 01 00) represents a no-op.
|
||||||
|
void Shuffle(uint8 shuffleMask = 0xE4);
|
||||||
|
|
||||||
// Tests for equality by comparing the values and the bit depths.
|
// Tests for equality by comparing the values and the bit depths.
|
||||||
bool operator==(const Pixel &) const;
|
bool operator==(const Pixel &) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,6 +222,29 @@ namespace FasTC {
|
||||||
B() = ChangeBitDepth((rgba >> 16) & 0xFF, 8, m_BitDepth[3]);
|
B() = ChangeBitDepth((rgba >> 16) & 0xFF, 8, m_BitDepth[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Pixel::Shuffle(uint8 shuffleMask) {
|
||||||
|
Pixel thisPixel(*this);
|
||||||
|
uint8 a = shuffleMask & 3;
|
||||||
|
uint8 b = (shuffleMask >> 2) & 3;
|
||||||
|
uint8 c = (shuffleMask >> 4) & 3;
|
||||||
|
uint8 d = (shuffleMask >> 6) & 3;
|
||||||
|
|
||||||
|
Pixel tmp;
|
||||||
|
tmp[0] = thisPixel[a];
|
||||||
|
tmp.m_BitDepth[0] = thisPixel.m_BitDepth[a];
|
||||||
|
|
||||||
|
tmp[1] = thisPixel[b];
|
||||||
|
tmp.m_BitDepth[1] = thisPixel.m_BitDepth[b];
|
||||||
|
|
||||||
|
tmp[2] = thisPixel[c];
|
||||||
|
tmp.m_BitDepth[2] = thisPixel.m_BitDepth[c];
|
||||||
|
|
||||||
|
tmp[3] = thisPixel[d];
|
||||||
|
tmp.m_BitDepth[3] = thisPixel.m_BitDepth[d];
|
||||||
|
|
||||||
|
*this = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
bool Pixel::operator==(const Pixel &other) const {
|
bool Pixel::operator==(const Pixel &other) const {
|
||||||
uint8 depths[4];
|
uint8 depths[4];
|
||||||
other.GetBitDepth(depths);
|
other.GetBitDepth(depths);
|
||||||
|
|
Loading…
Reference in a new issue