File indexing completed on 2024-11-10 04:56:38
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "colorlut.h" 0010 0011 #include "colortransformation.h" 0012 0013 namespace KWin 0014 { 0015 0016 ColorLUT::ColorLUT(const std::shared_ptr<ColorTransformation> &transformation, size_t size) 0017 : m_transformation(transformation) 0018 { 0019 m_data.fill(0, 3 * size); 0020 for (uint64_t i = 0; i < size; i++) { 0021 const uint16_t index = (i * 0xFFFF) / size; 0022 std::tie(m_data[i], m_data[size + i], m_data[size * 2 + i]) = transformation->transform(index, index, index); 0023 } 0024 } 0025 0026 uint16_t *ColorLUT::red() const 0027 { 0028 return const_cast<uint16_t *>(m_data.constData()); 0029 } 0030 0031 uint16_t *ColorLUT::green() const 0032 { 0033 return const_cast<uint16_t *>(m_data.constData() + size()); 0034 } 0035 0036 uint16_t *ColorLUT::blue() const 0037 { 0038 return const_cast<uint16_t *>(m_data.constData() + 2 * size()); 0039 } 0040 0041 size_t ColorLUT::size() const 0042 { 0043 return m_data.size() / 3; 0044 } 0045 0046 std::shared_ptr<ColorTransformation> ColorLUT::transformation() const 0047 { 0048 return m_transformation; 0049 } 0050 0051 }