diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 12 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qregion.cpp | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a385332d6d..ac11b0f324 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5925,9 +5925,9 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int dg = gamma[dg]; db = gamma[db]; - int nr = qt_div_255((sr - dr) * mr) + dr; - int ng = qt_div_255((sg - dg) * mg) + dg; - int nb = qt_div_255((sb - db) * mb) + db; + int nr = qt_div_255(sr * mr + dr * (255 - mr)); + int ng = qt_div_255(sg * mg + dg * (255 - mg)); + int nb = qt_div_255(sb * mb + db * (255 - mb)); nr = invgamma[nr]; ng = invgamma[ng]; @@ -5952,9 +5952,9 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, in int alpha = coverage; int ialpha = 255 - alpha; - int nr = (sr * alpha + ialpha * dr) / 255; - int ng = (sg * alpha + ialpha * dg) / 255; - int nb = (sb * alpha + ialpha * db) / 255; + int nr = qt_div_255(sr * alpha + dr * ialpha); + int ng = qt_div_255(sg * alpha + dg * ialpha); + int nb = qt_div_255(sb * alpha + db * ialpha); nr = invgamma[nr]; ng = invgamma[ng]; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 922ff157e2..664117a730 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -760,6 +760,7 @@ static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) { return t; } +// qt_div_255 is a fast rounded division by 255 using an approximation that is accurate for all positive 16-bit integers static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 1ba6345bf9..0571e1a328 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE \section1 Additional License Information - On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on + On Embedded Linux and X11 platforms, parts of this class rely on code obtained under the following licenses: \legalese |