aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-05-01 02:49:41 +0100
committervaxerski <[email protected]>2023-05-01 02:49:41 +0100
commitddfeebad3deac7d70350db40868bd67cb708d407 (patch)
treea828d5447cfdfcb11192d336d125504e5a4ed371
parent11e87986a2b37768711ddf4a510775cc1c6a9220 (diff)
downloadHyprland-ddfeebad3deac7d70350db40868bd67cb708d407.tar.gz
Hyprland-ddfeebad3deac7d70350db40868bd67cb708d407.zip
Renderer: add init animation
-rw-r--r--src/render/OpenGL.cpp27
-rw-r--r--src/render/OpenGL.hpp1
-rw-r--r--src/render/Renderer.cpp20
-rw-r--r--src/render/Renderer.hpp3
4 files changed, 39 insertions, 12 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 5eecdfdf..0acf2bb7 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -158,12 +158,13 @@ void CHyprOpenGLImpl::end() {
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
if (m_RenderData.mouseZoomFactor != 1.f) {
- const auto MOUSEPOS = g_pInputManager->getMouseCoordsInternal() - m_RenderData.pMonitor->vecPosition;
- monbox.x -= MOUSEPOS.x;
- monbox.y -= MOUSEPOS.y;
+ const auto ZOOMCENTER =
+ m_RenderData.mouseZoomUseMouse ? g_pInputManager->getMouseCoordsInternal() - m_RenderData.pMonitor->vecPosition : m_RenderData.pMonitor->vecSize / 2.f;
+ monbox.x -= ZOOMCENTER.x;
+ monbox.y -= ZOOMCENTER.y;
scaleBox(&monbox, m_RenderData.mouseZoomFactor);
- monbox.x += *PZOOMRIGID ? m_RenderData.pMonitor->vecTransformedSize.x / 2 : MOUSEPOS.x;
- monbox.y += *PZOOMRIGID ? m_RenderData.pMonitor->vecTransformedSize.y / 2 : MOUSEPOS.y;
+ monbox.x += *PZOOMRIGID ? m_RenderData.pMonitor->vecTransformedSize.x / 2 : ZOOMCENTER.x;
+ monbox.y += *PZOOMRIGID ? m_RenderData.pMonitor->vecTransformedSize.y / 2 : ZOOMCENTER.y;
if (monbox.x > 0)
monbox.x = 0;
@@ -177,9 +178,10 @@ void CHyprOpenGLImpl::end() {
clear(CColor(11.0 / 255.0, 11.0 / 255.0, 11.0 / 255.0, 1.0));
- m_bEndFrame = true;
- m_bApplyFinalShader = true;
- m_RenderData.useNearestNeighbor = true;
+ m_bEndFrame = true;
+ m_bApplyFinalShader = true;
+ if (m_RenderData.mouseZoomUseMouse)
+ m_RenderData.useNearestNeighbor = true;
renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &monbox, 1.f, 0);
@@ -189,9 +191,10 @@ void CHyprOpenGLImpl::end() {
}
// reset our data
- m_RenderData.pMonitor = nullptr;
- m_iWLROutputFb = 0;
- m_RenderData.mouseZoomFactor = 1.f;
+ m_RenderData.pMonitor = nullptr;
+ m_iWLROutputFb = 0;
+ m_RenderData.mouseZoomFactor = 1.f;
+ m_RenderData.mouseZoomUseMouse = true;
}
void CHyprOpenGLImpl::initShaders() {
@@ -816,7 +819,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
}
void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) {
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace);
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace);
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(pMonitor->activeWorkspace);
if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL && PFULLWINDOW && !PFULLWINDOW->m_vRealSize.isBeingAnimated() &&
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index be65cb85..1b9c3c8d 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -76,6 +76,7 @@ struct SCurrentRenderData {
SRenderModifData renderModif;
float mouseZoomFactor = 1.f;
+ bool mouseZoomUseMouse = true; // true by default
bool useNearestNeighbor = false;
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 0962feb8..62a0ac05 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -788,6 +788,20 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
if (!*PDAMAGEBLINK)
damageBlinkCleanup = 0;
+ static bool firstLaunch = true;
+
+ float zoomInFactorFirstLaunch = 1.f;
+
+ if (firstLaunch) {
+ firstLaunch = false;
+ m_tRenderTimer.reset();
+ }
+
+ if (m_tRenderTimer.getSeconds() < 1.5f) { // TODO: make the animation system more damage-flexible so that this can be migrated to there
+ zoomInFactorFirstLaunch = 2.f - g_pAnimationManager->getBezier("default")->getYForPoint(m_tRenderTimer.getSeconds() / 1.5);
+ damageMonitor(pMonitor);
+ }
+
startRender = std::chrono::high_resolution_clock::now();
if (*PDEBUGOVERLAY == 1) {
@@ -970,6 +984,12 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
else
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f;
+ if (zoomInFactorFirstLaunch > 1.f) {
+ g_pHyprOpenGL->m_RenderData.mouseZoomFactor = zoomInFactorFirstLaunch;
+ g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = false;
+ g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
+ }
+
EMIT_HOOK_EVENT("render", RENDER_LAST_MOMENT);
g_pHyprOpenGL->end();
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index c882a478..3e73287c 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -6,6 +6,7 @@
#include "../helpers/Workspace.hpp"
#include "../Window.hpp"
#include "OpenGL.hpp"
+#include "../helpers/Timer.hpp"
struct SMonitorRule;
@@ -69,6 +70,8 @@ class CHyprRenderer {
float m_fCrashingDistort = 0.5f;
wl_event_source* m_pCrashingLoop = nullptr;
+ CTimer m_tRenderTimer;
+
private:
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);