Commit 47f80b99 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Vlad Zahorodnii
Browse files

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.
parent d2b80df4
......@@ -732,24 +732,24 @@ void TestWaylandSurface::testScale()
QVERIFY(serverSurfaceCreated.wait());
SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWaylandServer::SurfaceInterface*>();
QVERIFY(serverSurface);
QCOMPARE(serverSurface->scale(), 1);
QCOMPARE(serverSurface->bufferScale(), 1);
// let's change the scale factor
QSignalSpy scaleChangedSpy(serverSurface, &SurfaceInterface::scaleChanged);
QSignalSpy bufferScaleChangedSpy(serverSurface, &SurfaceInterface::bufferScaleChanged);
//changing the scale implicitly changes the size
QSignalSpy sizeChangedSpy(serverSurface, &SurfaceInterface::sizeChanged);
QVERIFY(scaleChangedSpy.isValid());
QVERIFY(bufferScaleChangedSpy.isValid());
s->setScale(2);
QCOMPARE(s->scale(), 2);
// needs a commit
QVERIFY(!scaleChangedSpy.wait(100));
QVERIFY(!bufferScaleChangedSpy.wait(100));
s->commit(Surface::CommitFlag::None);
QVERIFY(scaleChangedSpy.wait());
QCOMPARE(scaleChangedSpy.count(), 1);
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
QCOMPARE(serverSurface->scale(), 2);
QVERIFY(bufferScaleChangedSpy.wait());
QCOMPARE(bufferScaleChangedSpy.count(), 1);
QCOMPARE(bufferScaleChangedSpy.first().first().toInt(), 2);
QCOMPARE(serverSurface->bufferScale(), 2);
//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
......@@ -759,17 +759,17 @@ void TestWaylandSurface::testScale()
// let's try changing to same factor, should not emit changed on server
s->setScale(2);
s->commit(Surface::CommitFlag::None);
QVERIFY(!scaleChangedSpy.wait(100));
QVERIFY(!bufferScaleChangedSpy.wait(100));
// but changing to a different value should still work
s->setScale(4);
s->commit(Surface::CommitFlag::None);
QVERIFY(scaleChangedSpy.wait());
QCOMPARE(scaleChangedSpy.count(), 2);
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
QCOMPARE(scaleChangedSpy.last().first().toInt(), 4);
QCOMPARE(serverSurface->scale(), 4);
scaleChangedSpy.clear();
QVERIFY(bufferScaleChangedSpy.wait());
QCOMPARE(bufferScaleChangedSpy.count(), 2);
QCOMPARE(bufferScaleChangedSpy.first().first().toInt(), 2);
QCOMPARE(bufferScaleChangedSpy.last().first().toInt(), 4);
QCOMPARE(serverSurface->bufferScale(), 4);
bufferScaleChangedSpy.clear();
//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);
......@@ -783,18 +783,18 @@ void TestWaylandSurface::testScale()
QCOMPARE(sizeChangedSpy.count(), 1);
QCOMPARE(serverSurface->size(), QSize(25,25));
sizeChangedSpy.clear();
scaleChangedSpy.clear();
bufferScaleChangedSpy.clear();
//set the scale to 1, buffer is still 100x100 so size should change to 100x100
s->setScale(1);
s->commit(Surface::CommitFlag::None);
QVERIFY(sizeChangedSpy.wait());
QCOMPARE(sizeChangedSpy.count(), 1);
QCOMPARE(scaleChangedSpy.count(), 1);
QCOMPARE(serverSurface->scale(), 1);
QCOMPARE(bufferScaleChangedSpy.count(), 1);
QCOMPARE(serverSurface->bufferScale(), 1);
QCOMPARE(serverSurface->size(), QSize(100,100));
sizeChangedSpy.clear();
scaleChangedSpy.clear();
bufferScaleChangedSpy.clear();
//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);
......@@ -806,8 +806,8 @@ void TestWaylandSurface::testScale()
s->commit(Surface::CommitFlag::None);
QVERIFY(sizeChangedSpy.wait());
QCOMPARE(sizeChangedSpy.count(), 1);
QCOMPARE(scaleChangedSpy.count(), 1);
QCOMPARE(serverSurface->scale(), 2);
QCOMPARE(bufferScaleChangedSpy.count(), 1);
QCOMPARE(serverSurface->bufferScale(), 2);
QCOMPARE(serverSurface->size(), QSize(25,25));
}
......@@ -856,14 +856,14 @@ void TestWaylandSurface::testUnmapOfNotMappedSurface()
QSignalSpy unmappedSpy(serverSurface, &SurfaceInterface::unmapped);
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
s->attachBuffer(Buffer::Ptr());
s->setScale(2);
s->commit(Surface::CommitFlag::None);
QVERIFY(scaleChanged.wait());
QVERIFY(bufferScaleChanged.wait());
QVERIFY(unmappedSpy.isEmpty());
}
......
......@@ -325,39 +325,39 @@ QMatrix4x4 SurfaceInterface::Private::buildSurfaceToBufferMatrix(const State *st
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::Flipped:
break;
case OutputInterface::Transform::Rotated90:
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);
break;
case OutputInterface::Transform::Rotated180:
case OutputInterface::Transform::Flipped180:
surfaceToBufferMatrix.translate(state->buffer->width() / state->scale,
state->buffer->height() / state->scale);
surfaceToBufferMatrix.translate(state->buffer->width() / state->bufferScale,
state->buffer->height() / state->bufferScale);
surfaceToBufferMatrix.rotate(-180, 0, 0, 1);
break;
case OutputInterface::Transform::Rotated270:
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);
break;
}
switch (current.transform) {
switch (state->bufferTransform) {
case OutputInterface::Transform::Flipped:
case OutputInterface::Transform::Flipped180:
surfaceToBufferMatrix.translate(state->buffer->width() / state->scale, 0);
surfaceToBufferMatrix.translate(state->buffer->width() / state->bufferScale, 0);
surfaceToBufferMatrix.scale(-1, 1);
break;
case OutputInterface::Transform::Flipped90:
case OutputInterface::Transform::Flipped270:
surfaceToBufferMatrix.translate(state->buffer->height() / state->scale, 0);
surfaceToBufferMatrix.translate(state->buffer->height() / state->bufferScale, 0);
surfaceToBufferMatrix.scale(-1, 1);
break;
default:
......@@ -379,8 +379,8 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
const bool bufferChanged = source->bufferIsSet;
const bool opaqueRegionChanged = source->opaqueIsSet;
const bool inputRegionChanged = source->inputIsSet;
const bool scaleFactorChanged = source->scaleIsSet && (target->scale != source->scale);
const bool transformChanged = source->transformIsSet && (target->transform != source->transform);
const bool scaleFactorChanged = source->bufferScaleIsSet && (target->bufferScale != source->bufferScale);
const bool transformChanged = source->bufferTransformIsSet && (target->bufferTransform != source->bufferTransform);
const bool shadowChanged = source->shadowIsSet;
const bool blurChanged = source->blurIsSet;
const bool contrastChanged = source->contrastIsSet;
......@@ -450,12 +450,12 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
target->opaqueIsSet = true;
}
if (scaleFactorChanged) {
target->scale = source->scale;
target->scaleIsSet = true;
target->bufferScale = source->bufferScale;
target->bufferScaleIsSet = true;
}
if (transformChanged) {
target->transform = source->transform;
target->transformIsSet = true;
target->bufferTransform = source->bufferTransform;
target->bufferTransformIsSet = true;
}
if (!lockedPointer.isNull()) {
lockedPointer->d_func()->commit();
......@@ -477,8 +477,8 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
} else if (target->sourceGeometry.isValid()) {
target->size = target->sourceGeometry.size().toSize();
} else {
target->size = target->buffer->size() / target->scale;
switch (target->transform) {
target->size = target->buffer->size() / target->bufferScale;
switch (target->bufferTransform) {
case OutputInterface::Transform::Rotated90:
case OutputInterface::Transform::Rotated270:
case OutputInterface::Transform::Flipped90:
......@@ -504,10 +504,10 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
emit q->inputChanged(target->input);
}
if (scaleFactorChanged) {
emit q->scaleChanged(target->scale);
emit q->bufferScaleChanged(target->bufferScale);
}
if (transformChanged) {
emit q->transformChanged(target->transform);
emit q->bufferTransformChanged(target->bufferTransform);
}
if (visibilityChanged) {
if (target->buffer) {
......@@ -612,14 +612,14 @@ void SurfaceInterface::Private::damageBuffer(const QRect &rect)
void SurfaceInterface::Private::setScale(qint32 scale)
{
pending.scale = scale;
pending.scaleIsSet = true;
pending.bufferScale = scale;
pending.bufferScaleIsSet = true;
}
void SurfaceInterface::Private::setTransform(OutputInterface::Transform transform)
{
pending.transform = transform;
pending.transformIsSet = true;
pending.bufferTransform = transform;
pending.bufferTransformIsSet = true;
}
void SurfaceInterface::Private::addFrameCallback(uint32_t callback)
......@@ -769,16 +769,16 @@ bool SurfaceInterface::inputIsInfinite() const
return d->current.inputIsInfinite;
}
qint32 SurfaceInterface::scale() const
qint32 SurfaceInterface::bufferScale() const
{
Q_D();
return d->current.scale;
return d->current.bufferScale;
}
OutputInterface::Transform SurfaceInterface::transform() const
OutputInterface::Transform SurfaceInterface::bufferTransform() const
{
Q_D();
return d->current.transform;
return d->current.bufferTransform;
}
BufferInterface *SurfaceInterface::buffer()
......
......@@ -73,8 +73,8 @@ class KWAYLANDSERVER_EXPORT SurfaceInterface : public Resource
* The current input region.
**/
Q_PROPERTY(QRegion input READ input NOTIFY inputChanged)
Q_PROPERTY(qint32 scale READ scale NOTIFY scaleChanged)
Q_PROPERTY(KWaylandServer::OutputInterface::Transform transform READ transform NOTIFY transformChanged)
Q_PROPERTY(qint32 bufferScale READ bufferScale NOTIFY bufferScaleChanged)
Q_PROPERTY(KWaylandServer::OutputInterface::Transform bufferTransform READ bufferTransform NOTIFY bufferTransformChanged)
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
public:
virtual ~SurfaceInterface();
......@@ -145,8 +145,8 @@ public:
QRegion opaque() const;
QRegion input() const;
bool inputIsInfinite() const;
qint32 scale() const;
OutputInterface::Transform transform() const;
qint32 bufferScale() const;
OutputInterface::Transform bufferTransform() const;
/**
* @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.
*/
void scaleChanged(qint32);
void bufferScaleChanged(qint32);
/**
* 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.
**/
......
......@@ -43,10 +43,10 @@ public:
bool slideIsSet = false;
bool inputIsInfinite = true;
bool childrenChanged = false;
bool scaleIsSet = false;
bool transformIsSet = false;
qint32 scale = 1;
OutputInterface::Transform transform = OutputInterface::Transform::Normal;
bool bufferScaleIsSet = false;
bool bufferTransformIsSet = false;
qint32 bufferScale = 1;
OutputInterface::Transform bufferTransform = OutputInterface::Transform::Normal;
QList<wl_resource*> callbacks = QList<wl_resource*>();
QPoint offset = QPoint();
BufferInterface *buffer = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment