Add comparison operator for pixels

This commit is contained in:
Pavel Krajcevski 2013-08-31 16:37:58 -04:00
parent 8bf682f04e
commit fa37aba768
2 changed files with 17 additions and 0 deletions

View file

@ -163,5 +163,19 @@ namespace PVRTCC {
return r;
}
bool Pixel::operator==(const Pixel &other) const {
uint8 depths[4];
other.GetBitDepth(depths);
bool ok = true;
for(int i = 0; i < 4; i++) {
ok = ok && m_BitDepth[i] == depths[i];
uint8 mask = (1 << depths[i]) - 1;
const uint8 c = other.Component(i) & mask;
ok = ok && (c == (Component(i) & mask));
}
return ok;
}
} // namespace PVRTCC

View file

@ -111,6 +111,9 @@ class Pixel {
// up in the most-significant byte.
uint32 PackRGBA() const;
// Tests for equality by comparing the values and the bit depths.
bool operator==(const Pixel &) const;
private:
union {
struct {