From d0ff0c0990db230999cc918f1d6230c4a18d08c8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 29 May 2022 12:27:45 +0200 Subject: Added basic monitor transforms, has bugs blur doesnt work on transformed outputs full damage tracking issues --- src/render/OpenGL.cpp | 33 +++++++++++++++++++++++---------- src/render/OpenGL.hpp | 1 + src/render/Renderer.cpp | 11 +++++++++-- 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index e5a95ec1..40fc100c 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -166,13 +166,17 @@ void CHyprOpenGLImpl::end() { // end the render, copy the data to the WLR framebuffer if (!m_bFakeFrame) { glBindFramebuffer(GL_FRAMEBUFFER, m_iWLROutputFb); - wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; + wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; pixman_region32_copy(m_RenderData.pDamage, &m_rOriginalDamageRegion); clear(CColor(11, 11, 11, 255)); + m_bEndFrame = true; + renderTexture(m_mMonitorRenderResources[m_RenderData.pMonitor].primaryFB.m_cTex, &monbox, 255.f, 0); + + m_bEndFrame = false; } // reset our data @@ -205,7 +209,15 @@ void CHyprOpenGLImpl::scissor(const wlr_box* pBox) { return; } - glScissor(pBox->x, pBox->y, pBox->width, pBox->height); + wlr_box newBox = *pBox; + + int w, h; + wlr_output_transformed_resolution(m_RenderData.pMonitor->output, &w, &h); + + const auto TR = wlr_output_transform_invert(m_RenderData.pMonitor->transform); + wlr_box_transform(&newBox, &newBox, TR, w, h); + + glScissor(newBox.x, newBox.y, newBox.width, newBox.height); glEnable(GL_SCISSOR_TEST); } @@ -217,8 +229,9 @@ void CHyprOpenGLImpl::scissor(const pixman_box32* pBox) { return; } - glScissor(pBox->x1, pBox->y1, pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - glEnable(GL_SCISSOR_TEST); + wlr_box newBox = {pBox->x1, pBox->y1, pBox->x2 - pBox->x1, pBox->y2 - pBox->y1}; + + scissor(&newBox); } void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h) { @@ -231,7 +244,7 @@ void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) { RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); float matrix[9]; - wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here + wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); @@ -296,7 +309,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); // get transform - const auto TRANSFORM = wlr_output_transform_invert(WL_OUTPUT_TRANSFORM_NORMAL); + const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform); float matrix[9]; wlr_matrix_project_box(matrix, pBox, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix); @@ -408,7 +421,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p glDisable(GL_STENCIL_TEST); // get transforms for the full monitor - const auto TRANSFORM = wlr_output_transform_invert(WL_OUTPUT_TRANSFORM_NORMAL); + const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform); float matrix[9]; wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix); @@ -817,10 +830,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) { // get the adequate tex std::string texPath = "/usr/share/hyprland/wall_"; Vector2D textureSize; - if (pMonitor->vecSize.x > 7000) { + if (pMonitor->vecTransformedSize.x > 7000) { textureSize = Vector2D(7680, 4320); texPath += "8K.png"; - } else if (pMonitor->vecSize.x > 3000) { + } else if (pMonitor->vecTransformedSize.x > 3000) { textureSize = Vector2D(3840, 2160); texPath += "4K.png"; } else { @@ -853,7 +866,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) { void CHyprOpenGLImpl::clearWithTex() { RASSERT(m_RenderData.pMonitor, "Tried to render BGtex without begin()!"); - wlr_box box = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; + wlr_box box = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; renderTexture(m_mMonitorBGTextures[m_RenderData.pMonitor], &box, 255, 0); } diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index fa193057..34eef478 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -92,6 +92,7 @@ private: std::string m_szExtensions; bool m_bFakeFrame = false; + bool m_bEndFrame = false; // Shaders SQuad m_shQUAD; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 86ab125d..52a17808 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -552,7 +552,7 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str()); // Check if the rule isn't already applied - if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) { + if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1) && pMonitor->transform == pMonitorRule->transform) { Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str()); return; } @@ -616,8 +616,10 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR pMonitor->vecSize = pMonitorRule->resolution; } + wlr_output_set_transform(pMonitor->output, pMonitorRule->transform); + pMonitor->transform = pMonitorRule->transform; + pMonitor->vecPixelSize = pMonitor->vecSize; - pMonitor->vecSize = (pMonitor->vecSize / pMonitor->scale).floor(); // update renderer g_pHyprOpenGL->destroyMonitorResources(pMonitor); @@ -627,6 +629,11 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR return; } + int x, y; + wlr_output_transformed_resolution(pMonitor->output, &x, &y); + pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor(); + pMonitor->vecTransformedSize = Vector2D(x,y); + wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitorRule->offset.x, (int)pMonitorRule->offset.y); //wlr_output_damage_add_whole(pMonitor->damage); -- cgit v1.2.3 From 9842730f570b118275191fd2b3e8910648ab7b05 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 29 May 2022 15:44:30 +0200 Subject: Added fullscreen types, maximize and full --- src/render/OpenGL.cpp | 6 +++--- src/render/Renderer.cpp | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/render') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 40fc100c..118f902b 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -421,7 +421,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p glDisable(GL_STENCIL_TEST); // get transforms for the full monitor - const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform); + const auto TRANSFORM = wlr_output_transform_invert(WL_OUTPUT_TRANSFORM_NORMAL); float matrix[9]; wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix); @@ -547,7 +547,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, pixman_region32_t inverseOpaque; pixman_region32_init(&inverseOpaque); if (a == 255.f) { - pixman_box32_t monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; + pixman_box32_t monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; pixman_region32_copy(&inverseOpaque, &pSurface->current.opaque); pixman_region32_translate(&inverseOpaque, pBox->x, pBox->y); pixman_region32_inverse(&inverseOpaque, &inverseOpaque, &monbox); @@ -585,7 +585,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // stencil done. Render everything. - wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y}; + wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; if (pixman_region32_not_empty(&damage)) { // render our great blurred FB renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, g_pConfigManager->getInt("decoration:blur_ignore_opacity") ? 255.f : a, &damage); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 52a17808..02824920 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -57,7 +57,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor continue; // found it! - renderWindow(&w, pMonitor, time, false); + renderWindow(&w, pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL); pWorkspaceWindow = &w; } @@ -71,6 +71,13 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor } // and the overlay layers + if (pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL) { + // on non-full we draw the bar and shit + for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { + renderLayer(ls, pMonitor, time); + } + } + for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) { renderLayer(ls, pMonitor, time); } @@ -98,7 +105,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow); renderdata.w = std::clamp(pWindow->m_vRealSize.vec().x, (double)5, (double)1337420); // clamp the size to min 5, renderdata.h = std::clamp(pWindow->m_vRealSize.vec().y, (double)5, (double)1337420); // otherwise we'll have issues later with invalid boxes - renderdata.dontRound = pWindow->m_bIsFullscreen; + renderdata.dontRound = pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL; renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f); renderdata.alpha = pWindow->m_bIsFullscreen ? g_pConfigManager->getFloat("decoration:fullscreen_opacity") : pWindow == g_pCompositor->m_pLastWindow ? g_pConfigManager->getFloat("decoration:active_opacity") : g_pConfigManager->getFloat("decoration:inactive_opacity"); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders; -- cgit v1.2.3