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