mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-28 00:14:16 +01:00
Make IPixels single vectors in order to allow us to use their operators and other convenience functions.
This commit is contained in:
parent
127fd7b365
commit
b07fe9b670
@ -54,23 +54,21 @@
|
|||||||
#define BASE_INCLUDE_IPIXEL_H_
|
#define BASE_INCLUDE_IPIXEL_H_
|
||||||
|
|
||||||
#include "TexCompTypes.h"
|
#include "TexCompTypes.h"
|
||||||
|
#include "VectorBase.h"
|
||||||
|
|
||||||
namespace FasTC {
|
namespace FasTC {
|
||||||
|
|
||||||
class IPixel {
|
class IPixel : public VectorBase<float, 1> {
|
||||||
private:
|
|
||||||
float m_Intensity;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IPixel() : m_Intensity(0.0f) { }
|
IPixel() : VectorBase<float, 1>() { vec[0] = 0.0f; }
|
||||||
IPixel(float f) : m_Intensity(f) { }
|
IPixel(float f) : VectorBase<float, 1>(&f) { }
|
||||||
|
|
||||||
operator float() const {
|
operator float() const {
|
||||||
return m_Intensity;
|
return vec[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
IPixel operator=(const float &f) {
|
IPixel operator=(const float &f) {
|
||||||
return m_Intensity = f;
|
return vec[0] = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take all of the components, transform them to their 8-bit variants,
|
// Take all of the components, transform them to their 8-bit variants,
|
||||||
@ -80,6 +78,7 @@ class IPixel {
|
|||||||
uint32 Pack() const;
|
uint32 Pack() const;
|
||||||
void Unpack(uint32 rgba);
|
void Unpack(uint32 rgba);
|
||||||
};
|
};
|
||||||
|
REGISTER_VECTOR_TYPE(IPixel);
|
||||||
|
|
||||||
} // namespace FasTC
|
} // namespace FasTC
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ namespace FasTC {
|
|||||||
uint32 IPixel::Pack() const {
|
uint32 IPixel::Pack() const {
|
||||||
uint32 ret = 0xFF << 24;
|
uint32 ret = 0xFF << 24;
|
||||||
for(uint32 i = 0; i < 3; i++) {
|
for(uint32 i = 0; i < 3; i++) {
|
||||||
ret |= static_cast<uint32>((255.0 * m_Intensity) + 0.5f) << i*8;
|
ret |= static_cast<uint32>((255.0 * vec[0]) + 0.5f) << i*8;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPixel::Unpack(uint32 rgba) {
|
void IPixel::Unpack(uint32 rgba) {
|
||||||
Pixel p(rgba);
|
Pixel p(rgba);
|
||||||
m_Intensity = p.ToIntensity();
|
vec[0] = p.ToIntensity();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace FasTC
|
} // namespace FasTC
|
||||||
|
Loading…
Reference in New Issue
Block a user