Skip to content

Commit a6dfd58

Browse files
committed
feat(effects): implement iOS 26 Liquid Glass effect with reusable components
Add GlassEffect.qml, a pure ShaderEffect item with GLSL liquid-glass shader: rounded-rect SDF, edge refraction, RGB dispersion, specular highlight, SDF-derivative AA. Register shaders via qt_add_shaders. 新增 GlassEffect.qml 组件,含 GLSL 液态玻璃着色器:圆角矩形 SDF、 边缘折射、RGB 色差、镜面高光、SDF 导数抗锯齿,通过 qt_add_shaders 注册。 Add dconfig keys for glass/blur effect switch and blur strength. Add highlight dconfig switch; remove unused props highlightStrength, shaderLog, radiusEnabled alias. 新增 dconfig 配置项:glass/blur 效果开关和 blur 强度,高光开关, 移除未使用属性 highlightStrength、shaderLog、radiusEnabled。 BlitTextureProvider maps smooth to setFiltering, antialiasing to setAnisotropyLevel. Fix corner white artifacts via premultiplied alpha output. Unify light direction via lightAngle. BlitTextureProvider 将 smooth 映射 setFiltering,antialiasing 映射 setAnisotropyLevel。修复圆角白色伪影(预乘 alpha 输出),统一光线方向。 test_glass standalone demo uses SHARED treeland_stub library providing a minimal Treeland QML module (Helper singleton + GlassConfig defaults) so Blur.qml / RoundBlur.qml work without libtreeland. test_glass 示例使用 SHARED treeland_stub 库提供最小 Treeland QML 模块 (Helper 单例 + GlassConfig 默认值),无需链接 libtreeland 即可运行。 RoundBlur: glassEnabled=false, pure blur at blurMax=64, color property restored. Remove non-existent color property from lockscreen QML. RoundBlur 设 glassEnabled=false,纯 blur(blurMax=64),恢复 color 属性, 移除锁屏 QML 中对不存在 color 属性的引用。 test_effect_glass: 14 tests covering GlassEffect properties and shader output. test_effect_glass 含 14 个测试,覆盖 GlassEffect 属性和着色器输出。 Log: 实现iOS 26 Liquid Glass效果,可复用组件和dconfig配置 Influence: 新增玻璃效果开关和材质参数配置,锁屏模糊效果由RoundBlur统一控制
1 parent 8b5c5c2 commit a6dfd58

22 files changed

Lines changed: 2759 additions & 32 deletions

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ add_subdirectory(test_im_candidate_panel_tag)
2727
add_subdirectory(test_im_candidate_panel_xprop)
2828
add_subdirectory(test_input_manager)
2929
add_subdirectory(test_keyboard_state_notify)
30+
add_subdirectory(test_glass)

