Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
also clang-format
  • Loading branch information
robin-carlier committed Dec 16, 2024
1 parent e8b7c58 commit b06a48d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 60 deletions.
12 changes: 6 additions & 6 deletions src/renderer/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class CRenderer {
float boostA = 1.0;
};

SRenderFeedback renderLock(const CSessionLockSurface& surface);
SRenderFeedback renderLock(const CSessionLockSurface& surface);

void renderRect(const CBox& box, const CColor& col, int rounding = 0);
void renderBorder(const CBox& box, const CGradientValueData& gradient, int thickness, int rounding = 0, float alpha = 1.0);
void renderTexture(const CBox& box, const CTexture& tex, float a = 1.0, int rounding = 0, std::optional<eTransform> tr = {});
void renderTextureMix(const CBox& box, const CTexture& tex, const CTexture& tex2, float a = 1.0, float mixFactor = 0.0, int rounding = 0, std::optional<eTransform> tr = {});
void blurFB(const CFramebuffer& outfb, SBlurParams params);
void renderRect(const CBox& box, const CColor& col, int rounding = 0);
void renderBorder(const CBox& box, const CGradientValueData& gradient, int thickness, int rounding = 0, float alpha = 1.0);
void renderTexture(const CBox& box, const CTexture& tex, float a = 1.0, int rounding = 0, std::optional<eTransform> tr = {});
void renderTextureMix(const CBox& box, const CTexture& tex, const CTexture& tex2, float a = 1.0, float mixFactor = 0.0, int rounding = 0, std::optional<eTransform> tr = {});
void blurFB(const CFramebuffer& outfb, SBlurParams params);

std::unique_ptr<CAsyncResourceGatherer> asyncResourceGatherer;
std::chrono::system_clock::time_point firstFullFrameTime;
Expand Down
56 changes: 25 additions & 31 deletions src/renderer/widgets/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ CBackground::~CBackground() {
}

if (fade) {
if (fade->crossFadeTimer) {
fade->crossFadeTimer->cancel();
fade->crossFadeTimer.reset();
}
fade.reset();
if (fade->crossFadeTimer) {
fade->crossFadeTimer->cancel();
fade->crossFadeTimer.reset();
}
fade.reset();
}
}

Expand Down Expand Up @@ -60,7 +60,6 @@ void CBackground::renderRect(CColor color) {
g_pRenderer->renderRect(monbox, color, 0);
}


