scene: Generate unnormalized shadow texture coords

This makes shadow texture coordinates consistent with surface and
decoration texture coords and allows reusing window quads between
kwin items and qtquick items more easily.
This commit is contained in:
Vlad Zahorodnii 2021-07-06 16:38:35 +03:00
parent 9b06492499
commit 1d54231df1
2 changed files with 27 additions and 27 deletions

View file

@ -916,7 +916,7 @@ void OpenGLWindow::createRenderNode(Item *item, RenderContext *context)
.transformMatrix = context->transforms.top(),
.opacity = context->paintData.opacity(),
.hasAlpha = true,
.coordinateType = NormalizedCoordinates,
.coordinateType = UnnormalizedCoordinates,
});
}
} else if (auto decorationItem = qobject_cast<DecorationItem *>(item)) {

View file

@ -164,8 +164,8 @@ WindowQuadList ShadowItem::buildQuads() const
if (topLeftRect.isValid()) {
tx1 = 0.0;
ty1 = 0.0;
tx2 = topLeftRect.width() / width;
ty2 = topLeftRect.height() / height;
tx2 = topLeftRect.width();
ty2 = topLeftRect.height();
WindowQuad topLeftQuad;
topLeftQuad[0] = WindowVertex(topLeftRect.left(), topLeftRect.top(), tx1, ty1);
topLeftQuad[1] = WindowVertex(topLeftRect.right(), topLeftRect.top(), tx2, ty1);
@ -175,10 +175,10 @@ WindowQuadList ShadowItem::buildQuads() const
}
if (topRightRect.isValid()) {
tx1 = 1.0 - topRightRect.width() / width;
tx1 = width - topRightRect.width();
ty1 = 0.0;
tx2 = 1.0;
ty2 = topRightRect.height() / height;
tx2 = width;
ty2 = topRightRect.height();
WindowQuad topRightQuad;
topRightQuad[0] = WindowVertex(topRightRect.left(), topRightRect.top(), tx1, ty1);
topRightQuad[1] = WindowVertex(topRightRect.right(), topRightRect.top(), tx2, ty1);
@ -188,10 +188,10 @@ WindowQuadList ShadowItem::buildQuads() const
}
if (bottomRightRect.isValid()) {
tx1 = 1.0 - bottomRightRect.width() / width;
tx2 = 1.0;
ty1 = 1.0 - bottomRightRect.height() / height;
ty2 = 1.0;
tx1 = width - bottomRightRect.width();
tx2 = width;
ty1 = height - bottomRightRect.height();
ty2 = height;
WindowQuad bottomRightQuad;
bottomRightQuad[0] = WindowVertex(bottomRightRect.left(), bottomRightRect.top(), tx1, ty1);
bottomRightQuad[1] = WindowVertex(bottomRightRect.right(), bottomRightRect.top(), tx2, ty1);
@ -202,9 +202,9 @@ WindowQuadList ShadowItem::buildQuads() const
if (bottomLeftRect.isValid()) {
tx1 = 0.0;
tx2 = bottomLeftRect.width() / width;
ty1 = 1.0 - bottomLeftRect.height() / height;
ty2 = 1.0;
tx2 = bottomLeftRect.width();
ty1 = height - bottomLeftRect.height();
ty2 = height;
WindowQuad bottomLeftQuad;
bottomLeftQuad[0] = WindowVertex(bottomLeftRect.left(), bottomLeftRect.top(), tx1, ty1);
bottomLeftQuad[1] = WindowVertex(bottomLeftRect.right(), bottomLeftRect.top(), tx2, ty1);
@ -234,10 +234,10 @@ WindowQuadList ShadowItem::buildQuads() const
distributeVertically(topRect, bottomRect);
if (topRect.isValid()) {
tx1 = shadowMargins.left() / width;
tx1 = shadowMargins.left();
ty1 = 0.0;
tx2 = tx1 + top.width() / width;
ty2 = topRect.height() / height;
tx2 = tx1 + top.width();
ty2 = topRect.height();
WindowQuad topQuad;
topQuad[0] = WindowVertex(topRect.left(), topRect.top(), tx1, ty1);
topQuad[1] = WindowVertex(topRect.right(), topRect.top(), tx2, ty1);
@ -247,10 +247,10 @@ WindowQuadList ShadowItem::buildQuads() const
}
if (rightRect.isValid()) {
tx1 = 1.0 - rightRect.width() / width;
ty1 = shadowMargins.top() / height;
tx2 = 1.0;
ty2 = ty1 + right.height() / height;
tx1 = width - rightRect.width();
ty1 = shadowMargins.top();
tx2 = width;
ty2 = ty1 + right.height();
WindowQuad rightQuad;
rightQuad[0] = WindowVertex(rightRect.left(), rightRect.top(), tx1, ty1);
rightQuad[1] = WindowVertex(rightRect.right(), rightRect.top(), tx2, ty1);
@ -260,10 +260,10 @@ WindowQuadList ShadowItem::buildQuads() const
}
if (bottomRect.isValid()) {
tx1 = shadowMargins.left() / width;
ty1 = 1.0 - bottomRect.height() / height;
tx2 = tx1 + bottom.width() / width;
ty2 = 1.0;
tx1 = shadowMargins.left();
ty1 = height - bottomRect.height();
tx2 = tx1 + bottom.width();
ty2 = height;
WindowQuad bottomQuad;
bottomQuad[0] = WindowVertex(bottomRect.left(), bottomRect.top(), tx1, ty1);
bottomQuad[1] = WindowVertex(bottomRect.right(), bottomRect.top(), tx2, ty1);
@ -274,9 +274,9 @@ WindowQuadList ShadowItem::buildQuads() const
if (leftRect.isValid()) {
tx1 = 0.0;
ty1 = shadowMargins.top() / height;
tx2 = leftRect.width() / width;
ty2 = ty1 + left.height() / height;
ty1 = shadowMargins.top();
tx2 = leftRect.width();
ty2 = ty1 + left.height();
WindowQuad leftQuad;
leftQuad[0] = WindowVertex(leftRect.left(), leftRect.top(), tx1, ty1);
leftQuad[1] = WindowVertex(leftRect.right(), leftRect.top(), tx2, ty1);