examples/test_glass/CMakeLists.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright (C) 2026 UnionTech Software Technology Co., Ltd.
2+
# SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
4+
find_package(Qt6 COMPONENTS Quick QuickControls2 ShaderTools REQUIRED)
5+
qt_standard_project_setup(REQUIRES 6.4)
6+
7+
if(QT_KNOWN_POLICY_QTP0001) # this policy was introduced in Qt 6.5
8+
qt_policy(SET QTP0001 NEW)
9+
# the RESOURCE_PREFIX argument for qt_add_qml_module() defaults to ":/qt/qml/"
10+
endif()
11+
if(POLICY CMP0071)
12+
# https://cmake.org/cmake/help/latest/policy/CMP0071.html
13+
cmake_policy(SET CMP0071 NEW)
14+
endif()
15+
16+
set(QML_IMPORT_PATH "${PROJECT_BINARY_DIR}/src/server;${QML_IMPORT_PATH}" CACHE STRING "For LSP" FORCE)
17+
18+
find_package(PkgConfig REQUIRED)
19+
pkg_search_module(PIXMAN REQUIRED IMPORTED_TARGET pixman-1)
20+
pkg_search_module(WAYLAND REQUIRED IMPORTED_TARGET wayland-server)
21+
22+
set(GLASS_LIQUIDGLASS_SHADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../misc/shaders")
23+
set(GLASS_EFFECT_QML "${CMAKE_CURRENT_SOURCE_DIR}/../../src/core/qml/Effects/GlassEffect.qml")
24+
set(GLASS_BLUR_QML "${CMAKE_CURRENT_SOURCE_DIR}/../../src/core/qml/Effects/Blur.qml")
25+
set(LOCKSCREEN_ROUNDBLUR_QML "${CMAKE_CURRENT_SOURCE_DIR}/../../src/plugins/lockscreen/qml/RoundBlur.qml")
26+
set_source_files_properties(${GLASS_EFFECT_QML}
27+
PROPERTIES
28+
QT_RESOURCE_ALIAS "GlassEffect.qml"
29+
)
30+
set_source_files_properties(${GLASS_BLUR_QML}
31+
PROPERTIES
32+
QT_RESOURCE_ALIAS "Blur.qml"
33+
)
34+
set_source_files_properties(${LOCKSCREEN_ROUNDBLUR_QML}
35+
PROPERTIES
36+
QT_RESOURCE_ALIAS "RoundBlur.qml"
37+
)
38+
39+
# ── Stub Treeland QML module ─────────────────────────────────────────────
40+
# Provides a minimal Helper singleton with default-valued glass config so
41+
# the upstream Blur.qml / RoundBlur.qml — which read `Helper.config.*` and
42+
# `import Treeland` — work inside the standalone demo without libtreeland.
43+
qt_add_library(treeland_stub SHARED)
44+
qt_add_qml_module(treeland_stub
45+
URI Treeland
46+
VERSION "2.0"
47+
QML_FILES
48+
${GLASS_EFFECT_QML}
49+
${GLASS_BLUR_QML}
50+
${LOCKSCREEN_ROUNDBLUR_QML}
51+
SOURCES
52+
helper.h
53+
helper.cpp
54+
)
55+
qt_add_shaders(treeland_stub "treeland_stub_liquidglass_shaders"
56+
PRECOMPILE
57+
PREFIX
58+
"/shaders"
59+
BASE
60+
${GLASS_LIQUIDGLASS_SHADER_DIR}
61+
FILES
62+
${GLASS_LIQUIDGLASS_SHADER_DIR}/liquidglass.vert
63+
${GLASS_LIQUIDGLASS_SHADER_DIR}/liquidglass.frag
64+
)
65+
target_compile_definitions(treeland_stub PRIVATE WLR_USE_UNSTABLE)
66+
target_link_libraries(treeland_stub PUBLIC
67+
Qt6::Quick
68+
waylibserver
69+
PkgConfig::PIXMAN
70+
PkgConfig::WAYLAND
71+
)
72+
73+
# ── test_glass executable ────────────────────────────────────────────────
74+
add_executable(test_glass
75+
main.cpp
76+
)
77+
qt_add_qml_module(test_glass
78+
URI GlassExample
79+
VERSION "1.0"
80+
QML_FILES
81+
Main.qml
82+
RESOURCES
83+
assets/default-glass-background.jpg
84+
)
85+
target_compile_definitions(test_glass
86+
PRIVATE
87+
SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
88+
$<$<BOOL:${START_DEMO}>:START_DEMO>
89+
WLR_USE_UNSTABLE
90+
)
91+
target_link_libraries(test_glass
92+
PRIVATE
93+
Qt6::Quick
94+
Qt6::QuickControls2
95+
treeland_stub
96+
PkgConfig::PIXMAN
97+
PkgConfig::WAYLAND
98+
)
99+
install(TARGETS test_glass DESTINATION ${CMAKE_INSTALL_BINDIR})

0 commit comments

Comments
 (0)