Commit e30b1212 authored by Fredrik Höglund's avatar Fredrik Höglund

screenshot: Use the new matrix API

This makes the screenshot effect work when the scene is using
dynamically generated shaders.
parent d2cb9f9b
......@@ -128,9 +128,13 @@ void ScreenShotEffect::postPaintScreen()
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0, 0.0, 0.0, 1.0);
setMatrix(offscreenTexture->width(), offscreenTexture->height());
QMatrix4x4 projection;
projection.ortho(QRect(0, 0, offscreenTexture->width(), offscreenTexture->height()));
d.setProjectionMatrix(projection);
effects->drawWindow(m_scheduledScreenshot, mask, infiniteRegion(), d);
restoreMatrix();
// copy content from framebuffer into image
img = QImage(QSize(width, height), QImage::Format_ARGB32);
glReadnPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, img.byteCount(), (GLvoid*)img.bits());
......@@ -174,30 +178,6 @@ void ScreenShotEffect::postPaintScreen()
}
}
static QMatrix4x4 s_origProjection;
static QMatrix4x4 s_origModelview;
void ScreenShotEffect::setMatrix(int width, int height)
{
QMatrix4x4 projection;
QMatrix4x4 identity;
projection.ortho(QRect(0, 0, width, height));
ShaderBinder binder(ShaderManager::GenericShader);
GLShader *shader = binder.shader();
s_origProjection = shader->getUniformMatrix4x4("projection");
s_origModelview = shader->getUniformMatrix4x4("modelview");
shader->setUniform(GLShader::ProjectionMatrix, projection);
shader->setUniform(GLShader::ModelViewMatrix, identity);
}
void ScreenShotEffect::restoreMatrix()
{
ShaderBinder binder(ShaderManager::GenericShader);
GLShader *shader = binder.shader();
shader->setUniform(GLShader::ProjectionMatrix, s_origProjection);
shader->setUniform(GLShader::ModelViewMatrix, s_origModelview);
}
void ScreenShotEffect::screenshotWindowUnderCursor(int mask)
{
m_type = (ScreenShotType)mask;
......
......@@ -84,8 +84,6 @@ private Q_SLOTS:
private:
void grabPointerImage(QImage& snapshot, int offsetx, int offsety);
QString blitScreenshot(const QRect &geometry);
void setMatrix(int width, int height);
void restoreMatrix();
EffectWindow *m_scheduledScreenshot;
ScreenShotType m_type;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment