From b7cb301deb3b191c7ff0bd04d87d6c1b93d90407 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 20 Jun 2017 15:48:41 +0100 Subject: [PATCH] Make shadows work for windows 100% width or height Summary: Clients provide shadows as 9 images, which then get split into relevant quads. To work out the full width we need the size of an item on the left, the middle and the right. Some elements can be legitiamtely missing so to work out the width of the left edge we need to consider all 3 of topleft,left,bottomleft. Currently we checked both corners in case one was missing, but it's legitimate for both to be missing if the shadow stretches the whole way. BUG: 380825 Test Plan: Shadow on panel, rest looks the same Reviewers: #plasma, mart Reviewed By: #plasma, mart Subscribers: graesslin, mart, plasma-devel, kwin, #kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D6164 --- scene_opengl.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 22debbd9f9..9be551b693 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -2248,12 +2248,12 @@ void SceneOpenGLShadow::buildQuads() const QRectF outerRect(QPointF(-leftOffset(), -topOffset()), QPointF(topLevel()->width() + rightOffset(), topLevel()->height() + bottomOffset())); - const int width = qMax(topLeft.width(), bottomLeft.width()) + - qMax(top.width(), bottom.width()) + - qMax(topRight.width(), bottomRight.width()); - const int height = qMax(topLeft.height(), topRight.height()) + - qMax(left.height(), right.height()) + - qMax(bottomLeft.height(), bottomRight.height()); + const int width = std::max({topLeft.width(), left.width(), bottomLeft.width()}) + + std::max(top.width(), bottom.width()) + + std::max({topRight.width(), right.width(), bottomRight.width()}); + const int height = std::max({topLeft.height(), top.height(), topRight.height()}) + + std::max(left.height(), right.height()) + + std::max({bottomLeft.height(), bottom.height(), bottomRight.height()}); qreal tx1(0.0), tx2(0.0), ty1(0.0), ty2(0.0); @@ -2355,13 +2355,12 @@ bool SceneOpenGLShadow::prepareBackend() const QSize topLeft(shadowPixmap(ShadowElementTopLeft).size()); const QSize bottomRight(shadowPixmap(ShadowElementBottomRight).size()); - const int width = qMax(topLeft.width(), bottomLeft.width()) + - qMax(top.width(), bottom.width()) + - qMax(topRight.width(), bottomRight.width()); - - const int height = qMax(topRight.height(), topLeft.height()) + - qMax(left.height(), right.height()) + - qMax(bottomLeft.height(), bottomRight.height()); + const int width = std::max({topLeft.width(), left.width(), bottomLeft.width()}) + + std::max(top.width(), bottom.width()) + + std::max({topRight.width(), right.width(), bottomRight.width()}); + const int height = std::max({topLeft.height(), top.height(), topRight.height()}) + + std::max(left.height(), right.height()) + + std::max({bottomLeft.height(), bottom.height(), bottomRight.height()}); if (width == 0 || height == 0) { return false;