[server] Use cached current mode more and assert validness
Summary: We can use the cached current mode in one more case. Additionally make it more explicit what a valid mode is and when to add them. Test Plan: Relevant autotests pass. KWin Wayland nested and DRM session work. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D23535
This commit is contained in:
parent
77730f7fa7
commit
b8c28c8a85
2 changed files with 11 additions and 6 deletions
|
@ -136,12 +136,9 @@ OutputDeviceInterface::OutputDeviceInterface(Display *display, QObject *parent)
|
||||||
Q_D();
|
Q_D();
|
||||||
connect(this, &OutputDeviceInterface::currentModeChanged, this,
|
connect(this, &OutputDeviceInterface::currentModeChanged, this,
|
||||||
[this, d] {
|
[this, d] {
|
||||||
auto currentModeIt = std::find_if(d->modes.constBegin(), d->modes.constEnd(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); });
|
Q_ASSERT(d->currentMode.id >= 0);
|
||||||
if (currentModeIt == d->modes.constEnd()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
|
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
|
||||||
d->sendMode((*it).resource, *currentModeIt);
|
d->sendMode((*it).resource, d->currentMode);
|
||||||
d->sendDone(*it);
|
d->sendDone(*it);
|
||||||
}
|
}
|
||||||
wl_display_flush_clients(*(d->display));
|
wl_display_flush_clients(*(d->display));
|
||||||
|
@ -187,9 +184,10 @@ int OutputDeviceInterface::refreshRate() const
|
||||||
void OutputDeviceInterface::addMode(Mode &mode)
|
void OutputDeviceInterface::addMode(Mode &mode)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!isValid());
|
Q_ASSERT(!isValid());
|
||||||
|
Q_ASSERT(mode.id >= 0);
|
||||||
|
Q_ASSERT(mode.size.isValid());
|
||||||
Q_D();
|
Q_D();
|
||||||
|
|
||||||
|
|
||||||
auto currentModeIt = std::find_if(d->modes.begin(), d->modes.end(),
|
auto currentModeIt = std::find_if(d->modes.begin(), d->modes.end(),
|
||||||
[](const Mode &mode) {
|
[](const Mode &mode) {
|
||||||
return mode.flags.testFlag(ModeFlag::Current);
|
return mode.flags.testFlag(ModeFlag::Current);
|
||||||
|
|
|
@ -132,6 +132,13 @@ public:
|
||||||
void setSubPixel(SubPixel subPixel);
|
void setSubPixel(SubPixel subPixel);
|
||||||
void setTransform(Transform transform);
|
void setTransform(Transform transform);
|
||||||
void setColorCurves(const ColorCurves &colorCurves);
|
void setColorCurves(const ColorCurves &colorCurves);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an additional mode to this output device. This is only allowed before create() is called
|
||||||
|
* on the object.
|
||||||
|
*
|
||||||
|
* @param mode must have a valid size and non-negative id.
|
||||||
|
*/
|
||||||
void addMode(Mode &mode);
|
void addMode(Mode &mode);
|
||||||
void setCurrentMode(const int modeId);
|
void setCurrentMode(const int modeId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue