Rename buffer-specific surface properties
The buffer scale and the buffer transform property specify transforms that had been applied to the buffer's contents. Neither one of those properties apply to the surface, in other words the buffer transform property doesn't indicate that the surface was rotated or flipped or both. This change doesn't gain anything in terms of new features, etc. It just attempts to make things more clear.
This commit is contained in:
parent
dd825dbfb3
commit
ecca34dea3
4 changed files with 60 additions and 60 deletions
|
@ -732,24 +732,24 @@ void TestWaylandSurface::testScale()
|
||||||
QVERIFY(serverSurfaceCreated.wait());
|
QVERIFY(serverSurfaceCreated.wait());
|
||||||
SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWaylandServer::SurfaceInterface*>();
|
SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWaylandServer::SurfaceInterface*>();
|
||||||
QVERIFY(serverSurface);
|
QVERIFY(serverSurface);
|
||||||
QCOMPARE(serverSurface->scale(), 1);
|
QCOMPARE(serverSurface->bufferScale(), 1);
|
||||||
|
|
||||||
// let's change the scale factor
|
// let's change the scale factor
|
||||||
QSignalSpy scaleChangedSpy(serverSurface, &SurfaceInterface::scaleChanged);
|
QSignalSpy bufferScaleChangedSpy(serverSurface, &SurfaceInterface::bufferScaleChanged);
|
||||||
|
|
||||||
//changing the scale implicitly changes the size
|
//changing the scale implicitly changes the size
|
||||||
QSignalSpy sizeChangedSpy(serverSurface, &SurfaceInterface::sizeChanged);
|
QSignalSpy sizeChangedSpy(serverSurface, &SurfaceInterface::sizeChanged);
|
||||||
|
|
||||||
QVERIFY(scaleChangedSpy.isValid());
|
QVERIFY(bufferScaleChangedSpy.isValid());
|
||||||
s->setScale(2);
|
s->setScale(2);
|
||||||
QCOMPARE(s->scale(), 2);
|
QCOMPARE(s->scale(), 2);
|
||||||
// needs a commit
|
// needs a commit
|
||||||
QVERIFY(!scaleChangedSpy.wait(100));
|
QVERIFY(!bufferScaleChangedSpy.wait(100));
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(scaleChangedSpy.wait());
|
QVERIFY(bufferScaleChangedSpy.wait());
|
||||||
QCOMPARE(scaleChangedSpy.count(), 1);
|
QCOMPARE(bufferScaleChangedSpy.count(), 1);
|
||||||
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
QCOMPARE(bufferScaleChangedSpy.first().first().toInt(), 2);
|
||||||
QCOMPARE(serverSurface->scale(), 2);
|
QCOMPARE(serverSurface->bufferScale(), 2);
|
||||||
|
|
||||||
//even though we've changed the scale, if we don't have a buffer we
|
//even though we've changed the scale, if we don't have a buffer we
|
||||||
//don't have a size. If we don't have a size it can't have changed
|
//don't have a size. If we don't have a size it can't have changed
|
||||||
|
@ -759,17 +759,17 @@ void TestWaylandSurface::testScale()
|
||||||
// let's try changing to same factor, should not emit changed on server
|
// let's try changing to same factor, should not emit changed on server
|
||||||
s->setScale(2);
|
s->setScale(2);
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(!scaleChangedSpy.wait(100));
|
QVERIFY(!bufferScaleChangedSpy.wait(100));
|
||||||
|
|
||||||
// but changing to a different value should still work
|
// but changing to a different value should still work
|
||||||
s->setScale(4);
|
s->setScale(4);
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(scaleChangedSpy.wait());
|
QVERIFY(bufferScaleChangedSpy.wait());
|
||||||
QCOMPARE(scaleChangedSpy.count(), 2);
|
QCOMPARE(bufferScaleChangedSpy.count(), 2);
|
||||||
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
QCOMPARE(bufferScaleChangedSpy.first().first().toInt(), 2);
|
||||||
QCOMPARE(scaleChangedSpy.last().first().toInt(), 4);
|
QCOMPARE(bufferScaleChangedSpy.last().first().toInt(), 4);
|
||||||
QCOMPARE(serverSurface->scale(), 4);
|
QCOMPARE(serverSurface->bufferScale(), 4);
|
||||||
scaleChangedSpy.clear();
|
bufferScaleChangedSpy.clear();
|
||||||
|
|
||||||
//attach a buffer of 100x100, our scale is 4, so this should be a size of 25x25
|
//attach a buffer of 100x100, our scale is 4, so this should be a size of 25x25
|
||||||
QImage red(100, 100, QImage::Format_ARGB32_Premultiplied);
|
QImage red(100, 100, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
@ -783,18 +783,18 @@ void TestWaylandSurface::testScale()
|
||||||
QCOMPARE(sizeChangedSpy.count(), 1);
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
QCOMPARE(serverSurface->size(), QSize(25,25));
|
QCOMPARE(serverSurface->size(), QSize(25,25));
|
||||||
sizeChangedSpy.clear();
|
sizeChangedSpy.clear();
|
||||||
scaleChangedSpy.clear();
|
bufferScaleChangedSpy.clear();
|
||||||
|
|
||||||
//set the scale to 1, buffer is still 100x100 so size should change to 100x100
|
//set the scale to 1, buffer is still 100x100 so size should change to 100x100
|
||||||
s->setScale(1);
|
s->setScale(1);
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(sizeChangedSpy.wait());
|
QVERIFY(sizeChangedSpy.wait());
|
||||||
QCOMPARE(sizeChangedSpy.count(), 1);
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
QCOMPARE(scaleChangedSpy.count(), 1);
|
QCOMPARE(bufferScaleChangedSpy.count(), 1);
|
||||||
QCOMPARE(serverSurface->scale(), 1);
|
QCOMPARE(serverSurface->bufferScale(), 1);
|
||||||
QCOMPARE(serverSurface->size(), QSize(100,100));
|
QCOMPARE(serverSurface->size(), QSize(100,100));
|
||||||
sizeChangedSpy.clear();
|
sizeChangedSpy.clear();
|
||||||
scaleChangedSpy.clear();
|
bufferScaleChangedSpy.clear();
|
||||||
|
|
||||||
//set scale and size in one commit, buffer is 50x50 at scale 2 so size should be 25x25
|
//set scale and size in one commit, buffer is 50x50 at scale 2 so size should be 25x25
|
||||||
QImage blue(50, 50, QImage::Format_ARGB32_Premultiplied);
|
QImage blue(50, 50, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
@ -806,8 +806,8 @@ void TestWaylandSurface::testScale()
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
QVERIFY(sizeChangedSpy.wait());
|
QVERIFY(sizeChangedSpy.wait());
|
||||||
QCOMPARE(sizeChangedSpy.count(), 1);
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
QCOMPARE(scaleChangedSpy.count(), 1);
|
QCOMPARE(bufferScaleChangedSpy.count(), 1);
|
||||||
QCOMPARE(serverSurface->scale(), 2);
|
QCOMPARE(serverSurface->bufferScale(), 2);
|
||||||
QCOMPARE(serverSurface->size(), QSize(25,25));
|
QCOMPARE(serverSurface->size(), QSize(25,25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,14 +856,14 @@ void TestWaylandSurface::testUnmapOfNotMappedSurface()
|
||||||
|
|
||||||
QSignalSpy unmappedSpy(serverSurface, &SurfaceInterface::unmapped);
|
QSignalSpy unmappedSpy(serverSurface, &SurfaceInterface::unmapped);
|
||||||
QVERIFY(unmappedSpy.isValid());
|
QVERIFY(unmappedSpy.isValid());
|
||||||
QSignalSpy scaleChanged(serverSurface, &SurfaceInterface::scaleChanged);
|
QSignalSpy bufferScaleChanged(serverSurface, &SurfaceInterface::bufferScaleChanged);
|
||||||
|
|
||||||
// let's map a null buffer and change scale to trigger a signal we can wait for
|
// let's map a null buffer and change scale to trigger a signal we can wait for
|
||||||
s->attachBuffer(Buffer::Ptr());
|
s->attachBuffer(Buffer::Ptr());
|
||||||
s->setScale(2);
|
s->setScale(2);
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
|
|
||||||
QVERIFY(scaleChanged.wait());
|
QVERIFY(bufferScaleChanged.wait());
|
||||||
QVERIFY(unmappedSpy.isEmpty());
|
QVERIFY(unmappedSpy.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,39 +325,39 @@ QMatrix4x4 SurfaceInterface::Private::buildSurfaceToBufferMatrix(const State *st
|
||||||
return surfaceToBufferMatrix;
|
return surfaceToBufferMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceToBufferMatrix.scale(state->scale, state->scale);
|
surfaceToBufferMatrix.scale(state->bufferScale, state->bufferScale);
|
||||||
|
|
||||||
switch (state->transform) {
|
switch (state->bufferTransform) {
|
||||||
case OutputInterface::Transform::Normal:
|
case OutputInterface::Transform::Normal:
|
||||||
case OutputInterface::Transform::Flipped:
|
case OutputInterface::Transform::Flipped:
|
||||||
break;
|
break;
|
||||||
case OutputInterface::Transform::Rotated90:
|
case OutputInterface::Transform::Rotated90:
|
||||||
case OutputInterface::Transform::Flipped90:
|
case OutputInterface::Transform::Flipped90:
|
||||||
surfaceToBufferMatrix.translate(0, state->buffer->height() / state->scale);
|
surfaceToBufferMatrix.translate(0, state->buffer->height() / state->bufferScale);
|
||||||
surfaceToBufferMatrix.rotate(-90, 0, 0, 1);
|
surfaceToBufferMatrix.rotate(-90, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case OutputInterface::Transform::Rotated180:
|
case OutputInterface::Transform::Rotated180:
|
||||||
case OutputInterface::Transform::Flipped180:
|
case OutputInterface::Transform::Flipped180:
|
||||||
surfaceToBufferMatrix.translate(state->buffer->width() / state->scale,
|
surfaceToBufferMatrix.translate(state->buffer->width() / state->bufferScale,
|
||||||
state->buffer->height() / state->scale);
|
state->buffer->height() / state->bufferScale);
|
||||||
surfaceToBufferMatrix.rotate(-180, 0, 0, 1);
|
surfaceToBufferMatrix.rotate(-180, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case OutputInterface::Transform::Rotated270:
|
case OutputInterface::Transform::Rotated270:
|
||||||
case OutputInterface::Transform::Flipped270:
|
case OutputInterface::Transform::Flipped270:
|
||||||
surfaceToBufferMatrix.translate(state->buffer->width() / state->scale, 0);
|
surfaceToBufferMatrix.translate(state->buffer->width() / state->bufferScale, 0);
|
||||||
surfaceToBufferMatrix.rotate(-270, 0, 0, 1);
|
surfaceToBufferMatrix.rotate(-270, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (current.transform) {
|
switch (state->bufferTransform) {
|
||||||
case OutputInterface::Transform::Flipped:
|
case OutputInterface::Transform::Flipped:
|
||||||
case OutputInterface::Transform::Flipped180:
|
case OutputInterface::Transform::Flipped180:
|
||||||
surfaceToBufferMatrix.translate(state->buffer->width() / state->scale, 0);
|
surfaceToBufferMatrix.translate(state->buffer->width() / state->bufferScale, 0);
|
||||||
surfaceToBufferMatrix.scale(-1, 1);
|
surfaceToBufferMatrix.scale(-1, 1);
|
||||||
break;
|
break;
|
||||||
case OutputInterface::Transform::Flipped90:
|
case OutputInterface::Transform::Flipped90:
|
||||||
case OutputInterface::Transform::Flipped270:
|
case OutputInterface::Transform::Flipped270:
|
||||||
surfaceToBufferMatrix.translate(state->buffer->height() / state->scale, 0);
|
surfaceToBufferMatrix.translate(state->buffer->height() / state->bufferScale, 0);
|
||||||
surfaceToBufferMatrix.scale(-1, 1);
|
surfaceToBufferMatrix.scale(-1, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -379,8 +379,8 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
|
||||||
const bool bufferChanged = source->bufferIsSet;
|
const bool bufferChanged = source->bufferIsSet;
|
||||||
const bool opaqueRegionChanged = source->opaqueIsSet;
|
const bool opaqueRegionChanged = source->opaqueIsSet;
|
||||||
const bool inputRegionChanged = source->inputIsSet;
|
const bool inputRegionChanged = source->inputIsSet;
|
||||||
const bool scaleFactorChanged = source->scaleIsSet && (target->scale != source->scale);
|
const bool scaleFactorChanged = source->bufferScaleIsSet && (target->bufferScale != source->bufferScale);
|
||||||
const bool transformChanged = source->transformIsSet && (target->transform != source->transform);
|
const bool transformChanged = source->bufferTransformIsSet && (target->bufferTransform != source->bufferTransform);
|
||||||
const bool shadowChanged = source->shadowIsSet;
|
const bool shadowChanged = source->shadowIsSet;
|
||||||
const bool blurChanged = source->blurIsSet;
|
const bool blurChanged = source->blurIsSet;
|
||||||
const bool contrastChanged = source->contrastIsSet;
|
const bool contrastChanged = source->contrastIsSet;
|
||||||
|
@ -450,12 +450,12 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
|
||||||
target->opaqueIsSet = true;
|
target->opaqueIsSet = true;
|
||||||
}
|
}
|
||||||
if (scaleFactorChanged) {
|
if (scaleFactorChanged) {
|
||||||
target->scale = source->scale;
|
target->bufferScale = source->bufferScale;
|
||||||
target->scaleIsSet = true;
|
target->bufferScaleIsSet = true;
|
||||||
}
|
}
|
||||||
if (transformChanged) {
|
if (transformChanged) {
|
||||||
target->transform = source->transform;
|
target->bufferTransform = source->bufferTransform;
|
||||||
target->transformIsSet = true;
|
target->bufferTransformIsSet = true;
|
||||||
}
|
}
|
||||||
if (!lockedPointer.isNull()) {
|
if (!lockedPointer.isNull()) {
|
||||||
lockedPointer->d_func()->commit();
|
lockedPointer->d_func()->commit();
|
||||||
|
@ -477,8 +477,8 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
|
||||||
} else if (target->sourceGeometry.isValid()) {
|
} else if (target->sourceGeometry.isValid()) {
|
||||||
target->size = target->sourceGeometry.size().toSize();
|
target->size = target->sourceGeometry.size().toSize();
|
||||||
} else {
|
} else {
|
||||||
target->size = target->buffer->size() / target->scale;
|
target->size = target->buffer->size() / target->bufferScale;
|
||||||
switch (target->transform) {
|
switch (target->bufferTransform) {
|
||||||
case OutputInterface::Transform::Rotated90:
|
case OutputInterface::Transform::Rotated90:
|
||||||
case OutputInterface::Transform::Rotated270:
|
case OutputInterface::Transform::Rotated270:
|
||||||
case OutputInterface::Transform::Flipped90:
|
case OutputInterface::Transform::Flipped90:
|
||||||
|
@ -504,10 +504,10 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
|
||||||
emit q->inputChanged(target->input);
|
emit q->inputChanged(target->input);
|
||||||
}
|
}
|
||||||
if (scaleFactorChanged) {
|
if (scaleFactorChanged) {
|
||||||
emit q->scaleChanged(target->scale);
|
emit q->bufferScaleChanged(target->bufferScale);
|
||||||
}
|
}
|
||||||
if (transformChanged) {
|
if (transformChanged) {
|
||||||
emit q->transformChanged(target->transform);
|
emit q->bufferTransformChanged(target->bufferTransform);
|
||||||
}
|
}
|
||||||
if (visibilityChanged) {
|
if (visibilityChanged) {
|
||||||
if (target->buffer) {
|
if (target->buffer) {
|
||||||
|
@ -612,14 +612,14 @@ void SurfaceInterface::Private::damageBuffer(const QRect &rect)
|
||||||
|
|
||||||
void SurfaceInterface::Private::setScale(qint32 scale)
|
void SurfaceInterface::Private::setScale(qint32 scale)
|
||||||
{
|
{
|
||||||
pending.scale = scale;
|
pending.bufferScale = scale;
|
||||||
pending.scaleIsSet = true;
|
pending.bufferScaleIsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceInterface::Private::setTransform(OutputInterface::Transform transform)
|
void SurfaceInterface::Private::setTransform(OutputInterface::Transform transform)
|
||||||
{
|
{
|
||||||
pending.transform = transform;
|
pending.bufferTransform = transform;
|
||||||
pending.transformIsSet = true;
|
pending.bufferTransformIsSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceInterface::Private::addFrameCallback(uint32_t callback)
|
void SurfaceInterface::Private::addFrameCallback(uint32_t callback)
|
||||||
|
@ -769,16 +769,16 @@ bool SurfaceInterface::inputIsInfinite() const
|
||||||
return d->current.inputIsInfinite;
|
return d->current.inputIsInfinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 SurfaceInterface::scale() const
|
qint32 SurfaceInterface::bufferScale() const
|
||||||
{
|
{
|
||||||
Q_D();
|
Q_D();
|
||||||
return d->current.scale;
|
return d->current.bufferScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputInterface::Transform SurfaceInterface::transform() const
|
OutputInterface::Transform SurfaceInterface::bufferTransform() const
|
||||||
{
|
{
|
||||||
Q_D();
|
Q_D();
|
||||||
return d->current.transform;
|
return d->current.bufferTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferInterface *SurfaceInterface::buffer()
|
BufferInterface *SurfaceInterface::buffer()
|
||||||
|
|
|
@ -73,8 +73,8 @@ class KWAYLANDSERVER_EXPORT SurfaceInterface : public Resource
|
||||||
* The current input region.
|
* The current input region.
|
||||||
**/
|
**/
|
||||||
Q_PROPERTY(QRegion input READ input NOTIFY inputChanged)
|
Q_PROPERTY(QRegion input READ input NOTIFY inputChanged)
|
||||||
Q_PROPERTY(qint32 scale READ scale NOTIFY scaleChanged)
|
Q_PROPERTY(qint32 bufferScale READ bufferScale NOTIFY bufferScaleChanged)
|
||||||
Q_PROPERTY(KWaylandServer::OutputInterface::Transform transform READ transform NOTIFY transformChanged)
|
Q_PROPERTY(KWaylandServer::OutputInterface::Transform bufferTransform READ bufferTransform NOTIFY bufferTransformChanged)
|
||||||
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
|
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
|
||||||
public:
|
public:
|
||||||
virtual ~SurfaceInterface();
|
virtual ~SurfaceInterface();
|
||||||
|
@ -145,8 +145,8 @@ public:
|
||||||
QRegion opaque() const;
|
QRegion opaque() const;
|
||||||
QRegion input() const;
|
QRegion input() const;
|
||||||
bool inputIsInfinite() const;
|
bool inputIsInfinite() const;
|
||||||
qint32 scale() const;
|
qint32 bufferScale() const;
|
||||||
OutputInterface::Transform transform() const;
|
OutputInterface::Transform bufferTransform() const;
|
||||||
/**
|
/**
|
||||||
* @returns the current BufferInterface, might be @c nullptr.
|
* @returns the current BufferInterface, might be @c nullptr.
|
||||||
**/
|
**/
|
||||||
|
@ -357,11 +357,11 @@ Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted when the scale of the attached buffer has changed.
|
* This signal is emitted when the scale of the attached buffer has changed.
|
||||||
*/
|
*/
|
||||||
void scaleChanged(qint32);
|
void bufferScaleChanged(qint32);
|
||||||
/**
|
/**
|
||||||
* This signal is emitted when the buffer transform has changed.
|
* This signal is emitted when the buffer transform has changed.
|
||||||
*/
|
*/
|
||||||
void transformChanged(KWaylandServer::OutputInterface::Transform);
|
void bufferTransformChanged(KWaylandServer::OutputInterface::Transform);
|
||||||
/**
|
/**
|
||||||
* Emitted when the Surface becomes visible, i.e. a non-null buffer has been attached.
|
* Emitted when the Surface becomes visible, i.e. a non-null buffer has been attached.
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -43,10 +43,10 @@ public:
|
||||||
bool slideIsSet = false;
|
bool slideIsSet = false;
|
||||||
bool inputIsInfinite = true;
|
bool inputIsInfinite = true;
|
||||||
bool childrenChanged = false;
|
bool childrenChanged = false;
|
||||||
bool scaleIsSet = false;
|
bool bufferScaleIsSet = false;
|
||||||
bool transformIsSet = false;
|
bool bufferTransformIsSet = false;
|
||||||
qint32 scale = 1;
|
qint32 bufferScale = 1;
|
||||||
OutputInterface::Transform transform = OutputInterface::Transform::Normal;
|
OutputInterface::Transform bufferTransform = OutputInterface::Transform::Normal;
|
||||||
QList<wl_resource*> callbacks = QList<wl_resource*>();
|
QList<wl_resource*> callbacks = QList<wl_resource*>();
|
||||||
QPoint offset = QPoint();
|
QPoint offset = QPoint();
|
||||||
BufferInterface *buffer = nullptr;
|
BufferInterface *buffer = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue