diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-15 14:49:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-16 10:07:07 +0100 |
commit | 63a68064bb33f180b8a231f7524d99405d910226 (patch) | |
tree | 7ecf05b057c5ca4d80a48af045998a4b34484561 /drawinglayer/source/primitive2d | |
parent | d534a4c7b45ff254b339e806c6a11f13d9ff0043 (diff) |
make the Color constructors explicitly specify transparency
to reduce the churn, we leave the existing constructor in place,
and add a clang plugin to detect when the value passed to the
existing constructor may contain transparency/alpha data.
i.e. we leave expressions like Color(0xffffff) alone, but
warn about any non-constant expression, and any expression
like Color(0xff000000)
Change-Id: Id2ce58e08882d9b7bd0b9f88eca97359dcdbcc8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109362
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r-- | drawinglayer/source/primitive2d/sceneprimitive2d.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index b96cca222e7f..21bf591aecc0 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -82,14 +82,14 @@ namespace if(nAlpha) { - aContent.SetPixel(y, x, Color( - 255 - static_cast<sal_uInt8>(nAlpha), + aContent.SetPixel(y, x, Color(ColorAlpha, + static_cast<sal_uInt8>(nAlpha), static_cast<sal_uInt8>(nRed / nDivisor), static_cast<sal_uInt8>(nGreen / nDivisor), static_cast<sal_uInt8>(nBlue / nDivisor) )); } else - aContent.SetPixel(y, x, Color(255, 0, 0, 0)); + aContent.SetPixel(y, x, Color(ColorAlpha, 0, 0, 0, 0)); } } } @@ -105,10 +105,10 @@ namespace if(rPixel.getAlpha()) { - aContent.SetPixel(y, x, Color(255 - rPixel.getAlpha(), rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue())); + aContent.SetPixel(y, x, Color(ColorAlpha, rPixel.getAlpha(), rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue())); } else - aContent.SetPixel(y, x, Color(255, 0, 0, 0)); + aContent.SetPixel(y, x, Color(ColorAlpha, 0, 0, 0, 0)); } } } |