From dce14a84490769afaac408ff6ce4678596980eda Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 26 Jun 2023 12:40:03 +0900 Subject: [PATCH] common: promote MULTIPLY() to a common helper macro. it's useful among the modules. --- src/lib/sw_engine/tvgSwCommon.h | 5 ----- src/lib/tvgPaint.cpp | 2 +- src/lib/tvgRender.h | 6 ++++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index 3e482771..a39d4798 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -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); diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index 6580b53a..f5dca0f1 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -245,7 +245,7 @@ RenderData Paint::Impl::update(RenderMethod& renderer, const RenderTransform* pT RenderData rd = nullptr; auto newFlag = static_cast(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); diff --git a/src/lib/tvgRender.h b/src/lib/tvgRender.h index e0fb43d8..9106ba76 100644 --- a/src/lib/tvgRender.h +++ b/src/lib/tvgRender.h @@ -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_