[effects] Adjust Cube to use shader traits shader for window rendering
Main change is that the rotation for each face of the cube is now done through a QMatrix4x4 instead of specifying through ScreenPaintData.
This commit is contained in:
parent
b366f0ac01
commit
6e35aded0b
2 changed files with 22 additions and 23 deletions
|
@ -693,12 +693,14 @@ void CubeEffect::paintCube(int mask, QRegion region, ScreenPaintData& data)
|
||||||
if (painting_desktop == 0) {
|
if (painting_desktop == 0) {
|
||||||
painting_desktop = effects->numberOfDesktops();
|
painting_desktop = effects->numberOfDesktops();
|
||||||
}
|
}
|
||||||
ScreenPaintData newData = data;
|
QMatrix4x4 matrix;
|
||||||
newData.setRotationAxis(Qt::YAxis);
|
matrix.translate(0, 0, -zTranslate);
|
||||||
newData.setRotationAngle(internalCubeAngle * i);
|
const QVector3D origin(rect.width() / 2, 0.0, -point);
|
||||||
newData.setRotationOrigin(QVector3D(rect.width() / 2, 0.0, -point));
|
matrix.translate(origin);
|
||||||
newData.setZTranslation(-zTranslate);
|
matrix.rotate(internalCubeAngle * i, 0, 1, 0);
|
||||||
effects->paintScreen(mask, region, newData);
|
matrix.translate(-origin);
|
||||||
|
m_currentFaceMatrix = matrix;
|
||||||
|
effects->paintScreen(mask, region, data);
|
||||||
}
|
}
|
||||||
cube_painting = false;
|
cube_painting = false;
|
||||||
painting_desktop = effects->currentDesktop();
|
painting_desktop = effects->currentDesktop();
|
||||||
|
@ -1222,11 +1224,8 @@ void CubeEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int t
|
||||||
void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||||
{
|
{
|
||||||
ShaderManager *shaderManager = ShaderManager::instance();
|
ShaderManager *shaderManager = ShaderManager::instance();
|
||||||
GLShader *shader = NULL;
|
|
||||||
QMatrix4x4 origMatrix;
|
|
||||||
if (activated && cube_painting) {
|
if (activated && cube_painting) {
|
||||||
region= infiniteRegion(); // we need to explicitly prevent any clipping, bug #325432
|
region= infiniteRegion(); // we need to explicitly prevent any clipping, bug #325432
|
||||||
shader = shaderManager->pushShader(ShaderManager::GenericShader);
|
|
||||||
//qCDebug(KWINEFFECTS) << w->caption();
|
//qCDebug(KWINEFFECTS) << w->caption();
|
||||||
float opacity = cubeOpacity;
|
float opacity = cubeOpacity;
|
||||||
if (start) {
|
if (start) {
|
||||||
|
@ -1344,8 +1343,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
|
||||||
}
|
}
|
||||||
data.quads = new_quads;
|
data.quads = new_quads;
|
||||||
}
|
}
|
||||||
origMatrix = shader->getUniformMatrix4x4("screenTransformation");
|
GLShader *currentShader = nullptr;
|
||||||
GLShader *currentShader = shader;
|
|
||||||
if (mode == Cylinder) {
|
if (mode == Cylinder) {
|
||||||
shaderManager->pushShader(cylinderShader);
|
shaderManager->pushShader(cylinderShader);
|
||||||
cylinderShader->setUniform("xCoord", (float)w->x());
|
cylinderShader->setUniform("xCoord", (float)w->x());
|
||||||
|
@ -1370,21 +1368,21 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
|
||||||
sphereShader->setUniform("timeLine", factor);
|
sphereShader->setUniform("timeLine", factor);
|
||||||
currentShader = sphereShader;
|
currentShader = sphereShader;
|
||||||
}
|
}
|
||||||
if (reflectionPainting) {
|
if (currentShader) {
|
||||||
currentShader->setUniform(GLShader::ScreenTransformation, m_reflectionMatrix * m_rotationMatrix * origMatrix);
|
data.shader = currentShader;
|
||||||
} else {
|
}
|
||||||
currentShader->setUniform(GLShader::ScreenTransformation, m_rotationMatrix*origMatrix);
|
data.setProjectionMatrix(data.screenProjectionMatrix());
|
||||||
|
if (reflectionPainting) {
|
||||||
|
data.setModelViewMatrix(m_reflectionMatrix * m_rotationMatrix * m_currentFaceMatrix);
|
||||||
|
} else {
|
||||||
|
data.setModelViewMatrix(m_rotationMatrix * m_currentFaceMatrix);
|
||||||
}
|
}
|
||||||
data.shader = currentShader;
|
|
||||||
}
|
}
|
||||||
effects->paintWindow(w, mask, region, data);
|
effects->paintWindow(w, mask, region, data);
|
||||||
if (activated && cube_painting) {
|
if (activated && cube_painting) {
|
||||||
if (mode == Cylinder || mode == Sphere) {
|
if (mode == Cylinder || mode == Sphere) {
|
||||||
shaderManager->popShader();
|
shaderManager->popShader();
|
||||||
} else {
|
|
||||||
shader->setUniform(GLShader::ScreenTransformation, origMatrix);
|
|
||||||
}
|
}
|
||||||
shaderManager->popShader();
|
|
||||||
if (w->isDesktop() && effects->numScreens() > 1 && paintCaps) {
|
if (w->isDesktop() && effects->numScreens() > 1 && paintCaps) {
|
||||||
QRect rect = effects->clientArea(FullArea, activeScreen, painting_desktop);
|
QRect rect = effects->clientArea(FullArea, activeScreen, painting_desktop);
|
||||||
QRegion paint = QRegion(rect);
|
QRegion paint = QRegion(rect);
|
||||||
|
@ -1426,17 +1424,17 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
|
||||||
}
|
}
|
||||||
bool capShader = false;
|
bool capShader = false;
|
||||||
if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) {
|
if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) {
|
||||||
// FIXME: needs projection being passed through to WindowPaintData
|
|
||||||
capShader = true;
|
capShader = true;
|
||||||
ShaderManager::instance()->pushShader(m_capShader);
|
ShaderManager::instance()->pushShader(m_capShader);
|
||||||
m_capShader->setUniform("u_mirror", 0);
|
m_capShader->setUniform("u_mirror", 0);
|
||||||
m_capShader->setUniform("u_untextured", 1);
|
m_capShader->setUniform("u_untextured", 1);
|
||||||
|
QMatrix4x4 mvp = data.screenProjectionMatrix();
|
||||||
if (reflectionPainting) {
|
if (reflectionPainting) {
|
||||||
m_capShader->setUniform(GLShader::ScreenTransformation, m_reflectionMatrix * m_rotationMatrix * origMatrix);
|
mvp = mvp * m_reflectionMatrix * m_rotationMatrix * m_currentFaceMatrix;
|
||||||
} else {
|
} else {
|
||||||
m_capShader->setUniform(GLShader::ScreenTransformation, m_rotationMatrix * origMatrix);
|
mvp = mvp * m_rotationMatrix * m_currentFaceMatrix;
|
||||||
}
|
}
|
||||||
m_capShader->setUniform(GLShader::WindowTransformation, QMatrix4x4());
|
m_capShader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
|
||||||
}
|
}
|
||||||
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
||||||
vbo->reset();
|
vbo->reset();
|
||||||
|
|
|
@ -237,6 +237,7 @@ private:
|
||||||
QMatrix4x4 m_rotationMatrix;
|
QMatrix4x4 m_rotationMatrix;
|
||||||
QMatrix4x4 m_reflectionMatrix;
|
QMatrix4x4 m_reflectionMatrix;
|
||||||
QMatrix4x4 m_textureMirrorMatrix;
|
QMatrix4x4 m_textureMirrorMatrix;
|
||||||
|
QMatrix4x4 m_currentFaceMatrix;
|
||||||
GLVertexBuffer *m_cubeCapBuffer;
|
GLVertexBuffer *m_cubeCapBuffer;
|
||||||
|
|
||||||
// Shortcuts - needed to toggle the effect
|
// Shortcuts - needed to toggle the effect
|
||||||
|
|
Loading…
Reference in a new issue