Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 655 Lines • ▼ Show 20 Line(s) | 650 | { | |||
---|---|---|---|---|---|
656 | // the front buffer. It doesn't include the additional damage returned | 656 | // the front buffer. It doesn't include the additional damage returned | ||
657 | // by prepareRenderingFrame(). validRegion is the region that has been | 657 | // by prepareRenderingFrame(). validRegion is the region that has been | ||
658 | // repainted, and may be larger than updateRegion. | 658 | // repainted, and may be larger than updateRegion. | ||
659 | QRegion updateRegion, validRegion; | 659 | QRegion updateRegion, validRegion; | ||
660 | if (m_backend->perScreenRendering()) { | 660 | if (m_backend->perScreenRendering()) { | ||
661 | // trigger start render timer | 661 | // trigger start render timer | ||
662 | m_backend->prepareRenderingFrame(); | 662 | m_backend->prepareRenderingFrame(); | ||
663 | for (int i = 0; i < screens()->count(); ++i) { | 663 | for (int i = 0; i < screens()->count(); ++i) { | ||
664 | const int rotation = screens()->rotation(i); | ||||
zzag: const int rotation | |||||
664 | const QRect &geo = screens()->geometry(i); | 665 | const QRect &geo = screens()->geometry(i); | ||
665 | QRegion update; | 666 | QRegion update; | ||
666 | QRegion valid; | 667 | QRegion valid; | ||
667 | // prepare rendering makes context current on the output | 668 | // prepare rendering makes context current on the output | ||
668 | QRegion repaint = m_backend->prepareRenderingForScreen(i); | 669 | QRegion repaint = m_backend->prepareRenderingForScreen(i); | ||
669 | GLVertexBuffer::setVirtualScreenGeometry(geo); | 670 | GLVertexBuffer::setVirtualScreenGeometry(geo); | ||
670 | GLRenderTarget::setVirtualScreenGeometry(geo); | 671 | GLRenderTarget::setVirtualScreenGeometry(geo); | ||
671 | GLVertexBuffer::setVirtualScreenScale(screens()->scale(i)); | 672 | GLVertexBuffer::setVirtualScreenScale(screens()->scale(i)); | ||
672 | GLRenderTarget::setVirtualScreenScale(screens()->scale(i)); | 673 | GLRenderTarget::setVirtualScreenScale(screens()->scale(i)); | ||
673 | 674 | | |||
674 | const GLenum status = glGetGraphicsResetStatus(); | 675 | const GLenum status = glGetGraphicsResetStatus(); | ||
675 | if (status != GL_NO_ERROR) { | 676 | if (status != GL_NO_ERROR) { | ||
676 | handleGraphicsReset(status); | 677 | handleGraphicsReset(status); | ||
677 | return 0; | 678 | return 0; | ||
678 | } | 679 | } | ||
679 | 680 | | |||
680 | int mask = 0; | 681 | int mask = 0; | ||
681 | updateProjectionMatrix(); | 682 | updateProjectionMatrix(rotation); | ||
682 | paintScreen(&mask, damage.intersected(geo), repaint, &update, &valid, projectionMatrix(), geo); // call generic implementation | 683 | | ||
684 | paintScreen(&mask, damage.intersected(geo), repaint, &update, &valid, rotation, projectionMatrix(), geo); // call generic implementation | ||||
683 | paintCursor(); | 685 | paintCursor(); | ||
684 | 686 | | |||
685 | GLVertexBuffer::streamingBuffer()->endOfFrame(); | 687 | GLVertexBuffer::streamingBuffer()->endOfFrame(); | ||
686 | 688 | | |||
687 | m_backend->endRenderingFrameForScreen(i, valid, update); | 689 | m_backend->endRenderingFrameForScreen(i, valid, update); | ||
688 | 690 | | |||
689 | GLVertexBuffer::streamingBuffer()->framePosted(); | 691 | GLVertexBuffer::streamingBuffer()->framePosted(); | ||
690 | } | 692 | } | ||
691 | } else { | 693 | } else { | ||
692 | m_backend->makeCurrent(); | 694 | m_backend->makeCurrent(); | ||
693 | QRegion repaint = m_backend->prepareRenderingFrame(); | 695 | QRegion repaint = m_backend->prepareRenderingFrame(); | ||
694 | 696 | | |||
695 | const GLenum status = glGetGraphicsResetStatus(); | 697 | const GLenum status = glGetGraphicsResetStatus(); | ||
696 | if (status != GL_NO_ERROR) { | 698 | if (status != GL_NO_ERROR) { | ||
697 | handleGraphicsReset(status); | 699 | handleGraphicsReset(status); | ||
698 | return 0; | 700 | return 0; | ||
699 | } | 701 | } | ||
700 | GLVertexBuffer::setVirtualScreenGeometry(screens()->geometry()); | 702 | GLVertexBuffer::setVirtualScreenGeometry(screens()->geometry()); | ||
701 | GLRenderTarget::setVirtualScreenGeometry(screens()->geometry()); | 703 | GLRenderTarget::setVirtualScreenGeometry(screens()->geometry()); | ||
702 | GLVertexBuffer::setVirtualScreenScale(1); | 704 | GLVertexBuffer::setVirtualScreenScale(1); | ||
703 | GLRenderTarget::setVirtualScreenScale(1); | 705 | GLRenderTarget::setVirtualScreenScale(1); | ||
704 | 706 | | |||
705 | int mask = 0; | 707 | int mask = 0; | ||
706 | updateProjectionMatrix(); | 708 | updateProjectionMatrix(0); | ||
707 | paintScreen(&mask, damage, repaint, &updateRegion, &validRegion, projectionMatrix()); // call generic implementation | 709 | paintScreen(&mask, damage, repaint, &updateRegion, &validRegion, 0, projectionMatrix()); // call generic implementation | ||
708 | 710 | | |||
709 | if (!GLPlatform::instance()->isGLES()) { | 711 | if (!GLPlatform::instance()->isGLES()) { | ||
710 | const QSize &screenSize = screens()->size(); | 712 | const QSize &screenSize = screens()->size(); | ||
711 | const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height()); | 713 | const QRegion displayRegion(0, 0, screenSize.width(), screenSize.height()); | ||
712 | 714 | | |||
713 | // copy dirty parts from front to backbuffer | 715 | // copy dirty parts from front to backbuffer | ||
714 | if (!m_backend->supportsBufferAge() && | 716 | if (!m_backend->supportsBufferAge() && | ||
715 | options->glPreferBufferSwap() == Options::CopyFrontBuffer && | 717 | options->glPreferBufferSwap() == Options::CopyFrontBuffer && | ||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Line(s) | |||||
964 | { | 966 | { | ||
965 | if (m_lanczosFilter) { | 967 | if (m_lanczosFilter) { | ||
966 | makeOpenGLContextCurrent(); | 968 | makeOpenGLContextCurrent(); | ||
967 | delete m_lanczosFilter; | 969 | delete m_lanczosFilter; | ||
968 | m_lanczosFilter = nullptr; | 970 | m_lanczosFilter = nullptr; | ||
969 | } | 971 | } | ||
970 | } | 972 | } | ||
971 | 973 | | |||
972 | QMatrix4x4 SceneOpenGL2::createProjectionMatrix() const | 974 | QMatrix4x4 SceneOpenGL2::createProjectionMatrix(int rotation) const | ||
973 | { | 975 | { | ||
974 | // Create a perspective projection with a 60° field-of-view, | 976 | // Create a perspective projection with a 60° field-of-view, | ||
975 | // and an aspect ratio of 1.0. | 977 | // and an aspect ratio of 1.0. | ||
976 | const float fovY = 60.0f; | 978 | const float fovY = 60.0f; | ||
977 | const float aspect = 1.0f; | 979 | const float aspect = 1.0f; | ||
978 | const float zNear = 0.1f; | 980 | const float zNear = 0.1f; | ||
979 | const float zFar = 100.0f; | 981 | const float zFar = 100.0f; | ||
980 | 982 | | |||
981 | const float yMax = zNear * std::tan(fovY * M_PI / 360.0f); | 983 | const float yMax = zNear * std::tan(fovY * M_PI / 360.0f); | ||
982 | const float yMin = -yMax; | 984 | const float yMin = -yMax; | ||
983 | const float xMin = yMin * aspect; | 985 | const float xMin = yMin * aspect; | ||
984 | const float xMax = yMax * aspect; | 986 | const float xMax = yMax * aspect; | ||
985 | 987 | | |||
986 | QMatrix4x4 projection; | 988 | QMatrix4x4 projection; | ||
987 | projection.frustum(xMin, xMax, yMin, yMax, zNear, zFar); | 989 | projection.frustum(xMin, xMax, yMin, yMax, zNear, zFar); | ||
990 | if (rotation != 0) { | ||||
991 | projection.rotate(rotation, 0, 0, 1); | ||||
zzag: Missing braces as well spaces after commas. | |||||
992 | } | ||||
988 | 993 | | |||
989 | // Create a second matrix that transforms screen coordinates | 994 | // Create a second matrix that transforms screen coordinates | ||
990 | // to world coordinates. | 995 | // to world coordinates. | ||
991 | const float scaleFactor = 1.1 * std::tan(fovY * M_PI / 360.0f) / yMax; | 996 | const float scaleFactor = 1.1 * std::tan(fovY * M_PI / 360.0f) / yMax; | ||
992 | const QSize size = screens()->size(); | 997 | const QSize size = screens()->size(); | ||
993 | 998 | | |||
994 | QMatrix4x4 matrix; | 999 | QMatrix4x4 matrix; | ||
995 | matrix.translate(xMin * scaleFactor, yMax * scaleFactor, -1.1); | 1000 | matrix.translate(xMin * scaleFactor, yMax * scaleFactor, -1.1); | ||
996 | matrix.scale( (xMax - xMin) * scaleFactor / size.width(), | 1001 | matrix.scale( (xMax - xMin) * scaleFactor / size.width(), | ||
997 | -(yMax - yMin) * scaleFactor / size.height(), | 1002 | -(yMax - yMin) * scaleFactor / size.height(), | ||
998 | 0.001); | 1003 | 0.001); | ||
999 | 1004 | | |||
1000 | // Combine the matrices | 1005 | // Combine the matrices | ||
1001 | return projection * matrix; | 1006 | return projection * matrix; | ||
1002 | } | 1007 | } | ||
1003 | 1008 | | |||
1004 | void SceneOpenGL2::updateProjectionMatrix() | 1009 | void SceneOpenGL2::updateProjectionMatrix(int rotation) | ||
1005 | { | 1010 | { | ||
1006 | m_projectionMatrix = createProjectionMatrix(); | 1011 | m_projectionMatrix = createProjectionMatrix(rotation); | ||
1007 | } | 1012 | } | ||
1008 | 1013 | | |||
1009 | void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region) | 1014 | void SceneOpenGL2::paintSimpleScreen(int mask, QRegion region) | ||
1010 | { | 1015 | { | ||
1011 | m_screenProjectionMatrix = m_projectionMatrix; | 1016 | m_screenProjectionMatrix = m_projectionMatrix; | ||
1012 | 1017 | | |||
1013 | Scene::paintSimpleScreen(mask, region); | 1018 | Scene::paintSimpleScreen(mask, region); | ||
1014 | } | 1019 | } | ||
▲ Show 20 Lines • Show All 1564 Lines • Show Last 20 Lines |
const int rotation