File indexing completed on 2024-11-10 04:56:36
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "x11_standalone_output.h" 0010 #include "core/colorlut.h" 0011 #include "core/colortransformation.h" 0012 #include "main.h" 0013 #include "x11_standalone_backend.h" 0014 0015 namespace KWin 0016 { 0017 0018 X11Output::X11Output(X11StandaloneBackend *backend, QObject *parent) 0019 : Output(parent) 0020 , m_backend(backend) 0021 { 0022 } 0023 0024 RenderLoop *X11Output::renderLoop() const 0025 { 0026 return m_loop; 0027 } 0028 0029 void X11Output::setRenderLoop(RenderLoop *loop) 0030 { 0031 m_loop = loop; 0032 } 0033 0034 int X11Output::xineramaNumber() const 0035 { 0036 return m_xineramaNumber; 0037 } 0038 0039 void X11Output::setXineramaNumber(int number) 0040 { 0041 m_xineramaNumber = number; 0042 } 0043 0044 bool X11Output::setChannelFactors(const QVector3D &rgb) 0045 { 0046 if (m_crtc == XCB_NONE) { 0047 return true; 0048 } 0049 auto transformation = ColorTransformation::createScalingTransform(ColorDescription::nitsToEncoded(rgb, NamedTransferFunction::gamma22, 1)); 0050 if (!transformation) { 0051 return false; 0052 } 0053 ColorLUT lut(std::move(transformation), m_gammaRampSize); 0054 xcb_randr_set_crtc_gamma(kwinApp()->x11Connection(), m_crtc, lut.size(), lut.red(), lut.green(), lut.blue()); 0055 return true; 0056 } 0057 0058 void X11Output::setCrtc(xcb_randr_crtc_t crtc) 0059 { 0060 m_crtc = crtc; 0061 } 0062 0063 void X11Output::setGammaRampSize(int size) 0064 { 0065 m_gammaRampSize = size; 0066 } 0067 0068 void X11Output::updateEnabled(bool enabled) 0069 { 0070 State next = m_state; 0071 next.enabled = enabled; 0072 setState(next); 0073 } 0074 0075 } // namespace KWin 0076 0077 #include "moc_x11_standalone_output.cpp"