output protocols: add rgb range setting

This commit is contained in:
Xaver Hugl 2021-08-31 03:05:18 +02:00
parent a9458fa031
commit e31d10c18d
6 changed files with 72 additions and 0 deletions

View file

@ -111,4 +111,13 @@ OutputDeviceV2Interface::VrrPolicy OutputChangeSetV2::vrrPolicy() const
return d->vrrPolicy;
}
bool OutputChangeSetV2::rgbRangeChanged() const
{
return d->rgbRange != d->outputDevice->rgbRange();
}
OutputDeviceV2Interface::RgbRange OutputChangeSetV2::rgbRange() const
{
return d->rgbRange;
}
}

View file

@ -72,6 +72,12 @@ public:
*/
bool vrrPolicyChanged() const;
/**
* Whether the rgbRange() property of the outputdevice changed.
* @returns @c true if the rgbRange() property of the outputdevice has changed.
*/
bool rgbRangeChanged() const;
/** The new value for enabled. */
bool enabled() const;
@ -97,6 +103,9 @@ public:
/** The new value for vrrPolicy */
OutputDeviceV2Interface::VrrPolicy vrrPolicy() const;
/** The new value for rgbRange */
OutputDeviceV2Interface::RgbRange rgbRange() const;
private:
friend class OutputConfigurationV2InterfacePrivate;
explicit OutputChangeSetV2(OutputDeviceV2Interface *outputdevice, QObject *parent = nullptr);

View file

@ -26,6 +26,7 @@ public:
qreal scale;
uint32_t overscan;
OutputDeviceV2Interface::VrrPolicy vrrPolicy = OutputDeviceV2Interface::VrrPolicy::Automatic;
OutputDeviceV2Interface::RgbRange rgbRange = OutputDeviceV2Interface::RgbRange::Automatic;
};
}

View file

@ -44,6 +44,7 @@ protected:
void kde_output_configuration_v2_destroy_resource(Resource *resource) override;
void kde_output_configuration_v2_overscan(Resource *resource, wl_resource *outputdevice, uint32_t overscan) override;
void kde_output_configuration_v2_set_vrr_policy(Resource *resource, struct ::wl_resource *outputdevice, uint32_t policy) override;
void kde_output_configuration_v2_set_rgb_range(Resource *resource, wl_resource *outputdevice, uint32_t rgbRange) override;
};
void OutputConfigurationV2InterfacePrivate::kde_output_configuration_v2_enable(Resource *resource, wl_resource *outputdevice, int32_t enable)
@ -143,6 +144,17 @@ void OutputConfigurationV2InterfacePrivate::kde_output_configuration_v2_set_vrr_
pendingChanges(output)->d->vrrPolicy = static_cast<OutputDeviceV2Interface::VrrPolicy>(policy);
}
void OutputConfigurationV2InterfacePrivate::kde_output_configuration_v2_set_rgb_range(Resource *resource, wl_resource *outputdevice, uint32_t rgbRange)
{
Q_UNUSED(resource)
if (rgbRange > static_cast<uint32_t>(OutputDeviceV2Interface::RgbRange::Limited)) {
qCWarning(KWAYLAND_SERVER) << "Invalid Rgb Range requested:" << rgbRange;
return;
}
OutputDeviceV2Interface *output = OutputDeviceV2Interface::get(outputdevice);
pendingChanges(output)->d->rgbRange = static_cast<OutputDeviceV2Interface::RgbRange>(rgbRange);
}
void OutputConfigurationV2InterfacePrivate::kde_output_configuration_v2_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);

View file

