Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 608 Lines • ▼ Show 20 Line(s) | 569 | { | |||
---|---|---|---|---|---|
609 | m_cursorTexture->render(QRegion(cursorRect), cursorRect); | 609 | m_cursorTexture->render(QRegion(cursorRect), cursorRect); | ||
610 | m_cursorTexture->unbind(); | 610 | m_cursorTexture->unbind(); | ||
611 | 611 | | |||
612 | kwinApp()->platform()->markCursorAsRendered(); | 612 | kwinApp()->platform()->markCursorAsRendered(); | ||
613 | 613 | | |||
614 | glDisable(GL_BLEND); | 614 | glDisable(GL_BLEND); | ||
615 | } | 615 | } | ||
616 | 616 | | |||
617 | qint64 SceneOpenGL::paint(QRegion damage, QList<Toplevel *> toplevels) | 617 | qint64 SceneOpenGL::paint(const QRegion &damage, const QList<Toplevel *> &toplevels) | ||
618 | { | 618 | { | ||
619 | // actually paint the frame, flushed with the NEXT frame | 619 | // actually paint the frame, flushed with the NEXT frame | ||
620 | createStackingOrder(toplevels); | 620 | createStackingOrder(toplevels); | ||
621 | 621 | | |||
622 | // After this call, updateRegion will contain the damaged region in the | 622 | // After this call, updateRegion will contain the damaged region in the | ||
623 | // back buffer. This is the region that needs to be posted to repair | 623 | // back buffer. This is the region that needs to be posted to repair | ||
624 | // the front buffer. It doesn't include the additional damage returned | 624 | // the front buffer. It doesn't include the additional damage returned | ||
625 | // by prepareRenderingFrame(). validRegion is the region that has been | 625 | // by prepareRenderingFrame(). validRegion is the region that has been | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 715 | { | |||
729 | matrix.translate(data.rotationOrigin()); | 729 | matrix.translate(data.rotationOrigin()); | ||
730 | const QVector3D axis = data.rotationAxis(); | 730 | const QVector3D axis = data.rotationAxis(); | ||
731 | matrix.rotate(data.rotationAngle(), axis.x(), axis.y(), axis.z()); | 731 | matrix.rotate(data.rotationAngle(), axis.x(), axis.y(), axis.z()); | ||
732 | matrix.translate(-data.rotationOrigin()); | 732 | matrix.translate(-data.rotationOrigin()); | ||
733 | 733 | | |||
734 | return matrix; | 734 | return matrix; | ||
735 | } | 735 | } | ||
736 | 736 | | |||
737 | void SceneOpenGL::paintBackground(QRegion region) | 737 | void SceneOpenGL::paintBackground(const QRegion ®ion) | ||
738 | { | 738 | { | ||
739 | PaintClipper pc(region); | 739 | PaintClipper pc(region); | ||
740 | if (!PaintClipper::clip()) { | 740 | if (!PaintClipper::clip()) { | ||
741 | glClearColor(0, 0, 0, 1); | 741 | glClearColor(0, 0, 0, 1); | ||
742 | glClear(GL_COLOR_BUFFER_BIT); | 742 | glClear(GL_COLOR_BUFFER_BIT); | ||
743 | return; | 743 | return; | ||
744 | } | 744 | } | ||
745 | if (pc.clip() && pc.paintArea().isEmpty()) | 745 | if (pc.clip() && pc.paintArea().isEmpty()) | ||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Line(s) | 967 | { | |||
995 | return projection * matrix; | 995 | return projection * matrix; | ||
996 | } | 996 | } | ||
997 | 997 | | |||
998 | void SceneOpenGL2::updateProjectionMatrix() | 998 | void SceneOpenGL2::updateProjectionMatrix() | ||
999 | { | 999 | { | ||
1000 | m_projectionMatrix = createProjectionMatrix(); | 1000 | m_projectionMatrix = createProjectionMatrix(); | ||
1001 | } | 1001 | } | ||
1002 | 1002 | | |||
1003 | void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region) | 1003 | void SceneOpenGL2::paintSimpleScreen(int mask, const QRegion ®ion) | ||
1004 | { | 1004 | { | ||
1005 | m_screenProjectionMatrix = m_projectionMatrix; | 1005 | m_screenProjectionMatrix = m_projectionMatrix; | ||
1006 | 1006 | | |||
1007 | Scene::paintSimpleScreen(mask, region); | 1007 | Scene::paintSimpleScreen(mask, region); | ||
1008 | } | 1008 | } | ||
1009 | 1009 | | |||
1010 | void SceneOpenGL2::paintGenericScreen(int mask, ScreenPaintData data) | 1010 | void SceneOpenGL2::paintGenericScreen(int mask, const ScreenPaintData &data) | ||
1011 | { | 1011 | { | ||
1012 | const QMatrix4x4 screenMatrix = transformation(mask, data); | 1012 | const QMatrix4x4 screenMatrix = transformation(mask, data); | ||
1013 | 1013 | | |||
1014 | m_screenProjectionMatrix = m_projectionMatrix * screenMatrix; | 1014 | m_screenProjectionMatrix = m_projectionMatrix * screenMatrix; | ||
1015 | 1015 | | |||
1016 | Scene::paintGenericScreen(mask, data); | 1016 | Scene::paintGenericScreen(mask, data); | ||
1017 | } | 1017 | } | ||
1018 | 1018 | | |||
Show All 10 Lines | 1020 | { | |||
1029 | vbo->render(GL_TRIANGLES); | 1029 | vbo->render(GL_TRIANGLES); | ||
1030 | } | 1030 | } | ||
1031 | 1031 | | |||
1032 | Scene::Window *SceneOpenGL2::createWindow(Toplevel *t) | 1032 | Scene::Window *SceneOpenGL2::createWindow(Toplevel *t) | ||
1033 | { | 1033 | { | ||
1034 | return new OpenGLWindow(t, this); | 1034 | return new OpenGLWindow(t, this); | ||
1035 | } | 1035 | } | ||
1036 | 1036 | | |||
1037 | void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) | 1037 | void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) | ||
1038 | { | 1038 | { | ||
1039 | if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { | 1039 | if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { | ||
1040 | return; | 1040 | return; | ||
1041 | } | 1041 | } | ||
1042 | performPaintWindow(w, mask, region, data); | 1042 | performPaintWindow(w, mask, region, data); | ||
1043 | } | 1043 | } | ||
1044 | 1044 | | |||
1045 | void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) | 1045 | void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) | ||
1046 | { | 1046 | { | ||
1047 | if (mask & PAINT_WINDOW_LANCZOS) { | 1047 | if (mask & PAINT_WINDOW_LANCZOS) { | ||
1048 | if (!m_lanczosFilter) { | 1048 | if (!m_lanczosFilter) { | ||
1049 | m_lanczosFilter = new LanczosFilter(this); | 1049 | m_lanczosFilter = new LanczosFilter(this); | ||
1050 | // reset the lanczos filter when the screen gets resized | 1050 | // reset the lanczos filter when the screen gets resized | ||
1051 | // it will get created next paint | 1051 | // it will get created next paint | ||
1052 | connect(screens(), &Screens::changed, this, [this]() { | 1052 | connect(screens(), &Screens::changed, this, [this]() { | ||
1053 | makeOpenGLContextCurrent(); | 1053 | makeOpenGLContextCurrent(); | ||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Line(s) | 1307 | { | |||
1327 | for (auto pixmap : children) { | 1327 | for (auto pixmap : children) { | ||
1328 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | 1328 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | ||
1329 | continue; | 1329 | continue; | ||
1330 | } | 1330 | } | ||
1331 | renderSubSurface(shader, mvp, newWindowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, hardwareClipping); | 1331 | renderSubSurface(shader, mvp, newWindowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, hardwareClipping); | ||
1332 | } | 1332 | } | ||
1333 | } | 1333 | } | ||
1334 | 1334 | | |||
1335 | void OpenGLWindow::performPaint(int mask, QRegion region, WindowPaintData data) | 1335 | void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPaintData &_data) | ||
1336 | { | 1336 | { | ||
1337 | WindowPaintData data = _data; | ||||
1337 | if (!beginRenderWindow(mask, region, data)) | 1338 | if (!beginRenderWindow(mask, region, data)) | ||
1338 | return; | 1339 | return; | ||
1339 | 1340 | | |||
1340 | QMatrix4x4 windowMatrix = transformation(mask, data); | 1341 | QMatrix4x4 windowMatrix = transformation(mask, data); | ||
1341 | const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data); | 1342 | const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data); | ||
1342 | const QMatrix4x4 mvpMatrix = modelViewProjection * windowMatrix; | 1343 | const QMatrix4x4 mvpMatrix = modelViewProjection * windowMatrix; | ||
1343 | 1344 | | |||
1344 | 1345 | | |||
▲ Show 20 Lines • Show All 360 Lines • ▼ Show 20 Line(s) | |||||
1705 | 1706 | | |||
1706 | void SceneOpenGL::EffectFrame::crossFadeText() | 1707 | void SceneOpenGL::EffectFrame::crossFadeText() | ||
1707 | { | 1708 | { | ||
1708 | delete m_oldTextTexture; | 1709 | delete m_oldTextTexture; | ||
1709 | m_oldTextTexture = m_textTexture; | 1710 | m_oldTextTexture = m_textTexture; | ||
1710 | m_textTexture = nullptr; | 1711 | m_textTexture = nullptr; | ||
1711 | } | 1712 | } | ||
1712 | 1713 | | |||
1713 | void SceneOpenGL::EffectFrame::render(QRegion region, double opacity, double frameOpacity) | 1714 | void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, double frameOpacity) | ||
1714 | { | 1715 | { | ||
1715 | if (m_effectFrame->geometry().isEmpty()) | 1716 | if (m_effectFrame->geometry().isEmpty()) | ||
1716 | return; // Nothing to display | 1717 | return; // Nothing to display | ||
1717 | 1718 | | |||
1718 | region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL | 1719 | Q_UNUSED(_region); | ||
1720 | const QRegion region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL | ||||
1719 | 1721 | | |||
1720 | GLShader* shader = m_effectFrame->shader(); | 1722 | GLShader* shader = m_effectFrame->shader(); | ||
1721 | if (!shader) { | 1723 | if (!shader) { | ||
1722 | shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture | ShaderTrait::Modulate); | 1724 | shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture | ShaderTrait::Modulate); | ||
1723 | } else if (shader) { | 1725 | } else if (shader) { | ||
1724 | ShaderManager::instance()->pushShader(shader); | 1726 | ShaderManager::instance()->pushShader(shader); | ||
1725 | } | 1727 | } | ||
1726 | 1728 | | |||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |