Create the new projection matrix at start of frame rendering

For both simple and generic rendering the projection is actually the
same. So let's create it at the start of the frame rendering which
allows us to also pass it through the effects.
This commit is contained in:
Martin Gräßlin 2015-11-26 14:48:57 +01:00
parent 778a7fd1a0
commit ad7246e010
2 changed files with 12 additions and 5 deletions

View file

@ -727,6 +727,7 @@ qint64 SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
}
int mask = 0;
updateProjectionMatrix();
paintScreen(&mask, damage.intersected(geo), repaint, &update, &valid); // call generic implementation
GLVertexBuffer::streamingBuffer()->endOfFrame();
@ -746,6 +747,7 @@ qint64 SceneOpenGL::paint(QRegion damage, ToplevelList toplevels)
}
int mask = 0;
updateProjectionMatrix();
paintScreen(&mask, damage, repaint, &updateRegion, &validRegion); // call generic implementation
if (!GLPlatform::instance()->isGLES()) {
@ -1092,9 +1094,13 @@ QMatrix4x4 SceneOpenGL2::createProjectionMatrix() const
return projection * matrix;
}
void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region)
void SceneOpenGL2::updateProjectionMatrix()
{
m_projectionMatrix = createProjectionMatrix();
}
void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region)
{
m_screenProjectionMatrix = m_projectionMatrix;
Scene::paintSimpleScreen(mask, region);
@ -1103,10 +1109,8 @@ void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region)
void SceneOpenGL2::paintGenericScreen(int mask, ScreenPaintData data)
{
const QMatrix4x4 screenMatrix = transformation(mask, data);
const QMatrix4x4 pMatrix = createProjectionMatrix();
m_projectionMatrix = pMatrix;
m_screenProjectionMatrix = pMatrix * screenMatrix;
m_screenProjectionMatrix = m_projectionMatrix * screenMatrix;
// ### Remove the following two lines when there are no more users of the old shader API
ShaderBinder binder(ShaderManager::GenericShader);

View file

@ -62,6 +62,7 @@ public:
virtual void doneOpenGLContextCurrent() override;
Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override;
virtual void triggerFence() override;
virtual QMatrix4x4 projectionMatrix() const = 0;
void insertWait();
@ -98,6 +99,7 @@ protected:
void handleGraphicsReset(GLenum status);
virtual void doPaintBackground(const QVector<float> &vertices) = 0;
virtual void updateProjectionMatrix() = 0;
Q_SIGNALS:
void resetCompositing();
@ -126,7 +128,7 @@ public:
static bool supported(OpenGLBackend *backend);
ColorCorrection *colorCorrection();
QMatrix4x4 projectionMatrix() const { return m_projectionMatrix; }
QMatrix4x4 projectionMatrix() const override { return m_projectionMatrix; }
QMatrix4x4 screenProjectionMatrix() const { return m_screenProjectionMatrix; }
protected:
@ -136,6 +138,7 @@ protected:
virtual Scene::Window *createWindow(Toplevel *t);
virtual void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data);
virtual void paintDesktop(int desktop, int mask, const QRegion &region, ScreenPaintData &data);
virtual void updateProjectionMatrix() override;
private Q_SLOTS:
void slotColorCorrectedChanged(bool recreateShaders = true);