core: move colorspace handling to oklab (#8635)
* Meson: add hyprgraphics * Nix: add hyprgraphics * CI/setup_base: get hyprgraphics-git --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
92186898c0
commit
320144ae72
40 changed files with 492 additions and 173 deletions
|
|
@ -8,6 +8,8 @@
|
|||
#include "eventLoop/EventLoopManager.hpp"
|
||||
#include "../helpers/varlist/VarList.hpp"
|
||||
|
||||
#include <hyprgraphics/color/Color.hpp>
|
||||
|
||||
int wlTick(SP<CEventLoopTimer> self, void* data) {
|
||||
if (g_pAnimationManager)
|
||||
g_pAnimationManager->onTicked();
|
||||
|
|
@ -154,7 +156,7 @@ void CAnimationManager::tick() {
|
|||
// beziers are with a switch unforto
|
||||
// TODO: maybe do something cleaner
|
||||
|
||||
auto updateVariable = [&]<Animable T>(CAnimatedVariable<T>& av) {
|
||||
static const auto updateVariable = [&]<Animable T>(CAnimatedVariable<T>& av) {
|
||||
// for disabled anims just warp
|
||||
if (av.m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
||||
av.warp(false);
|
||||
|
|
@ -166,13 +168,50 @@ void CAnimationManager::tick() {
|
|||
return;
|
||||
}
|
||||
|
||||
const auto DELTA = av.m_Goal - av.m_Begun;
|
||||
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
||||
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER->second.getYForPoint(SPENT);
|
||||
|
||||
const auto DELTA = av.m_Goal - av.m_Begun;
|
||||
|
||||
if (BEZIER != m_mBezierCurves.end())
|
||||
av.m_Value = av.m_Begun + DELTA * BEZIER->second.getYForPoint(SPENT);
|
||||
av.m_Value = av.m_Begun + DELTA * POINTY;
|
||||
else
|
||||
av.m_Value = av.m_Begun + DELTA * DEFAULTBEZIER->second.getYForPoint(SPENT);
|
||||
av.m_Value = av.m_Begun + DELTA * POINTY;
|
||||
};
|
||||
|
||||
static const auto updateColorVariable = [&](CAnimatedVariable<CHyprColor>& av) {
|
||||
// for disabled anims just warp
|
||||
if (av.m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
|
||||
av.warp(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SPENT >= 1.f || av.m_Begun == av.m_Goal) {
|
||||
av.warp(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto BEZIER = m_mBezierCurves.find(av.m_pConfig->pValues->internalBezier);
|
||||
const auto POINTY = BEZIER != m_mBezierCurves.end() ? BEZIER->second.getYForPoint(SPENT) : DEFAULTBEZIER->second.getYForPoint(SPENT);
|
||||
|
||||
// convert both to OkLab, then lerp that, and convert back.
|
||||
// This is not as fast as just lerping rgb, but it's WAY more precise...
|
||||
// Use the CHyprColor cache for OkLab
|
||||
|
||||
const auto& L1 = av.m_Begun.asOkLab();
|
||||
const auto& L2 = av.m_Goal.asOkLab();
|
||||
|
||||
static const auto lerp = [](const float one, const float two, const float progress) -> float { return one + (two - one) * progress; };
|
||||
|
||||
const Hyprgraphics::CColor lerped = Hyprgraphics::CColor::SOkLab{
|
||||
.l = lerp(L1.l, L2.l, POINTY),
|
||||
.a = lerp(L1.a, L2.a, POINTY),
|
||||
.b = lerp(L1.b, L2.b, POINTY),
|
||||
};
|
||||
|
||||
av.m_Value = {lerped, lerp(av.m_Begun.a, av.m_Goal.a, POINTY)};
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
switch (av->m_Type) {
|
||||
|
|
@ -187,8 +226,8 @@ void CAnimationManager::tick() {
|
|||
break;
|
||||
}
|
||||
case AVARTYPE_COLOR: {
|
||||
auto typedAv = static_cast<CAnimatedVariable<CColor>*>(av);
|
||||
updateVariable(*typedAv);
|
||||
auto typedAv = static_cast<CAnimatedVariable<CHyprColor>*>(av);
|
||||
updateColorVariable(*typedAv);
|
||||
break;
|
||||
}
|
||||
default: UNREACHABLE();
|
||||
|
|
@ -272,7 +311,7 @@ bool CAnimationManager::deltaSmallToFlip(const Vector2D& a, const Vector2D& b) {
|
|||
return std::abs(a.x - b.x) < 0.5f && std::abs(a.y - b.y) < 0.5f;
|
||||
}
|
||||
|
||||
bool CAnimationManager::deltaSmallToFlip(const CColor& a, const CColor& b) {
|
||||
bool CAnimationManager::deltaSmallToFlip(const CHyprColor& a, const CHyprColor& b) {
|
||||
return std::abs(a.r - b.r) < 0.5f && std::abs(a.g - b.g) < 0.5f && std::abs(a.b - b.b) < 0.5f && std::abs(a.a - b.a) < 0.5f;
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +327,7 @@ bool CAnimationManager::deltazero(const float& a, const float& b) {
|
|||
return a == b;
|
||||
}
|
||||
|
||||
bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
|
||||
bool CAnimationManager::deltazero(const CHyprColor& a, const CHyprColor& b) {
|
||||
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ class CAnimationManager {
|
|||
|
||||
private:
|
||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
||||
bool deltaSmallToFlip(const CHyprColor& a, const CHyprColor& b);
|
||||
bool deltaSmallToFlip(const float& a, const float& b);
|
||||
bool deltazero(const Vector2D& a, const Vector2D& b);
|
||||
bool deltazero(const CColor& a, const CColor& b);
|
||||
bool deltazero(const CHyprColor& a, const CHyprColor& b);
|
||||
bool deltazero(const float& a, const float& b);
|
||||
|
||||
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ void CKeybindManager::updateXKBTranslationState() {
|
|||
if (!PKEYMAP) {
|
||||
g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +
|
||||
", layout: " + LAYOUT + " )",
|
||||
CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
|
||||
Debug::log(ERR, "[XKBTranslationState] Keyboard layout {} with variant {} (rules: {}, model: {}, options: {}) couldn't have been loaded.", rules.layout, rules.variant,
|
||||
rules.rules, rules.model, rules.options);
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
|
|||
RBO->bind();
|
||||
|
||||
g_pHyprOpenGL->beginSimple(state->monitor.lock(), {0, 0, INT16_MAX, INT16_MAX}, RBO);
|
||||
g_pHyprOpenGL->clear(CColor{0.F, 0.F, 0.F, 0.F});
|
||||
g_pHyprOpenGL->clear(CHyprColor{0.F, 0.F, 0.F, 0.F});
|
||||
|
||||
CBox xbox = {{}, Vector2D{currentCursorImage.size / currentCursorImage.scale * state->monitor->scale}.round()};
|
||||
Debug::log(TRACE, "[pointer] monitor: {}, size: {}, hw buf: {}, scale: {:.2f}, monscale: {:.2f}, xbox: {}", state->monitor->szName, currentCursorImage.size, cursorSize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue