mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-17 00:45:58 +01:00
Internal: move to Mat3x3 from hyprutils (#7902)
* Meson: require hyprutils >= 0.2.3 * flake.lock: update hyprutils --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
8f5188269b
commit
2320b2241c
11 changed files with 93 additions and 268 deletions
|
@ -114,7 +114,7 @@ pkg_check_modules(
|
|||
gio-2.0
|
||||
hyprlang>=0.3.2
|
||||
hyprcursor>=0.1.7
|
||||
hyprutils>=0.2.2)
|
||||
hyprutils>=0.2.3)
|
||||
|
||||
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
|
||||
|
||||
|
|
|
@ -116,11 +116,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726874949,
|
||||
"narHash": "sha256-PNnIpwGqpTvMU3N2r0wMQwK1E+t4Bb5fbJwblQvr+80=",
|
||||
"lastModified": 1727219120,
|
||||
"narHash": "sha256-wmT+JpnDk6EjgASU2VGfS0nnu6oKA4Cw25o5fzpDD/Q=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprutils",
|
||||
"rev": "d97af4f6bd068c03a518b597675e598f57ea2291",
|
||||
"rev": "db956287d3aa194dda91d05c8eb286de2a569edf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -628,27 +628,6 @@ void logSystemInfo() {
|
|||
Debug::log(NONE, "{}", execAndGet("cat /etc/os-release"));
|
||||
}
|
||||
|
||||
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) {
|
||||
memset(mat, 0, sizeof(*mat) * 9);
|
||||
|
||||
const float* t = transforms[tr];
|
||||
float x = 2.0f / w;
|
||||
float y = 2.0f / h;
|
||||
|
||||
// Rotation + reflection
|
||||
mat[0] = x * t[0];
|
||||
mat[1] = x * t[1];
|
||||
mat[3] = y * t[3];
|
||||
mat[4] = y * t[4];
|
||||
|
||||
// Translation
|
||||
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
|
||||
mat[5] = -copysign(1.0f, mat[3] + mat[4]);
|
||||
|
||||
// Identity
|
||||
mat[8] = 1.0f;
|
||||
}
|
||||
|
||||
int64_t getPPIDof(int64_t pid) {
|
||||
#if defined(KERN_PROC_PID)
|
||||
int mib[] = {
|
||||
|
|
|
@ -34,7 +34,6 @@ int64_t getPPIDof(int64_t pid);
|
|||
int64_t configStringToInt(const std::string&);
|
||||
Vector2D configStringToVector2D(const std::string&);
|
||||
std::optional<float> getPlusMinusKeywordResult(std::string in, float relative);
|
||||
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
|
||||
double normalizeAngleRad(double ang);
|
||||
std::vector<SCallstackFrameInfo> getBacktrace();
|
||||
void throwError(const std::string& err);
|
||||
|
|
|
@ -772,12 +772,9 @@ Vector2D CMonitor::middle() {
|
|||
}
|
||||
|
||||
void CMonitor::updateMatrix() {
|
||||
matrixIdentity(projMatrix.data());
|
||||
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||
matrixTranslate(projMatrix.data(), vecPixelSize.x / 2.0, vecPixelSize.y / 2.0);
|
||||
matrixTransform(projMatrix.data(), wlTransformToHyprutils(transform));
|
||||
matrixTranslate(projMatrix.data(), -vecTransformedSize.x / 2.0, -vecTransformedSize.y / 2.0);
|
||||
}
|
||||
projMatrix = Mat3x3::identity();
|
||||
if (transform != WL_OUTPUT_TRANSFORM_NORMAL)
|
||||
projMatrix.translate(vecPixelSize / 2.0).transform(wlTransformToHyprutils(transform)).translate(-vecTransformedSize / 2.0);
|
||||
}
|
||||
|
||||
WORKSPACEID CMonitor::activeWorkspaceID() {
|
||||
|
|
|
@ -96,7 +96,7 @@ class CMonitor {
|
|||
bool scheduledRecalc = false;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
float xwaylandScale = 1.f;
|
||||
std::array<float, 9> projMatrix = {0};
|
||||
Mat3x3 projMatrix;
|
||||
std::optional<Vector2D> forceSize;
|
||||
SP<Aquamarine::SOutputMode> currentMode;
|
||||
SP<Aquamarine::CSwapchain> cursorSwapchain;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include "Math.hpp"
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
|
||||
Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) {
|
||||
switch (t) {
|
||||
|
@ -17,124 +15,6 @@ Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) {
|
|||
return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_NORMAL;
|
||||
}
|
||||
|
||||
void matrixIdentity(float mat[9]) {
|
||||
static const float identity[9] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
memcpy(mat, identity, sizeof(identity));
|
||||
}
|
||||
|
||||
void matrixMultiply(float mat[9], const float a[9], const float b[9]) {
|
||||
float product[9];
|
||||
|
||||
product[0] = a[0] * b[0] + a[1] * b[3] + a[2] * b[6];
|
||||
product[1] = a[0] * b[1] + a[1] * b[4] + a[2] * b[7];
|
||||
product[2] = a[0] * b[2] + a[1] * b[5] + a[2] * b[8];
|
||||
|
||||
product[3] = a[3] * b[0] + a[4] * b[3] + a[5] * b[6];
|
||||
product[4] = a[3] * b[1] + a[4] * b[4] + a[5] * b[7];
|
||||
product[5] = a[3] * b[2] + a[4] * b[5] + a[5] * b[8];
|
||||
|
||||
product[6] = a[6] * b[0] + a[7] * b[3] + a[8] * b[6];
|
||||
product[7] = a[6] * b[1] + a[7] * b[4] + a[8] * b[7];
|
||||
product[8] = a[6] * b[2] + a[7] * b[5] + a[8] * b[8];
|
||||
|
||||
memcpy(mat, product, sizeof(product));
|
||||
}
|
||||
|
||||
void matrixTranspose(float mat[9], const float a[9]) {
|
||||
float transposition[9] = {
|
||||
a[0], a[3], a[6], a[1], a[4], a[7], a[2], a[5], a[8],
|
||||
};
|
||||
memcpy(mat, transposition, sizeof(transposition));
|
||||
}
|
||||
|
||||
void matrixTranslate(float mat[9], float x, float y) {
|
||||
float translate[9] = {
|
||||
1.0f, 0.0f, x, 0.0f, 1.0f, y, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
matrixMultiply(mat, mat, translate);
|
||||
}
|
||||
|
||||
void matrixScale(float mat[9], float x, float y) {
|
||||
float scale[9] = {
|
||||
x, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
matrixMultiply(mat, mat, scale);
|
||||
}
|
||||
|
||||
void matrixRotate(float mat[9], float rad) {
|
||||
float rotate[9] = {
|
||||
cos(rad), -sin(rad), 0.0f, sin(rad), cos(rad), 0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
matrixMultiply(mat, mat, rotate);
|
||||
}
|
||||
|
||||
const std::unordered_map<eTransform, std::array<float, 9>>& getTransforms() {
|
||||
static std::unordered_map<eTransform, std::array<float, 9>> transforms = {
|
||||
{HYPRUTILS_TRANSFORM_NORMAL, {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_90, {0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_180, {-1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_270, {0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_FLIPPED, {-1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_FLIPPED_90, {0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_FLIPPED_180, {1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
{HYPRUTILS_TRANSFORM_FLIPPED_270, {0.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}},
|
||||
};
|
||||
return transforms;
|
||||
}
|
||||
|
||||
void matrixTransform(float mat[9], eTransform transform) {
|
||||
matrixMultiply(mat, mat, getTransforms().at(transform).data());
|
||||
}
|
||||
|
||||
void matrixProjection(float mat[9], int width, int height, eTransform transform) {
|
||||
memset(mat, 0, sizeof(*mat) * 9);
|
||||
|
||||
const float* t = getTransforms().at(transform).data();
|
||||
float x = 2.0f / width;
|
||||
float y = 2.0f / height;
|
||||
|
||||
// Rotation + reflection
|
||||
mat[0] = x * t[0];
|
||||
mat[1] = x * t[1];
|
||||
mat[3] = y * -t[3];
|
||||
mat[4] = y * -t[4];
|
||||
|
||||
// Translation
|
||||
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
|
||||
mat[5] = -copysign(1.0f, mat[3] + mat[4]);
|
||||
|
||||
// Identity
|
||||
mat[8] = 1.0f;
|
||||
}
|
||||
|
||||
void projectBox(float mat[9], CBox& box, eTransform transform, float rotation, const float projection[9]) {
|
||||
double x = box.x;
|
||||
double y = box.y;
|
||||
double width = box.width;
|
||||
double height = box.height;
|
||||
|
||||
matrixIdentity(mat);
|
||||
matrixTranslate(mat, x, y);
|
||||
|
||||
if (rotation != 0) {
|
||||
matrixTranslate(mat, width / 2, height / 2);
|
||||
matrixRotate(mat, rotation);
|
||||
matrixTranslate(mat, -width / 2, -height / 2);
|
||||
}
|
||||
|
||||
matrixScale(mat, width, height);
|
||||
|
||||
if (transform != HYPRUTILS_TRANSFORM_NORMAL) {
|
||||
matrixTranslate(mat, 0.5, 0.5);
|
||||
matrixTransform(mat, transform);
|
||||
matrixTranslate(mat, -0.5, -0.5);
|
||||
}
|
||||
|
||||
matrixMultiply(mat, projection, mat);
|
||||
}
|
||||
|
||||
wl_output_transform invertTransform(wl_output_transform tr) {
|
||||
if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED))
|
||||
tr = (wl_output_transform)(tr ^ (int)WL_OUTPUT_TRANSFORM_180);
|
||||
|
|
|
@ -4,17 +4,9 @@
|
|||
|
||||
// includes box and vector as well
|
||||
#include <hyprutils/math/Region.hpp>
|
||||
#include <hyprutils/math/Mat3x3.hpp>
|
||||
|
||||
using namespace Hyprutils::Math;
|
||||
|
||||
eTransform wlTransformToHyprutils(wl_output_transform t);
|
||||
void projectBox(float mat[9], CBox& box, eTransform transform, float rotation, const float projection[9]);
|
||||
void matrixProjection(float mat[9], int width, int height, eTransform transform);
|
||||
void matrixTransform(float mat[9], eTransform transform);
|
||||
void matrixRotate(float mat[9], float rad);
|
||||
void matrixScale(float mat[9], float x, float y);
|
||||
void matrixTranslate(float mat[9], float x, float y);
|
||||
void matrixTranspose(float mat[9], const float a[9]);
|
||||
void matrixMultiply(float mat[9], const float a[9], const float b[9]);
|
||||
void matrixIdentity(float mat[9]);
|
||||
wl_output_transform invertTransform(wl_output_transform tr);
|
||||
|
|
|
@ -16,7 +16,7 @@ executable(
|
|||
dependency('cairo'),
|
||||
dependency('hyprcursor', version: '>=0.1.7'),
|
||||
dependency('hyprlang', version: '>= 0.3.2'),
|
||||
dependency('hyprutils', version: '>= 0.2.1'),
|
||||
dependency('hyprutils', version: '>= 0.2.3'),
|
||||
dependency('libdrm'),
|
||||
dependency('egl'),
|
||||
dependency('xkbcommon'),
|
||||
|
|
|
@ -755,14 +755,12 @@ void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, SP<
|
|||
|
||||
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
|
||||
|
||||
matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
m_RenderData.projection = Mat3x3::outputProjection(pMonitor->vecPixelSize, HYPRUTILS_TRANSFORM_NORMAL);
|
||||
|
||||
matrixIdentity(m_RenderData.monitorProjection.data());
|
||||
m_RenderData.monitorProjection = Mat3x3::identity();
|
||||
if (pMonitor->transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||
const Vector2D tfmd = pMonitor->transform % 2 == 1 ? Vector2D{FBO->m_vSize.y, FBO->m_vSize.x} : FBO->m_vSize;
|
||||
matrixTranslate(m_RenderData.monitorProjection.data(), FBO->m_vSize.x / 2.0, FBO->m_vSize.y / 2.0);
|
||||
matrixTransform(m_RenderData.monitorProjection.data(), wlTransformToHyprutils(pMonitor->transform));
|
||||
matrixTranslate(m_RenderData.monitorProjection.data(), -tfmd.x / 2.0, -tfmd.y / 2.0);
|
||||
m_RenderData.monitorProjection.translate(FBO->m_vSize / 2.0).transform(wlTransformToHyprutils(pMonitor->transform)).translate(-tfmd / 2.0);
|
||||
}
|
||||
|
||||
m_RenderData.pCurrentMonData = &m_mMonitorRenderResources[pMonitor];
|
||||
|
@ -809,7 +807,7 @@ void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebu
|
|||
|
||||
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
|
||||
|
||||
matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
|
||||
m_RenderData.projection = Mat3x3::outputProjection(pMonitor->vecPixelSize, HYPRUTILS_TRANSFORM_NORMAL);
|
||||
|
||||
m_RenderData.monitorProjection = pMonitor->projMatrix;
|
||||
|
||||
|
@ -1289,20 +1287,17 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CColor& col, CRegion
|
|||
|
||||
box = &newBox;
|
||||
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||
m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(
|
||||
newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
glUseProgram(m_RenderData.pCurrentMonData->m_shQUAD.program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
|
||||
// premultiply the color as well as we don't work with straight alpha
|
||||
|
@ -1386,11 +1381,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, CBox* pB
|
|||
if (m_bEndFrame || TRANSFORMS_MATCH)
|
||||
TRANSFORM = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform));
|
||||
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
Debug::log(LOG, "internal:\nmat: {},\nglmat: {}", matrix.toString(), glMatrix.toString());
|
||||
|
||||
if (waitTimeline != nullptr) {
|
||||
if (!waitForTimelinePoint(waitTimeline, waitPoint)) {
|
||||
|
@ -1442,10 +1436,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, CBox* pB
|
|||
glUseProgram(shader->program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1i(shader->tex, 0);
|
||||
|
||||
|
@ -1556,13 +1550,10 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP<CTexture> tex, CBox* pBox) {
|
|||
|
||||
// get transform
|
||||
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform));
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
||||
CShader* shader = &m_RenderData.pCurrentMonData->m_shPASSTHRURGBA;
|
||||
CShader* shader = &m_RenderData.pCurrentMonData->m_shPASSTHRURGBA;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(tex->m_iTarget, tex->m_iTexID);
|
||||
|
@ -1570,10 +1561,10 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP<CTexture> tex, CBox* pBox) {
|
|||
glUseProgram(shader->program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1i(shader->tex, 0);
|
||||
|
||||
|
@ -1610,21 +1601,18 @@ void CHyprOpenGLImpl::renderTextureMatte(SP<CTexture> tex, CBox* pBox, CFramebuf
|
|||
|
||||
// get transform
|
||||
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform));
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
||||
CShader* shader = &m_RenderData.pCurrentMonData->m_shMATTE;
|
||||
CShader* shader = &m_RenderData.pCurrentMonData->m_shMATTE;
|
||||
|
||||
glUseProgram(shader->program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1i(shader->tex, 0);
|
||||
glUniform1i(shader->alphaMatte, 1);
|
||||
|
@ -1667,13 +1655,10 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
|||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
// get transforms for the full monitor
|
||||
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform));
|
||||
float matrix[9];
|
||||
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(m_RenderData.pMonitor->transform));
|
||||
CBox MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
projectBox(matrix, MONITORBOX, TRANSFORM, 0, m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(MONITORBOX, TRANSFORM);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
// get the config settings
|
||||
static auto PBLURSIZE = CConfigValue<Hyprlang::INT>("decoration:blur:size");
|
||||
|
@ -1710,10 +1695,10 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
|||
glUseProgram(m_RenderData.pCurrentMonData->m_shBLURPREPARE.program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURPREPARE.proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURPREPARE.proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURPREPARE.proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURPREPARE.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBLURPREPARE.contrast, *PBLURCONTRAST);
|
||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBLURPREPARE.brightness, *PBLURBRIGHTNESS);
|
||||
|
@ -1755,10 +1740,10 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
|||
|
||||
// prep two shaders
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(pShader->proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(pShader->proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1f(pShader->radius, *PBLURSIZE * a); // this makes the blursize change with a
|
||||
if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1) {
|
||||
|
@ -1832,10 +1817,10 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
|||
glUseProgram(m_RenderData.pCurrentMonData->m_shBLURFINISH.program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURFINISH.proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURFINISH.proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURFINISH.proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBLURFINISH.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBLURFINISH.noise, *PBLURNOISE);
|
||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBLURFINISH.brightness, *PBLURBRIGHTNESS);
|
||||
|
@ -2165,12 +2150,9 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
|||
|
||||
round += round == 0 ? 0 : scaledBorderSize;
|
||||
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||
m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(
|
||||
newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
const auto BLEND = m_bBlend;
|
||||
blend(true);
|
||||
|
@ -2178,10 +2160,10 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
|||
glUseProgram(m_RenderData.pCurrentMonData->m_shBORDER1.program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
|
||||
static_assert(sizeof(CColor) == 4 * sizeof(float)); // otherwise the line below this will fail
|
||||
|
@ -2471,22 +2453,19 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
|
|||
|
||||
const auto col = color;
|
||||
|
||||
float matrix[9];
|
||||
projectBox(matrix, newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||
m_RenderData.monitorProjection.data());
|
||||
|
||||
float glMatrix[9];
|
||||
matrixMultiply(glMatrix, m_RenderData.projection, matrix);
|
||||
Mat3x3 matrix = m_RenderData.monitorProjection.projectBox(
|
||||
newBox, wlTransformToHyprutils(invertTransform(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot);
|
||||
Mat3x3 glMatrix = m_RenderData.projection.copy().multiply(matrix);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glUseProgram(m_RenderData.pCurrentMonData->m_shSHADOW.program);
|
||||
|
||||
#ifndef GLES2
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_TRUE, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||
#else
|
||||
matrixTranspose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_FALSE, glMatrix);
|
||||
glMatrix.transpose();
|
||||
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_FALSE, glMatrix.getMatrix().data());
|
||||
#endif
|
||||
glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r, col.g, col.b, col.a * a);
|
||||
|
||||
|
@ -2565,11 +2544,11 @@ void CHyprOpenGLImpl::renderMirrored() {
|
|||
return;
|
||||
|
||||
// replace monitor projection to undo the mirrored monitor's projection
|
||||
matrixIdentity(m_RenderData.monitorProjection.data());
|
||||
matrixTranslate(m_RenderData.monitorProjection.data(), monitor->vecPixelSize.x / 2.0, monitor->vecPixelSize.y / 2.0);
|
||||
matrixTransform(m_RenderData.monitorProjection.data(), wlTransformToHyprutils(monitor->transform));
|
||||
matrixTransform(m_RenderData.monitorProjection.data(), wlTransformToHyprutils(invertTransform(mirrored->transform)));
|
||||
matrixTranslate(m_RenderData.monitorProjection.data(), -monitor->vecTransformedSize.x / 2.0, -monitor->vecTransformedSize.y / 2.0);
|
||||
m_RenderData.monitorProjection = Mat3x3::identity()
|
||||
.translate(monitor->vecPixelSize / 2.0)
|
||||
.transform(wlTransformToHyprutils(monitor->transform))
|
||||
.transform(wlTransformToHyprutils(invertTransform(mirrored->transform)))
|
||||
.translate(-monitor->vecTransformedSize / 2.0);
|
||||
|
||||
// clear stuff outside of mirrored area (e.g. when changing to mirrored)
|
||||
clear(CColor(0, 0, 0, 0));
|
||||
|
@ -2920,16 +2899,15 @@ void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
|
|||
}
|
||||
|
||||
void CHyprOpenGLImpl::saveMatrix() {
|
||||
memcpy(m_RenderData.savedProjection, m_RenderData.projection, 9 * sizeof(float));
|
||||
m_RenderData.savedProjection = m_RenderData.projection;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::setMatrixScaleTranslate(const Vector2D& translate, const float& scale) {
|
||||
matrixScale(m_RenderData.projection, scale, scale);
|
||||
matrixTranslate(m_RenderData.projection, translate.x, translate.y);
|
||||
m_RenderData.projection.scale(scale).translate(translate);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::restoreMatrix() {
|
||||
memcpy(m_RenderData.projection, m_RenderData.savedProjection, 9 * sizeof(float));
|
||||
m_RenderData.projection = m_RenderData.savedProjection;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::bindOffMain() {
|
||||
|
|
|
@ -94,35 +94,35 @@ struct SMonitorRenderData {
|
|||
};
|
||||
|
||||
struct SCurrentRenderData {
|
||||
CMonitor* pMonitor = nullptr;
|
||||
PHLWORKSPACE pWorkspace = nullptr;
|
||||
float projection[9];
|
||||
float savedProjection[9];
|
||||
std::array<float, 9> monitorProjection;
|
||||
CMonitor* pMonitor = nullptr;
|
||||
PHLWORKSPACE pWorkspace = nullptr;
|
||||
Mat3x3 projection;
|
||||
Mat3x3 savedProjection;
|
||||
Mat3x3 monitorProjection;
|
||||
|
||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||
CFramebuffer* currentFB = nullptr; // current rendering to
|
||||
CFramebuffer* mainFB = nullptr; // main to render to
|
||||
CFramebuffer* outFB = nullptr; // out to render to (if offloaded, etc)
|
||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||
CFramebuffer* currentFB = nullptr; // current rendering to
|
||||
CFramebuffer* mainFB = nullptr; // main to render to
|
||||
CFramebuffer* outFB = nullptr; // out to render to (if offloaded, etc)
|
||||
|
||||
CRegion damage;
|
||||
CRegion finalDamage; // damage used for funal off -> main
|
||||
CRegion damage;
|
||||
CRegion finalDamage; // damage used for funal off -> main
|
||||
|
||||
SRenderModifData renderModif;
|
||||
float mouseZoomFactor = 1.f;
|
||||
bool mouseZoomUseMouse = true; // true by default
|
||||
bool useNearestNeighbor = false;
|
||||
bool forceIntrospection = false; // cleaned in ::end()
|
||||
bool blockScreenShader = false;
|
||||
bool simplePass = false;
|
||||
SRenderModifData renderModif;
|
||||
float mouseZoomFactor = 1.f;
|
||||
bool mouseZoomUseMouse = true; // true by default
|
||||
bool useNearestNeighbor = false;
|
||||
bool forceIntrospection = false; // cleaned in ::end()
|
||||
bool blockScreenShader = false;
|
||||
bool simplePass = false;
|
||||
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
|
||||
CBox clipBox = {}; // scaled coordinates
|
||||
CBox clipBox = {}; // scaled coordinates
|
||||
|
||||
uint32_t discardMode = DISCARD_OPAQUE;
|
||||
float discardOpacity = 0.f;
|
||||
uint32_t discardMode = DISCARD_OPAQUE;
|
||||
float discardOpacity = 0.f;
|
||||
};
|
||||
|
||||
class CEGLSync {
|
||||
|
|
Loading…
Reference in a new issue