summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-01 13:16:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-02 09:18:19 +0100
commit477d2ba662cbd716588519419eece2b4f06d8610 (patch)
treef3aa77adfcd770e8321738bffed8f8243eb11a98 /include/tools
parent82d42fa2c05e8d53ec2c21733a2a9f53412dd2d1 (diff)
delete colordata.hxx
move what we still need into color.hxx Change-Id: Ied7e31eb16468aa334c666b1499a6262f16a6350 Reviewed-on: https://gerrit.libreoffice.org/50561 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/color.hxx34
-rw-r--r--include/tools/colordata.hxx51
2 files changed, 23 insertions, 62 deletions
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 1f6012d98151..7d9202282ea9 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -19,39 +19,46 @@
#ifndef INCLUDED_TOOLS_COLOR_HXX
#define INCLUDED_TOOLS_COLOR_HXX
+#include <sal/types.h>
#include <tools/toolsdllapi.h>
-#include <tools/colordata.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <basegfx/color/bcolor.hxx>
class SvStream;
+constexpr sal_uInt8 COLORDATA_RED( sal_uInt32 n ) { return static_cast<sal_uInt8>(n>>16); }
+constexpr sal_uInt8 COLORDATA_GREEN( sal_uInt32 n ) { return static_cast<sal_uInt8>(static_cast<sal_uInt16>(n) >> 8); }
+constexpr sal_uInt8 COLORDATA_BLUE( sal_uInt32 n ) { return static_cast<sal_uInt8>(n); }
+constexpr sal_uInt8 COLORDATA_TRANSPARENCY( sal_uInt32 n ) { return static_cast<sal_uInt8>(n>>24); }
+constexpr sal_uInt32 COLORDATA_RGB( sal_uInt32 n ) { return static_cast<sal_uInt32>(n & 0x00FFFFFF); }
// Color
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Color final
{
- ColorData mnColor;
+ sal_uInt32 mnColor;
public:
constexpr Color()
: mnColor(0) // black
{}
- constexpr Color(ColorData nColor)
+ constexpr Color(sal_uInt32 nColor)
: mnColor(nColor)
{}
- constexpr Color(sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue)
- : mnColor(RGB_COLORDATA(nRed, nGreen, nBlue))
- {}
constexpr Color(sal_uInt8 nTransparency, sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue)
- : mnColor(TRGB_COLORDATA(nTransparency, nRed, nGreen, nBlue))
+ : mnColor( sal_uInt32(nBlue) | (sal_uInt32(nGreen) << 8) | (sal_uInt32(nRed) << 16)
+ | (sal_uInt32(nTransparency) << 24) )
+ {}
+ constexpr Color(sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue)
+ : Color(0, nRed, nGreen, nBlue)
{}
// constructor to create a tools-Color from ::basegfx::BColor
explicit Color(const basegfx::BColor& rBColor)
- : mnColor(RGB_COLORDATA(sal_uInt8((rBColor.getRed() * 255.0) + 0.5),
- sal_uInt8((rBColor.getGreen() * 255.0) + 0.5),
- sal_uInt8((rBColor.getBlue() * 255.0) + 0.5)))
+ : Color(0,
+ sal_uInt8((rBColor.getRed() * 255.0) + 0.5),
+ sal_uInt8((rBColor.getGreen() * 255.0) + 0.5),
+ sal_uInt8((rBColor.getBlue() * 255.0) + 0.5))
{}
/** Primarily used when passing Color objects to UNO API */
@@ -91,7 +98,7 @@ public:
return COLORDATA_TRANSPARENCY(mnColor);
}
- ColorData GetColor() const
+ sal_uInt32 GetColor() const
{
return mnColor;
}
@@ -198,6 +205,11 @@ inline sal_uInt8 Color::GetLuminance() const
COLORDATA_RED(mnColor) * 76UL) >> 8);
}
+constexpr sal_uInt8 ColorChannelMerge(sal_uInt8 nDst, sal_uInt8 nSrc, sal_uInt8 nSrcTrans)
+{
+ return static_cast<sal_uInt8>(((static_cast<sal_Int32>(nDst)-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8);
+};
+
inline void Color::Merge( const Color& rMergeColor, sal_uInt8 cTransparency )
{
SetRed(ColorChannelMerge(COLORDATA_RED(mnColor), COLORDATA_RED(rMergeColor.mnColor), cTransparency));
diff --git a/include/tools/colordata.hxx b/include/tools/colordata.hxx
deleted file mode 100644
index 6159e49b947d..000000000000
--- a/include/tools/colordata.hxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_TOOLS_COLORDATA_HXX
-#define INCLUDED_TOOLS_COLORDATA_HXX
-
-#include <sal/types.h>
-
-// Color types
-typedef sal_uInt32 ColorData;
-
-constexpr ColorData TRGB_COLORDATA(
- sal_uInt8 TRANSPARENCE, sal_uInt8 RED, sal_uInt8 GREEN, sal_uInt8 BLUE)
-{
- return sal_uInt32(BLUE) | (sal_uInt32(GREEN) << 8) | (sal_uInt32(RED) << 16)
- | (sal_uInt32(TRANSPARENCE) << 24);
-}
-
-constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) {
- return sal_uInt32(b) | (sal_uInt32(g) << 8) | (sal_uInt32(r) << 16);
-}
-
-#define COLORDATA_RED( n ) (static_cast<sal_uInt8>((n)>>16))
-#define COLORDATA_GREEN( n ) (static_cast<sal_uInt8>((static_cast<sal_uInt16>(n)) >> 8))
-#define COLORDATA_BLUE( n ) (static_cast<sal_uInt8>(n))
-#define COLORDATA_TRANSPARENCY( n ) (static_cast<sal_uInt8>((n)>>24))
-#define COLORDATA_RGB( n ) (static_cast<ColorData>((n) & 0x00FFFFFF))
-
-constexpr sal_uInt8 ColorChannelMerge(sal_uInt8 nDst, sal_uInt8 nSrc, sal_uInt8 nSrcTrans)
-{
- return static_cast<sal_uInt8>(((static_cast<sal_Int32>(nDst)-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */