mirror of
https://github.com/holub/mame
synced 2025-04-25 01:40:16 +03:00
Fixed some rgbaint_t functions. Added some optimizations to rgbaint_t.
This commit is contained in:
parent
fae860f0dd
commit
dc8e0b3c22
@ -117,7 +117,7 @@ void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& oth
|
||||
if ((UINT32)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
{
|
||||
m_a = (m_a * scale.m_a + other.m_a * scale2.m_a) >> 8;
|
||||
m_r = (m_r * scale.m_r + other.m_r * scale2.m_r) >> 8;
|
||||
|
@ -374,7 +374,7 @@ public:
|
||||
|
||||
void scale_and_clamp(const rgbaint_t& scale);
|
||||
void scale_imm_and_clamp(const INT32 scale);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
|
||||
void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
|
||||
void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
|
||||
|
||||
|
@ -174,53 +174,21 @@ void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor)
|
||||
|
||||
mul(scale1);
|
||||
add(scaled_other);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_and_clamp(const rgbaint_t& scale)
|
||||
{
|
||||
mul(scale);
|
||||
sra(8);
|
||||
max(0);
|
||||
min(255);
|
||||
sra_imm(8);
|
||||
clamp_to_uint8();
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_imm_and_clamp(const INT32 scale)
|
||||
{
|
||||
mul_imm(scale);
|
||||
sra(8);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
{
|
||||
rgbaint_t color2(other);
|
||||
color2.mul(scale2);
|
||||
|
||||
mul(scale);
|
||||
add(color2);
|
||||
sra(8);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other)
|
||||
{
|
||||
mul_imm(scale);
|
||||
sra(8);
|
||||
add(other);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other)
|
||||
{
|
||||
mul(scale);
|
||||
sra(8);
|
||||
add(other);
|
||||
max(0);
|
||||
min(255);
|
||||
sra_imm(8);
|
||||
clamp_to_uint8();
|
||||
}
|
||||
|
||||
#endif // defined(__SSE2__) || defined(_MSC_VER)
|
||||
|
@ -341,9 +341,33 @@ public:
|
||||
|
||||
void scale_and_clamp(const rgbaint_t& scale);
|
||||
void scale_imm_and_clamp(const INT32 scale);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
|
||||
void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
|
||||
|
||||
inline void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other)
|
||||
{
|
||||
mul_imm(scale);
|
||||
sra_imm(8);
|
||||
add(other);
|
||||
clamp_to_uint8();
|
||||
}
|
||||
|
||||
inline void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other)
|
||||
{
|
||||
mul(scale);
|
||||
sra_imm(8);
|
||||
add(other);
|
||||
clamp_to_uint8();
|
||||
}
|
||||
|
||||
inline void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
{
|
||||
rgbaint_t color2(other);
|
||||
color2.mul(scale2);
|
||||
|
||||
mul(scale);
|
||||
add(color2);
|
||||
sra_imm(8);
|
||||
clamp_to_uint8();
|
||||
}
|
||||
|
||||
inline void cmpeq(const rgbaint_t& value)
|
||||
{
|
||||
|
@ -168,13 +168,13 @@ void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor)
|
||||
|
||||
m_value = vec_msum((VECU16)m_value, (VECU16)scale1, vec_mulo((VECU16)other.m_value, (VECU16)scale2));
|
||||
m_value = vec_add(vec_sl(temp, shift), (VECU32)m_value);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_and_clamp(const rgbaint_t& scale)
|
||||
{
|
||||
mul(scale);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
@ -182,19 +182,19 @@ void rgbaint_t::scale_and_clamp(const rgbaint_t& scale)
|
||||
void rgbaint_t::scale_imm_and_clamp(const INT32 scale)
|
||||
{
|
||||
mul_imm(scale);
|
||||
sra(8);
|
||||
srsra_imma(8);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
|
||||
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
|
||||
{
|
||||
rgbaint_t color2(other);
|
||||
color2.mul(scale2);
|
||||
|
||||
mul(scale);
|
||||
add(color2);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
max(0);
|
||||
min(255);
|
||||
}
|
||||
@ -202,7 +202,7 @@ void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& oth
|
||||
void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other)
|
||||
{
|
||||
mul_imm(scale);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
add(other);
|
||||
max(0);
|
||||
min(255);
|
||||
@ -211,7 +211,7 @@ void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& othe
|
||||
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other)
|
||||
{
|
||||
mul(scale);
|
||||
sra(8);
|
||||
sra_imm(8);
|
||||
add(other);
|
||||
max(0);
|
||||
min(255);
|
||||
|
@ -342,7 +342,7 @@ public:
|
||||
|
||||
void scale_and_clamp(const rgbaint_t& scale);
|
||||
void scale_imm_and_clamp(const INT32 scale);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
|
||||
void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
|
||||
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
|
||||
void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
|
||||
|
||||
|
@ -2941,7 +2941,7 @@ INLINE void ATTR_FORCE_INLINE alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32
|
||||
// Main blend
|
||||
rgbaint_t destColor(da, dr, dg, db);
|
||||
|
||||
srcColor.scale_add_and_clamp(srcScale, destColor, destScale);
|
||||
srcColor.scale2_add_and_clamp(srcScale, destColor, destScale);
|
||||
/* clamp */
|
||||
//CLAMP((RR), 0x00, 0xff);
|
||||
//CLAMP((GG), 0x00, 0xff);
|
||||
|
Loading…
Reference in New Issue
Block a user