improve support for mirroring output transforms

CCBUG: 447792
This commit is contained in:
Xaver Hugl 2023-10-10 14:37:59 +02:00
parent aaffd459ce
commit 1f82d81558
6 changed files with 38 additions and 15 deletions

View file

@ -24,15 +24,16 @@ static TextureTransforms drmToTextureRotation(DrmPipeline *pipeline)
if (angle < 0) {
angle += 360;
}
TextureTransforms flip = (pipeline->renderOrientation() & DrmPlane::Transformation::ReflectX) ? TextureTransform::MirrorX : TextureTransforms();
switch (angle % 360) {
case 0:
return TextureTransforms();
return TextureTransforms() | flip;
case 90:
return TextureTransform::Rotate90;
return TextureTransforms(TextureTransform::Rotate90) | flip;
case 180:
return TextureTransform::Rotate180;
return TextureTransforms(TextureTransform::Rotate180) | flip;
case 270:
return TextureTransform::Rotate270;
return TextureTransforms(TextureTransform::Rotate270) | flip;
default:
Q_UNREACHABLE();
}

View file

@ -31,15 +31,16 @@ static TextureTransforms drmToTextureRotation(DrmPipeline *pipeline)
if (angle < 0) {
angle += 360;
}
TextureTransforms flip = (pipeline->renderOrientation() & DrmPlane::Transformation::ReflectX) ? TextureTransform::MirrorX : TextureTransforms();
switch (angle % 360) {
case 0:
return TextureTransforms();
return TextureTransforms() | flip;
case 90:
return TextureTransform::Rotate90;
return TextureTransforms(TextureTransform::Rotate90) | flip;
case 180:
return TextureTransform::Rotate180;
return TextureTransforms(TextureTransform::Rotate180) | flip;
case 270:
return TextureTransform::Rotate270;
return TextureTransforms(TextureTransform::Rotate270) | flip;
default:
Q_UNREACHABLE();
}

View file

@ -84,6 +84,9 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayerSurface::startRendering(cons
return std::nullopt;
}
if (slot->framebuffer()->colorAttachment()->contentTransforms() != transformation) {
m_surface->damageJournal.clear();
}
slot->framebuffer()->colorAttachment()->setContentTransform(transformation);
m_surface->currentSlot = slot;

View file

@ -204,21 +204,23 @@ DrmPlane::Transformations outputToPlaneTransform(OutputTransform transform)
{
using PlaneTrans = DrmPlane::Transformation;
// TODO: Do we want to support reflections (flips)?
switch (transform.kind()) {
case OutputTransform::Normal:
case OutputTransform::Flipped:
return PlaneTrans::Rotate0;
case OutputTransform::Flipped:
return PlaneTrans::ReflectX | PlaneTrans::Rotate0;
case OutputTransform::Rotated90:
case OutputTransform::Flipped90:
return PlaneTrans::Rotate90;
case OutputTransform::Flipped90:
return PlaneTrans::ReflectX | PlaneTrans::Rotate90;
case OutputTransform::Rotated180:
case OutputTransform::Flipped180:
return PlaneTrans::Rotate180;
case OutputTransform::Flipped180:
return PlaneTrans::ReflectX | PlaneTrans::Rotate180;
case OutputTransform::Rotated270:
case OutputTransform::Flipped270:
return PlaneTrans::Rotate270;
case OutputTransform::Flipped270:
return PlaneTrans::ReflectX | PlaneTrans::Rotate270;
default:
Q_UNREACHABLE();
}

View file

@ -559,6 +559,14 @@ void OutputConfigurationStore::load()
state.transform = state.manualTransform = OutputTransform::Kind::Rotated180;
} else if (str == "Rotated270") {
state.transform = state.manualTransform = OutputTransform::Kind::Rotated270;
} else if (str == "Flipped") {
state.transform = state.manualTransform = OutputTransform::Kind::Flipped;
} else if (str == "Flipped90") {
state.transform = state.manualTransform = OutputTransform::Kind::Flipped90;
} else if (str == "Flipped180") {
state.transform = state.manualTransform = OutputTransform::Kind::Flipped180;
} else if (str == "Flipped270") {
state.transform = state.manualTransform = OutputTransform::Kind::Flipped270;
}
}
if (const auto it = data.find("overscan"); it != data.end()) {
@ -744,6 +752,14 @@ void OutputConfigurationStore::save()
o["transform"] = "Rotated180";
} else if (output.manualTransform == OutputTransform::Kind::Rotated270) {
o["transform"] = "Rotated270";
} else if (output.manualTransform == OutputTransform::Kind::Flipped) {
o["transform"] = "Flipped";
} else if (output.manualTransform == OutputTransform::Kind::Flipped90) {
o["transform"] = "Flipped90";
} else if (output.manualTransform == OutputTransform::Kind::Flipped180) {
o["transform"] = "Flipped180";
} else if (output.manualTransform == OutputTransform::Kind::Flipped270) {
o["transform"] = "Flipped270";
}
if (output.overscan) {
o["overscan"] = int(*output.overscan);

View file

@ -68,7 +68,7 @@ void ScreenTransformEffect::addScreen(EffectScreen *screen)
{
connect(screen, &EffectScreen::changed, this, [this, screen] {
auto &state = m_states[screen];
if (screen->transform() == state.m_oldTransform) {
if (transformAngle(screen->transform(), state.m_oldTransform) == 0) {
effects->makeOpenGLContextCurrent();
m_states.remove(screen);
return;