mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 03:05:59 +01:00
renderer: overhaul renderModifData
This commit is contained in:
parent
9f2bde925b
commit
44ee9915e3
4 changed files with 53 additions and 16 deletions
|
@ -73,6 +73,8 @@ class CBox {
|
||||||
double height;
|
double height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
double rot = 0; /* rad, ccw */
|
||||||
|
|
||||||
//
|
//
|
||||||
bool operator==(const CBox& rhs) const {
|
bool operator==(const CBox& rhs) const {
|
||||||
return x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h;
|
return x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h;
|
||||||
|
|
|
@ -637,7 +637,7 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CColor& col, CRegion
|
||||||
TRACY_GPU_ZONE("RenderRectWithDamage");
|
TRACY_GPU_ZONE("RenderRectWithDamage");
|
||||||
|
|
||||||
CBox newBox = *box;
|
CBox newBox = *box;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
box = &newBox;
|
box = &newBox;
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, CBox*
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CBox newBox = *pBox;
|
CBox newBox = *pBox;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
static auto* const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
|
static auto* const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(const CTexture& tex, CBox* pBox) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CBox newBox = *pBox;
|
CBox newBox = *pBox;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||||
|
@ -940,7 +940,7 @@ void CHyprOpenGLImpl::renderTextureMatte(const CTexture& tex, CBox* pBox, CFrame
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CBox newBox = *pBox;
|
CBox newBox = *pBox;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||||
|
@ -1475,14 +1475,14 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CBox newBox = *box;
|
CBox newBox = *box;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
box = &newBox;
|
box = &newBox;
|
||||||
|
|
||||||
if (borderSize < 1)
|
if (borderSize < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int scaledBorderSize = std::round(borderSize * m_RenderData.pMonitor->scale * m_RenderData.renderModif.scale);
|
int scaledBorderSize = std::round(borderSize * m_RenderData.pMonitor->scale);
|
||||||
|
|
||||||
// adjust box
|
// adjust box
|
||||||
box->x -= scaledBorderSize;
|
box->x -= scaledBorderSize;
|
||||||
|
@ -1779,7 +1779,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
|
||||||
TRACY_GPU_ZONE("RenderShadow");
|
TRACY_GPU_ZONE("RenderShadow");
|
||||||
|
|
||||||
CBox newBox = *box;
|
CBox newBox = *box;
|
||||||
newBox.scale(m_RenderData.renderModif.scale).translate(m_RenderData.renderModif.translate);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
box = &newBox;
|
box = &newBox;
|
||||||
|
|
||||||
|
@ -2211,3 +2211,25 @@ const SGLPixelFormat* CHyprOpenGLImpl::getPixelFormatFromDRM(uint32_t drmFormat)
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SRenderModifData::applyToBox(CBox& box) {
|
||||||
|
for (auto& [type, val] : modifs) {
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case RMOD_TYPE_SCALE: box.scale(std::any_cast<float>(val)); break;
|
||||||
|
case RMOD_TYPE_SCALECENTER: box.scaleFromCenter(std::any_cast<float>(val)); break;
|
||||||
|
case RMOD_TYPE_TRANSLATE: box.translate(std::any_cast<Vector2D>(val)); break;
|
||||||
|
case RMOD_TYPE_ROTATE: box.rot += std::any_cast<float>(val); break;
|
||||||
|
case RMOD_TYPE_ROTATECENTER: {
|
||||||
|
const auto THETA = std::any_cast<float>(val);
|
||||||
|
const double COS = std::cos(THETA);
|
||||||
|
const double SIN = std::sin(THETA);
|
||||||
|
box.rot += THETA;
|
||||||
|
const auto OLDPOS = box.pos();
|
||||||
|
box.x = OLDPOS.x * COS - OLDPOS.y * SIN;
|
||||||
|
box.y = OLDPOS.y * COS + OLDPOS.x * SIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (std::bad_any_cast& e) { Debug::log(ERR, "BUG THIS OR PLUGIN ERROR: caught a bad_any_cast in SRenderModifData::applyToBox!"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,8 +36,17 @@ enum eDiscardMode {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SRenderModifData {
|
struct SRenderModifData {
|
||||||
Vector2D translate = {};
|
enum eRenderModifType {
|
||||||
float scale = 1.f;
|
RMOD_TYPE_SCALE, /* scale by a float */
|
||||||
|
RMOD_TYPE_SCALECENTER, /* scale by a float from the center */
|
||||||
|
RMOD_TYPE_TRANSLATE, /* translate by a Vector2D */
|
||||||
|
RMOD_TYPE_ROTATE, /* rotate by a float in rad from top left */
|
||||||
|
RMOD_TYPE_ROTATECENTER, /* rotate by a float in rad from center */
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::pair<eRenderModifType, std::any>> modifs;
|
||||||
|
|
||||||
|
void applyToBox(CBox& box);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SGLPixelFormat {
|
struct SGLPixelFormat {
|
||||||
|
|
|
@ -659,7 +659,11 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
|
||||||
static auto* const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
|
static auto* const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
|
||||||
static auto* const PBACKGROUNDCOLOR = &g_pConfigManager->getConfigValuePtr("misc:background_color")->intValue;
|
static auto* const PBACKGROUNDCOLOR = &g_pConfigManager->getConfigValuePtr("misc:background_color")->intValue;
|
||||||
|
|
||||||
const SRenderModifData RENDERMODIFDATA = {translate, scale};
|
SRenderModifData RENDERMODIFDATA;
|
||||||
|
if (translate != Vector2D{0, 0})
|
||||||
|
RENDERMODIFDATA.modifs.push_back({SRenderModifData::eRenderModifType::RMOD_TYPE_TRANSLATE, translate});
|
||||||
|
if (scale != 1.f)
|
||||||
|
RENDERMODIFDATA.modifs.push_back({SRenderModifData::eRenderModifType::RMOD_TYPE_SCALE, scale});
|
||||||
|
|
||||||
if (!pMonitor)
|
if (!pMonitor)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue