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