static void onTimer(std::shared_ptr<CTimer> self, void* data) {
const auto PBG = (CBackground*)data;

Expand Down Expand Up @@ -107,7 +106,6 @@ bool CBackground::draw(const SRenderData& data) {
return true;
}


if (fade || ((blurPasses > 0 || isScreenshot) && (!blurredFB.isAllocated() || firstRender))) {

if (firstRender)
Expand Down Expand Up @@ -141,13 +139,13 @@ bool CBackground::draw(const SRenderData& data) {

if (fade) {
g_pRenderer->renderTextureMix(texbox, asset->texture, pendingAsset->texture, 1.0,
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - fade->start).count()/(1000*crossfade_time),
0, HYPRUTILS_TRANSFORM_NORMAL);
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - fade->start).count() / (1000 * crossfade_time),
0, HYPRUTILS_TRANSFORM_NORMAL);
} else {
g_pRenderer->renderTexture(texbox, asset->texture, 1.0, 0,
isScreenshot ?
wlTransformToHyprutils(invertTransform(output->transform)) :
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
isScreenshot ?
wlTransformToHyprutils(invertTransform(output->transform)) :
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
}

if (blurPasses > 0)
Expand Down Expand Up @@ -177,12 +175,11 @@ bool CBackground::draw(const SRenderData& data) {
return true; // actively redraw during fading
else
return data.opacity < 1.0;

}

void CBackground::plantTimer() {

RASSERT(!(reloadTime >= 0 && isScreenshot), "Reloadable background can't be used with screenshot" )
RASSERT(!(reloadTime >= 0 && isScreenshot), "Reloadable background can't be used with screenshot")

if (reloadTime == 0) {
bgTimer = g_pHyprlock->addTimer(std::chrono::hours(1), onTimer, this, true);
Expand All @@ -203,14 +200,13 @@ void CBackground::onFadeTimerUpdate() {
blurredFB.release();
}

asset = pendingAsset;
resourceID = pendingResourceID;
asset = pendingAsset;
resourceID = pendingResourceID;
pendingResourceID = "";
pendingAsset = nullptr;
firstRender = true;
pendingAsset = nullptr;
firstRender = true;

g_pHyprlock->renderOutput(output->stringPort);

};

void CBackground::onTimerUpdate() {
Expand Down Expand Up @@ -260,15 +256,14 @@ void CBackground::onTimerUpdate() {
request.callbackData = this;

g_pRenderer->asyncResourceGatherer->requestAsyncAssetPreload(request);

};

void CBackground::startFadeOrUpdateRender() {
auto newAsset = g_pRenderer->asyncResourceGatherer->getAssetByID(pendingResourceID);
if (newAsset) {
if (newAsset->texture.m_iType == TEXTURE_INVALID) {
g_pRenderer->asyncResourceGatherer->unloadAsset(newAsset);
Debug::log( ERR, "New asset had an invalid texture!");
Debug::log(ERR, "New asset had an invalid texture!");
} else if (resourceID != pendingResourceID) {

pendingAsset = newAsset;
Expand All @@ -277,22 +272,21 @@ void CBackground::startFadeOrUpdateRender() {
// Start a fade
if (!fade) {

fade = std::make_unique<SFade>(std::chrono::system_clock::now(), 0, nullptr);
fade = std::make_unique<SFade>(std::chrono::system_clock::now(), 0, nullptr);

} else {

// Maybe we where already fading so reset it just in case, but should'nt be happening.

if (fade->crossFadeTimer) {
fade->crossFadeTimer->cancel();
fade->crossFadeTimer.reset();
};
// Maybe we where already fading so reset it just in case, but should'nt be happening.

if (fade->crossFadeTimer) {
fade->crossFadeTimer->cancel();
fade->crossFadeTimer.reset();
};
};

fade->start = std::chrono::system_clock::now();
fade->a = 0;
fade->crossFadeTimer = g_pHyprlock->addTimer(std::chrono::milliseconds((int)(1000.0*crossfade_time)), onFadeTimer, this);
fade->start = std::chrono::system_clock::now();
fade->a = 0;
fade->crossFadeTimer = g_pHyprlock->addTimer(std::chrono::milliseconds((int)(1000.0 * crossfade_time)), onFadeTimer, this);
} else {
onFadeTimerUpdate();
}
Expand Down
45 changes: 22 additions & 23 deletions src/renderer/widgets/Background.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ struct SPreloadedAsset;
class COutput;

struct SFade {
std::chrono::system_clock::time_point start;
float a = 0;
std::shared_ptr<CTimer> crossFadeTimer = nullptr;
std::chrono::system_clock::time_point start;
float a = 0;
std::shared_ptr<CTimer> crossFadeTimer = nullptr;
};

class CBackground : public IWidget {
Expand All @@ -36,30 +36,29 @@ class CBackground : public IWidget {

private:
// if needed
CFramebuffer blurredFB;
CFramebuffer blurredFB;

int blurSize = 10;
int blurPasses = 3;
float noise = 0.0117;
float contrast = 0.8916;
float brightness = 0.8172;
float vibrancy = 0.1696;
float vibrancy_darkness = 0.0;
Vector2D viewport;
std::string path = "";
int blurSize = 10;
int blurPasses = 3;
float noise = 0.0117;
float contrast = 0.8916;
float brightness = 0.8172;
float vibrancy = 0.1696;
float vibrancy_darkness = 0.0;
Vector2D viewport;
std::string path = "";

std::string resourceID;
std::string pendingResourceID;

std::string resourceID;
std::string pendingResourceID;
float crossfade_time = -1.0;

float crossfade_time = -1.0;

CColor color;
SPreloadedAsset* asset = nullptr;
COutput* output = nullptr;
bool isScreenshot = false;
SPreloadedAsset* pendingAsset = nullptr;
bool firstRender = true;
CColor color;
SPreloadedAsset* asset = nullptr;
COutput* output = nullptr;
bool isScreenshot = false;
SPreloadedAsset* pendingAsset = nullptr;
bool firstRender = true;

std::unique_ptr<SFade> fade;

Expand Down

0 comments on commit b06a48d

Please sign in to comment.