@ -38,6 +38,7 @@ public:
void updateCapabilities();
void updateOverscan();
void updateVrrPolicy();
void updateRgbRange();
void sendGeometry(Resource *resource);
wl_resource *sendNewMode(Resource *resource, OutputDeviceModeV2Interface *mode);
@ -52,6 +53,7 @@ public:
void sendCapabilities(Resource *resource);
void sendOverscan(Resource *resource);
void sendVrrPolicy(Resource *resource);
void sendRgbRange(Resource *resource);
QSize physicalSize;
QPoint globalPosition;
@ -72,6 +74,7 @@ public:
OutputDeviceV2Interface::Capabilities capabilities;
uint32_t overscan = 0;
OutputDeviceV2Interface::VrrPolicy vrrPolicy = OutputDeviceV2Interface::VrrPolicy::Automatic;
OutputDeviceV2Interface::RgbRange rgbRange = OutputDeviceV2Interface::RgbRange::Automatic;
QPointer<Display> display;
OutputDeviceV2Interface *q;
@ -701,6 +704,33 @@ void OutputDeviceV2InterfacePrivate::updateVrrPolicy()
}
}
OutputDeviceV2Interface::RgbRange OutputDeviceV2Interface::rgbRange() const
{
return d->rgbRange;
}
void OutputDeviceV2Interface::setRgbRange(RgbRange rgbRange)
{
if (d->rgbRange != rgbRange) {
d->rgbRange = rgbRange;
d->updateRgbRange();
Q_EMIT rgbRangeChanged();
}
}
void OutputDeviceV2InterfacePrivate::sendRgbRange(Resource *resource)
{
send_rgb_range(resource->handle, static_cast<uint32_t>(rgbRange));
}
void OutputDeviceV2InterfacePrivate::updateRgbRange()
{
const auto clientResources = resourceMap();
for (const auto &resource : clientResources) {
sendRgbRange(resource);
}
}
OutputDeviceV2Interface *OutputDeviceV2Interface::get(wl_resource *native)
{
if (auto devicePrivate = resource_cast<OutputDeviceV2InterfacePrivate *>(native)) {

View file

@ -48,6 +48,7 @@ class KWAYLANDSERVER_EXPORT OutputDeviceV2Interface : public QObject
Q_PROPERTY(Capabilities capabilities READ capabilities WRITE setCapabilities NOTIFY capabilitiesChanged)
Q_PROPERTY(uint32_t overscan READ overscan WRITE setOverscan NOTIFY overscanChanged)
Q_PROPERTY(VrrPolicy vrrPolicy READ vrrPolicy WRITE setVrrPolicy NOTIFY vrrPolicyChanged)
Q_PROPERTY(RgbRange rgbRange READ rgbRange WRITE setRgbRange NOTIFY rgbRangeChanged)
public:
enum class SubPixel {
Unknown,
@ -72,6 +73,7 @@ public:
enum class Capability {
Overscan = 0x1,
Vrr = 0x2,
RgbRange = 0x4,
};
Q_ENUM(Capability)
Q_DECLARE_FLAGS(Capabilities, Capability)
@ -81,6 +83,12 @@ public:
Automatic = 2
};
Q_ENUM(VrrPolicy)
enum class RgbRange {
Automatic = 0,
Full = 1,
Limited = 2,
};
Q_ENUM(RgbRange)
explicit OutputDeviceV2Interface(Display *display, QObject *parent = nullptr);
~OutputDeviceV2Interface() override;
@ -107,6 +115,7 @@ public:
Capabilities capabilities() const;
uint32_t overscan() const;
VrrPolicy vrrPolicy() const;
RgbRange rgbRange() const;
void setPhysicalSize(const QSize &size);
void setGlobalPosition(const QPoint &pos);
@ -135,6 +144,7 @@ public:
void setCapabilities(Capabilities cap);
void setOverscan(uint32_t overscan);
void setVrrPolicy(VrrPolicy policy);
void setRgbRange(RgbRange rgbRange);
static OutputDeviceV2Interface *get(wl_resource *native);
@ -158,6 +168,7 @@ Q_SIGNALS:
void capabilitiesChanged();
void overscanChanged();
void vrrPolicyChanged();
void rgbRangeChanged();
private:
QScopedPointer<OutputDeviceV2InterfacePrivate> d;