diff --git a/abstract_output.cpp b/abstract_output.cpp index 94d828285..d7db2af0d 100644 --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -1,76 +1,107 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2018 Roman Gilg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "abstract_output.h" namespace KWin { GammaRamp::GammaRamp(uint32_t size) : m_table(3 * size) , m_size(size) { } uint32_t GammaRamp::size() const { return m_size; } uint16_t *GammaRamp::red() { return m_table.data(); } const uint16_t *GammaRamp::red() const { return m_table.data(); } uint16_t *GammaRamp::green() { return m_table.data() + m_size; } const uint16_t *GammaRamp::green() const { return m_table.data() + m_size; } uint16_t *GammaRamp::blue() { return m_table.data() + 2 * m_size; } const uint16_t *GammaRamp::blue() const { return m_table.data() + 2 * m_size; } AbstractOutput::AbstractOutput(QObject *parent) : QObject(parent) { } AbstractOutput::~AbstractOutput() { } +bool AbstractOutput::isInternal() const +{ + return false; } + +qreal AbstractOutput::scale() const +{ + return 1; +} + +QSize AbstractOutput::physicalSize() const +{ + return QSize(); +} + +Qt::ScreenOrientation AbstractOutput::orientation() const +{ + return Qt::PrimaryOrientation; +} + +int AbstractOutput::gammaRampSize() const +{ + return 0; +} + +bool AbstractOutput::setGammaRamp(const GammaRamp &gamma) +{ + Q_UNUSED(gamma); + return false; +} + +} // namespace KWin diff --git a/abstract_output.h b/abstract_output.h index 151febc7e..4164371ad 100644 --- a/abstract_output.h +++ b/abstract_output.h @@ -1,129 +1,162 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #ifndef KWIN_ABSTRACT_OUTPUT_H #define KWIN_ABSTRACT_OUTPUT_H #include #include #include #include #include namespace KWin { class KWIN_EXPORT GammaRamp { public: GammaRamp(uint32_t size); /** * Returns the size of the gamma ramp. **/ uint32_t size() const; /** * Returns pointer to the first red component in the gamma ramp. * * The returned pointer can be used for altering the red component * in the gamma ramp. **/ uint16_t *red(); /** * Returns pointer to the first red component in the gamma ramp. **/ const uint16_t *red() const; /** * Returns pointer to the first green component in the gamma ramp. * * The returned pointer can be used for altering the green component * in the gamma ramp. **/ uint16_t *green(); /** * Returns pointer to the first green component in the gamma ramp. **/ const uint16_t *green() const; /** * Returns pointer to the first blue component in the gamma ramp. * * The returned pointer can be used for altering the blue component * in the gamma ramp. **/ uint16_t *blue(); /** * Returns pointer to the first blue component in the gamma ramp. **/ const uint16_t *blue() const; private: QVector m_table; uint32_t m_size; }; /** - * Generic output representation in a Wayland session + * Generic output representation. **/ class KWIN_EXPORT AbstractOutput : public QObject { Q_OBJECT + public: explicit AbstractOutput(QObject *parent = nullptr); - virtual ~AbstractOutput(); + ~AbstractOutput() override; + /** + * Returns the human readable name of this output. + **/ virtual QString name() const = 0; + + /** + * Returns geometry of this output in device independent pixels. + **/ virtual QRect geometry() const = 0; /** - * Current refresh rate in 1/ms. + * Returns the approximate vertical refresh rate of this output, in mHz. **/ virtual int refreshRate() const = 0; - virtual bool isInternal() const { - return false; - } - virtual qreal scale() const { - return 1.; - } - virtual QSize physicalSize() const { - return QSize(); - } - virtual Qt::ScreenOrientation orientation() const { - return Qt::PrimaryOrientation; - } - - virtual int gammaRampSize() const { - return 0; - } - virtual bool setGammaRamp(const GammaRamp &gamma) { - Q_UNUSED(gamma); - return false; - } + /** + * Returns whether this output is connected through an internal connector, + * e.g. LVDS, or eDP. + * + * Default implementation returns @c false. + **/ + virtual bool isInternal() const; + + /** + * Returns the ratio between physical pixels and logical pixels. + * + * Default implementation returns 1. + **/ + virtual qreal scale() const; + + /** + * Returns the physical size of this output, in millimeters. + * + * Default implementation returns an invalid QSize. + **/ + virtual QSize physicalSize() const; + + /** + * Returns the orientation of this output. + * + * Default implementation returns Qt::PrimaryOrientation. + **/ + virtual Qt::ScreenOrientation orientation() const; + + /** + * Returns the size of the gamma lookup table. + * + * Default implementation returns 0. + **/ + virtual int gammaRampSize() const; + + /** + * Sets the gamma ramp of this output. + * + * Returns @c true if the gamma ramp was successfully set. + **/ + virtual bool setGammaRamp(const GammaRamp &gamma); + +private: + Q_DISABLE_COPY(AbstractOutput) }; -} +} // namespace KWin #endif