Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/greeter/appearance_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace greeter::appearance {
inline constexpr const char* kGreeterConfFileName = "greeter.conf";
inline constexpr const char* kWallpaperBaseName = "wallpaper";
inline constexpr const char* kSyncedSchemeDisplayName = "Synced";
inline constexpr const char* kSyncedBlurSchemeDisplayName = "Synced (Blur)";
inline constexpr const char* kSyncedDataDirEnv = "NOCTALIA_GREETER_STATE_DIR";

[[nodiscard]] std::filesystem::path syncedDataDirectory();
Expand Down
26 changes: 24 additions & 2 deletions src/greeter/greeter_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ void GreeterSurface::buildSchemeNames() {
m_syncedAppearance = loadGreeterSyncedAppearance();
if (m_syncedAppearance.has_value()) {
m_schemeNames.emplace_back(greeter::appearance::kSyncedSchemeDisplayName);
m_schemeNames.emplace_back(greeter::appearance::kSyncedBlurSchemeDisplayName);
m_selectedScheme = 0;
}

Expand All @@ -1315,8 +1316,12 @@ void GreeterSurface::buildSchemeNames() {
}

bool GreeterSurface::isSyncedScheme(const std::size_t schemeIndex) const {
return schemeIndex < m_schemeNames.size()
&& m_schemeNames[schemeIndex] == greeter::appearance::kSyncedSchemeDisplayName;
if (schemeIndex >= m_schemeNames.size()) {
return false;
}
const auto& name = m_schemeNames[schemeIndex];
return name == greeter::appearance::kSyncedSchemeDisplayName
|| name == greeter::appearance::kSyncedBlurSchemeDisplayName;
}

std::optional<std::size_t> GreeterSurface::findSchemeIndex(const std::string_view name) const {
Expand All @@ -1334,6 +1339,10 @@ void GreeterSurface::clearWallpaperDisplay() {
m_wallpaperFillMode = WallpaperFillMode::Crop;
m_wallpaperFillColor = rgba(0.0f, 0.0f, 0.0f, 0.0f);
m_wallpaperDirty = true;
if (m_wallpaper != nullptr) {
m_wallpaper->setBlurRadius(0.0f);
m_wallpaper->setTintColor(rgba(0.0f, 0.0f, 0.0f, 0.0f));
}
}

void GreeterSurface::applyScheme(const std::size_t schemeIndex) {
Expand All @@ -1360,6 +1369,19 @@ void GreeterSurface::applyScheme(const std::size_t schemeIndex) {
m_wallpaperFillColor = m_syncedAppearance->wallpaperFillColor;
m_hasSyncedWallpaper = !m_wallpaperPath.empty();
m_wallpaperDirty = true;

if (m_wallpaper != nullptr) {
const bool isBlur = m_schemeNames[schemeIndex] == greeter::appearance::kSyncedBlurSchemeDisplayName;
if (isBlur) {
Color tint = m_syncedAppearance->palette.surface;
tint.a = 0.4f;
m_wallpaper->setBlurRadius(30.0f);
m_wallpaper->setTintColor(tint);
} else {
Comment on lines +1375 to +1380

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be nice to allow tint and blur to be configurable, either from greeter.toml or synced from Noctalia settings if possible. That would also make it possible to remove the separate "Synced (Blur)" option and instead blur only if the intensity is nonzero

m_wallpaper->setBlurRadius(0.0f);
m_wallpaper->setTintColor(rgba(0.0f, 0.0f, 0.0f, 0.0f));
}
}
return;
}

Expand Down
46 changes: 44 additions & 2 deletions src/render/backend/gles_render_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ void GlesRenderBackend::makeCurrent(RenderTarget& target) {
void GlesRenderBackend::beginFrame(RenderTarget& target) {
makeCurrent(target);

setViewport(target.bufferWidth(), target.bufferHeight());
m_bufferWidth = target.bufferWidth();
m_bufferHeight = target.bufferHeight();

setViewport(m_bufferWidth, m_bufferHeight);
setBlendMode(RenderBlendMode::PremultipliedAlpha);
disableScissor();
clear(rgba(0.0f, 0.0f, 0.0f, 0.0f));
Expand Down Expand Up @@ -425,8 +428,47 @@ void GlesRenderBackend::drawWallpaper(
WallpaperSourceKind sourceKind2, TextureId texture2, const Color& sourceColor2, float surfaceWidth,
float surfaceHeight, float width, float height, float imageWidth1, float imageHeight1, float imageWidth2,
float imageHeight2, float progress, float fillMode, const TransitionParams& params, const Color& fillColor,
const Mat3& transform
const Mat3& transform, float blurRadius, const Color& tintColor
) {
if (blurRadius > 0.0f) {
const std::uint32_t targetWidth = m_bufferWidth > 0 ? m_bufferWidth : static_cast<std::uint32_t>(surfaceWidth);
const std::uint32_t targetHeight = m_bufferHeight > 0 ? m_bufferHeight : static_cast<std::uint32_t>(surfaceHeight);
const std::uint32_t fbWidth = std::max(1u, targetWidth / 4);
const std::uint32_t fbHeight = std::max(1u, targetHeight / 4);

auto fb1 = createFramebuffer(fbWidth, fbHeight);
auto fb2 = createFramebuffer(fbWidth, fbHeight);

if (fb1 != nullptr && fb2 != nullptr && fb1->valid() && fb2->valid()) {
bindFramebuffer(*fb1);
setViewport(fbWidth, fbHeight);
clear(rgba(0.0f, 0.0f, 0.0f, 0.0f));

m_wallpaperProgram.ensureInitialized();
m_wallpaperProgram.draw(
transition, sourceKind1, texture1, sourceColor1, sourceKind2, texture2, sourceColor2, surfaceWidth,
surfaceHeight, width, height, imageWidth1, imageHeight1, imageWidth2, imageHeight2, progress, fillMode,
params, fillColor, transform
);

bindFramebuffer(*fb2);
setViewport(fbWidth, fbHeight);
clear(rgba(0.0f, 0.0f, 0.0f, 0.0f));
drawFramebufferBlur(fb1->colorTexture(), fbWidth, fbHeight, 1.0f, 0.0f, blurRadius);

bindDefaultFramebuffer();
setViewport(targetWidth, targetHeight);
drawFramebufferBlur(fb2->colorTexture(), fbWidth, fbHeight, 0.0f, 1.0f, blurRadius);

if (tintColor.a > 0.0f) {
setBlendMode(RenderBlendMode::StraightAlpha);
drawFullscreenTint(tintColor);
setBlendMode(RenderBlendMode::PremultipliedAlpha);
}
return;
}
}

m_wallpaperProgram.ensureInitialized();
m_wallpaperProgram.draw(
transition, sourceKind1, texture1, sourceColor1, sourceKind2, texture2, sourceColor2, surfaceWidth, surfaceHeight,
Expand Down
4 changes: 3 additions & 1 deletion src/render/backend/gles_render_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GlesRenderBackend final : public RenderBackend {
WallpaperSourceKind sourceKind2, TextureId texture2, const Color& sourceColor2, float surfaceWidth,
float surfaceHeight, float width, float height, float imageWidth1, float imageHeight1, float imageWidth2,
float imageHeight2, float progress, float fillMode, const TransitionParams& params, const Color& fillColor,
const Mat3& transform
const Mat3& transform, float blurRadius = 0.0f, const Color& tintColor = rgba(0.0f, 0.0f, 0.0f, 0.0f)
) override;
void drawFullscreenTexture(TextureId texture, bool flipY) override;
void drawFullscreenTint(Color color) override;
Expand All @@ -94,6 +94,8 @@ class GlesRenderBackend final : public RenderBackend {
EGLConfig m_config = nullptr;
EGLContext m_context = EGL_NO_CONTEXT;
int m_maxTextureSize = 0;
std::uint32_t m_bufferWidth = 0;
std::uint32_t m_bufferHeight = 0;
GlesTextureManager m_textureManager;
RectProgram m_rectProgram;
ImageProgram m_imageProgram;
Expand Down
2 changes: 1 addition & 1 deletion src/render/backend/render_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class RenderBackend {
WallpaperSourceKind sourceKind2, TextureId texture2, const Color& sourceColor2, float surfaceWidth,
float surfaceHeight, float width, float height, float imageWidth1, float imageHeight1, float imageWidth2,
float imageHeight2, float progress, float fillMode, const TransitionParams& params, const Color& fillColor,
const Mat3& transform
const Mat3& transform, float blurRadius = 0.0f, const Color& tintColor = rgba(0.0f, 0.0f, 0.0f, 0.0f)
) = 0;
virtual void drawFullscreenTexture(TextureId texture, bool flipY) = 0;
virtual void drawFullscreenTint(Color color) = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/render/render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ void RenderContext::renderNode(
wallpaper->transition(), wallpaper->sourceKind1(), wallpaper->texture1(), wallpaper->sourceColor1(),
sourceKind2, texture2, sourceColor2, sw, sh, node->width(), node->height(), wallpaper->imageWidth1(),
wallpaper->imageHeight1(), imageWidth2, imageHeight2, progress, static_cast<float>(wallpaper->fillMode()),
wallpaper->transitionParams(), wallpaper->fillColor(), worldTransform
wallpaper->transitionParams(), wallpaper->fillColor(), worldTransform, wallpaper->blurRadius(),
wallpaper->tintColor()
);
}
break;
Expand Down
21 changes: 21 additions & 0 deletions src/render/scene/wallpaper_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ class WallpaperNode : public Node {
markPaintDirty();
}

[[nodiscard]] float blurRadius() const noexcept { return m_blurRadius; }
[[nodiscard]] const Color& tintColor() const noexcept { return m_tintColor; }

void setBlurRadius(float radius) {
if (m_blurRadius == radius) {
return;
}
m_blurRadius = radius;
markPaintDirty();
}

void setTintColor(const Color& tintColor) {
if (m_tintColor == tintColor) {
return;
}
m_tintColor = tintColor;
markPaintDirty();
}

private:
WallpaperSourceKind m_sourceKind1 = WallpaperSourceKind::Image;
WallpaperSourceKind m_sourceKind2 = WallpaperSourceKind::Image;
Expand All @@ -120,4 +139,6 @@ class WallpaperNode : public Node {
WallpaperFillMode m_fillMode = WallpaperFillMode::Crop;
Color m_fillColor = rgba(0.0f, 0.0f, 0.0f, 1.0f);
TransitionParams m_params;
float m_blurRadius = 0.0f;
Color m_tintColor = rgba(0.0f, 0.0f, 0.0f, 0.0f);
};