Changeset View
Changeset View
Standalone View
Standalone View
effects/sheet/sheet.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 64 | { | |||
---|---|---|---|---|---|
80 | // to track its progress | 80 | // to track its progress | ||
81 | if (info != windows.end() && !w->isPaintingEnabled() && !effects->activeFullScreenEffect()) | 81 | if (info != windows.end() && !w->isPaintingEnabled() && !effects->activeFullScreenEffect()) | ||
82 | w->addRepaintFull(); | 82 | w->addRepaintFull(); | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | void SheetEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 85 | void SheetEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | ||
86 | { | 86 | { | ||
87 | InfoMap::const_iterator info = windows.constFind(w); | 87 | InfoMap::const_iterator info = windows.constFind(w); | ||
88 | if (info != windows.constEnd()) { | 88 | if (info == windows.constEnd()) { | ||
89 | effects->paintWindow(w, mask, region, data); | ||||
90 | return; | ||||
91 | } | ||||
92 | | ||||
93 | // Perspective projection distorts objects near edges of the viewport | ||||
94 | // in undesired way. To fix this, the center of the window will be | ||||
95 | // moved to the origin, after applying perspective projection, the | ||||
96 | // center is moved back to its "original" projected position. Overall, | ||||
97 | // this is how the window will be transformed: | ||||
98 | // [move to the origin] -> [scale] -> [rotate] -> [translate] -> | ||||
99 | // -> [perspective projection] -> [reverse "move to the origin"] | ||||
100 | const QMatrix4x4 oldProjMatrix = data.screenProjectionMatrix(); | ||||
101 | const QRectF windowGeo = w->geometry(); | ||||
102 | const QVector3D invOffset = oldProjMatrix.map(QVector3D(windowGeo.center())); | ||||
103 | QMatrix4x4 invOffsetMatrix; | ||||
104 | invOffsetMatrix.translate(invOffset.x(), invOffset.y()); | ||||
105 | data.setProjectionMatrix(invOffsetMatrix * oldProjMatrix); | ||||
106 | | ||||
107 | // Move the center of the window to the origin. | ||||
108 | const QRectF screenGeo = effects->virtualScreenGeometry(); | ||||
109 | const QPointF offset = screenGeo.center() - windowGeo.center(); | ||||
110 | data.translate(offset.x(), offset.y()); | ||||
111 | | ||||
89 | const double progress = info->timeLine->currentValue(); | 112 | const double progress = info->timeLine->currentValue(); | ||
90 | QGraphicsRotation rot; | 113 | QGraphicsRotation rot; | ||
91 | data.setRotationAxis(Qt::XAxis); | 114 | data.setRotationAxis(Qt::XAxis); | ||
92 | data.setRotationAngle(60.0 * (1.0 - progress)); | 115 | data.setRotationAngle(60.0 * (1.0 - progress)); | ||
93 | data *= QVector3D(1.0, progress, progress); | 116 | data *= QVector3D(1.0, progress, progress); | ||
94 | data.translate(0.0, - (w->y() - info->parentY) * (1.0 - progress)); | 117 | data.translate(0.0, - (w->y() - info->parentY) * (1.0 - progress)); | ||
95 | } | 118 | | ||
96 | effects->paintWindow(w, mask, region, data); | 119 | effects->paintWindow(w, mask, region, data); | ||
97 | } | 120 | } | ||
98 | 121 | | |||
99 | void SheetEffect::postPaintWindow(EffectWindow* w) | 122 | void SheetEffect::postPaintWindow(EffectWindow* w) | ||
100 | { | 123 | { | ||
101 | InfoMap::iterator info = windows.find(w); | 124 | InfoMap::iterator info = windows.find(w); | ||
102 | if (info != windows.end()) { | 125 | if (info != windows.end()) { | ||
103 | if (info->added && info->timeLine->currentValue() == 1.0) { | 126 | if (info->added && info->timeLine->currentValue() == 1.0) { | ||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |