Changeset View
Changeset View
Standalone View
Standalone View
scene.cpp
Show First 20 Lines • Show All 953 Lines • ▼ Show 20 Line(s) | 950 | { | |||
---|---|---|---|---|---|
954 | } | 954 | } | ||
955 | 955 | | |||
956 | const QPointF geometryOffset = bufferOffset(); | 956 | const QPointF geometryOffset = bufferOffset(); | ||
957 | const qreal textureScale = toplevel->bufferScale(); | 957 | const qreal textureScale = toplevel->bufferScale(); | ||
958 | 958 | | |||
959 | WindowQuadList quads; | 959 | WindowQuadList quads; | ||
960 | quads.reserve(contentsRegion.rectCount()); | 960 | quads.reserve(contentsRegion.rectCount()); | ||
961 | 961 | | |||
962 | for (const QRectF &rect : contentsRegion) { | 962 | auto createQuad = [geometryOffset](const QRectF &rect, const QRectF &sourceRect) { | ||
963 | WindowQuad quad(WindowQuadContents); | 963 | WindowQuad quad(WindowQuadContents); | ||
964 | 964 | | |||
965 | const qreal x0 = rect.left() + geometryOffset.x(); | 965 | const qreal x0 = rect.left() + geometryOffset.x(); | ||
966 | const qreal y0 = rect.top() + geometryOffset.y(); | 966 | const qreal y0 = rect.top() + geometryOffset.y(); | ||
967 | const qreal x1 = rect.right() + geometryOffset.x(); | 967 | const qreal x1 = rect.right() + geometryOffset.x(); | ||
968 | const qreal y1 = rect.bottom() + geometryOffset.y(); | 968 | const qreal y1 = rect.bottom() + geometryOffset.y(); | ||
969 | 969 | | |||
970 | const qreal u0 = rect.left() * textureScale; | 970 | const qreal u0 = sourceRect.left(); | ||
971 | const qreal v0 = rect.top() * textureScale; | 971 | const qreal v0 = sourceRect.top(); | ||
972 | const qreal u1 = rect.right() * textureScale; | 972 | const qreal u1 = sourceRect.right(); | ||
973 | const qreal v1 = rect.bottom() * textureScale; | 973 | const qreal v1 = sourceRect.bottom(); | ||
974 | 974 | | |||
975 | quad[0] = WindowVertex(QPointF(x0, y0), QPointF(u0, v0)); | 975 | quad[0] = WindowVertex(QPointF(x0, y0), QPointF(u0, v0)); | ||
976 | quad[1] = WindowVertex(QPointF(x1, y0), QPointF(u1, v0)); | 976 | quad[1] = WindowVertex(QPointF(x1, y0), QPointF(u1, v0)); | ||
977 | quad[2] = WindowVertex(QPointF(x1, y1), QPointF(u1, v1)); | 977 | quad[2] = WindowVertex(QPointF(x1, y1), QPointF(u1, v1)); | ||
978 | quad[3] = WindowVertex(QPointF(x0, y1), QPointF(u0, v1)); | 978 | quad[3] = WindowVertex(QPointF(x0, y1), QPointF(u0, v1)); | ||
979 | return quad; | ||||
980 | }; | ||||
979 | 981 | | |||
980 | quads << quad; | 982 | // Check for viewport being set. We only allow specifying the viewport at the moment for | ||
983 | // non-shape windows. | ||||
984 | if (contentsRegion.rectCount() < 2) { | ||||
985 | const QRectF contentsRect = *contentsRegion.begin(); | ||||
986 | QRectF sourceRect(contentsRect.topLeft() * textureScale, | ||||
987 | contentsRect.bottomRight() * textureScale); | ||||
988 | | ||||
989 | if (const auto *surface = toplevel->surface()) { | ||||
990 | const QRectF rect = surface->sourceRectangle(); | ||||
991 | if (rect.isValid()) { | ||||
992 | sourceRect = QRectF(rect.topLeft() * textureScale, | ||||
993 | rect.bottomRight() * textureScale); | ||||
994 | } else if (auto *buffer = surface->buffer()) { | ||||
995 | // Try to get the source rectangle from the buffer size, what defines the source | ||||
996 | // size without respect to destination size. | ||||
997 | const auto origin = contentsRect.topLeft(); | ||||
998 | const QRectF rect = QRectF(origin, buffer->size() - QSize(origin.x(), origin.y())); | ||||
999 | // Make sure a buffer was set already. | ||||
1000 | if (rect.isValid()) { | ||||
1001 | sourceRect = rect; | ||||
1002 | } | ||||
1003 | } | ||||
1004 | } | ||||
1005 | quads << createQuad(contentsRect, sourceRect); | ||||
1006 | } else { | ||||
1007 | for (const QRectF &contentsRect : contentsRegion) { | ||||
1008 | const QRectF sourceRect(contentsRect.topLeft() * textureScale, | ||||
1009 | contentsRect.bottomRight() * textureScale); | ||||
1010 | quads << createQuad(contentsRect, sourceRect); | ||||
1011 | } | ||||
981 | } | 1012 | } | ||
982 | 1013 | | |||
983 | return quads; | 1014 | return quads; | ||
984 | } | 1015 | } | ||
985 | 1016 | | |||
986 | void Scene::Window::invalidateQuadsCache() | 1017 | void Scene::Window::invalidateQuadsCache() | ||
987 | { | 1018 | { | ||
988 | cached_quad_list.reset(); | 1019 | cached_quad_list.reset(); | ||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |