diff options
author | JiDe Zhang <[email protected]> | 2021-10-28 11:45:52 +0800 |
---|---|---|
committer | JiDe Zhang <[email protected]> | 2021-10-29 18:59:48 +0800 |
commit | 85b5413dc43e20951a3f27b2940961b1c998df95 (patch) | |
tree | b131e0f53937f0db19f1d4a06e86d7810d5ade5c /src/quick/util | |
parent | 004e90b15569ab204e8302df853ef66eba918131 (diff) |
Avoid unnecessary color format conversion
If a color is not the rgb format, when QColor::red() QColor::blue()
QColor::green() is used continuously to obtain the values of different
channels, three times color conversions will occur. Therefore, use
QColor::toRgb() before that to ensure that only one conversion is
performed at most. Not only rgb, the conversion of other formats is the
same.
Change-Id: Ia969e1ca6f1524ad5d7e8dec915bcbc407875c66
Reviewed-by: Shawn Rutledge <[email protected]>
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 338ab4b5fa..f869d26280 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -262,7 +262,7 @@ public: QVariant tint(const QVariant &baseVar, const QVariant &tintVar) override { - QColor tintColor = tintVar.value<QColor>(); + QColor tintColor = tintVar.value<QColor>().toRgb(); int tintAlpha = tintColor.alpha(); if (tintAlpha == 0xFF) { @@ -272,7 +272,7 @@ public: } // tint the base color and return the final color - QColor baseColor = baseVar.value<QColor>(); + QColor baseColor = baseVar.value<QColor>().toRgb(); qreal a = tintColor.alphaF(); qreal inv_a = 1.0 - a; |