common: promote MULTIPLY() to a common helper macro.

it's useful among the modules.
This commit is contained in:
Hermet Park 2023-06-26 12:40:03 +09:00 committed by Hermet Park
parent 4482664740
commit dce14a8449
3 changed files with 7 additions and 6 deletions

View file

@ -307,11 +307,6 @@ static inline SwCoord HALF_STROKE(float width)
return TO_SWCOORD(width * 0.5f);
}
static inline uint8_t MULTIPLY(uint8_t c, uint8_t a)
{
return (((c) * (a) + 0xff) >> 8);
}
static inline uint8_t A(uint32_t c)
{
return ((c) >> 24);

View file

@ -245,7 +245,7 @@ RenderData Paint::Impl::update(RenderMethod& renderer, const RenderTransform* pT
RenderData rd = nullptr;
auto newFlag = static_cast<RenderUpdateFlag>(pFlag | renderFlag);
renderFlag = RenderUpdateFlag::None;
opacity = ((opacity * this->opacity + 0xff) >> 8); //opacity = (opacity * this->opacity) / 255;
opacity = MULTIPLY(opacity, this->opacity);
if (rTransform && pTransform) {
RenderTransform outTransform(pTransform, rTransform);

View file

@ -316,6 +316,12 @@ static inline ColorSpace COMPOSITE_TO_COLORSPACE(RenderMethod& renderer, Composi
}
}
static inline uint8_t MULTIPLY(uint8_t c, uint8_t a)
{
return (((c) * (a) + 0xff) >> 8);
}
}
#endif //_TVG_RENDER_H_