aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-05-17 14:39:04 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-07-02 17:31:43 +0200
commit697a9632434a35ee168bd79d1f43313a43fad5ea (patch)
tree763eac0617f9ac9db96a52b094a6d2b673fa5e09 /apps/theming
parent9972589cad6de5b81ecdfc7f90ad79a2f09a81f9 (diff)
downloadnextcloud-server-697a9632434a35ee168bd79d1f43313a43fad5ea.tar.gz
nextcloud-server-697a9632434a35ee168bd79d1f43313a43fad5ea.zip
fix(theming): Conitionally disable blur filter for performance
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php58
-rw-r--r--apps/theming/tests/Service/ThemesServiceTest.php6
-rw-r--r--apps/theming/tests/Themes/DarkHighContrastThemeTest.php1
-rw-r--r--apps/theming/tests/Themes/DarkThemeTest.php1
-rw-r--r--apps/theming/tests/Themes/DefaultThemeTest.php1
-rw-r--r--apps/theming/tests/Themes/DyslexiaFontTest.php1
-rw-r--r--apps/theming/tests/Themes/HighContrastThemeTest.php1
7 files changed, 42 insertions, 27 deletions
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index a169541d371..e81c01f1f83 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -7,6 +7,7 @@ declare(strict_types=1);
*/
namespace OCA\Theming\Themes;
+use OC\AppFramework\Http\Request;
use OCA\Theming\ImageManager;
use OCA\Theming\ITheme;
use OCA\Theming\ThemingDefaults;
@@ -14,41 +15,27 @@ use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
class DefaultTheme implements ITheme {
use CommonThemeTrait;
- public Util $util;
- public ThemingDefaults $themingDefaults;
- public IUserSession $userSession;
- public IURLGenerator $urlGenerator;
- public ImageManager $imageManager;
- public IConfig $config;
- public IL10N $l;
- public IAppManager $appManager;
-
public string $defaultPrimaryColor;
public string $primaryColor;
- public function __construct(Util $util,
- ThemingDefaults $themingDefaults,
- IUserSession $userSession,
- IURLGenerator $urlGenerator,
- ImageManager $imageManager,
- IConfig $config,
- IL10N $l,
- IAppManager $appManager) {
- $this->util = $util;
- $this->themingDefaults = $themingDefaults;
- $this->userSession = $userSession;
- $this->urlGenerator = $urlGenerator;
- $this->imageManager = $imageManager;
- $this->config = $config;
- $this->l = $l;
- $this->appManager = $appManager;
-
+ public function __construct(
+ public Util $util,
+ public ThemingDefaults $themingDefaults,
+ public IUserSession $userSession,
+ public IURLGenerator $urlGenerator,
+ public ImageManager $imageManager,
+ public IConfig $config,
+ public IL10N $l,
+ public IAppManager $appManager,
+ private ?IRequest $request,
+ ) {
$this->defaultPrimaryColor = $this->themingDefaults->getDefaultColorPrimary();
$this->primaryColor = $this->themingDefaults->getColorPrimary();
}
@@ -96,12 +83,29 @@ class DefaultTheme implements ITheme {
$colorSuccess = '#2d7b41';
$colorInfo = '#0071ad';
+ $user = $this->userSession->getUser();
+ // Chromium based browsers currently (2024) have huge performance issues with blur filters
+ $isChromium = $this->request !== null && $this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_MS_EDGE]);
+ // Ignore MacOS because they always have hardware accelartion
+ $isChromium = $isChromium && !$this->request->isUserAgent(['/Macintosh/']);
+ // Allow to force the blur filter
+ $forceEnableBlur = $user === null ? false : $this->config->getUserValue(
+ $user->getUID(),
+ 'theming',
+ 'force_enable_blur_filter',
+ );
+ $workingBlur = match($forceEnableBlur) {
+ 'yes' => true,
+ 'no' => false,
+ default => !$isChromium
+ };
+
$variables = [
'--color-main-background' => $colorMainBackground,
'--color-main-background-rgb' => $colorMainBackgroundRGB,
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
'--color-main-background-blur' => 'rgba(var(--color-main-background-rgb), .8)',
- '--filter-background-blur' => 'blur(25px)',
+ '--filter-background-blur' => $workingBlur ? 'blur(25px)' : 'none',
// to use like this: background-image: linear-gradient(0, var('--gradient-main-background));
'--gradient-main-background' => 'var(--color-main-background) 0%, var(--color-main-background-translucent) 85%, transparent 100%',
diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php
index a670ab3a583..1644deea4c7 100644
--- a/apps/theming/tests/Service/ThemesServiceTest.php
+++ b/apps/theming/tests/Service/ThemesServiceTest.php
@@ -315,6 +315,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
'light' => new LightTheme(
$util,
@@ -325,6 +326,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
'dark' => new DarkTheme(
$util,
@@ -335,6 +337,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
'light-highcontrast' => new HighContrastTheme(
$util,
@@ -345,6 +348,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
'dark-highcontrast' => new DarkHighContrastTheme(
$util,
@@ -355,6 +359,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
'opendyslexic' => new DyslexiaFont(
$util,
@@ -365,6 +370,7 @@ class ThemesServiceTest extends TestCase {
$this->config,
$l10n,
$appManager,
+ null,
),
];
}
diff --git a/apps/theming/tests/Themes/DarkHighContrastThemeTest.php b/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
index 7a4187ae8ea..30bbc5f110d 100644
--- a/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
+++ b/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
@@ -101,6 +101,7 @@ class DarkHighContrastThemeTest extends AccessibleThemeTestCase {
$this->config,
$this->l10n,
$this->appManager,
+ null,
);
parent::setUp();
diff --git a/apps/theming/tests/Themes/DarkThemeTest.php b/apps/theming/tests/Themes/DarkThemeTest.php
index 606d9694b4a..16a289053ae 100644
--- a/apps/theming/tests/Themes/DarkThemeTest.php
+++ b/apps/theming/tests/Themes/DarkThemeTest.php
@@ -98,6 +98,7 @@ class DarkThemeTest extends AccessibleThemeTestCase {
$this->config,
$this->l10n,
$this->appManager,
+ null,
);
parent::setUp();
diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php
index 662f1e970b6..91b7d8887d7 100644
--- a/apps/theming/tests/Themes/DefaultThemeTest.php
+++ b/apps/theming/tests/Themes/DefaultThemeTest.php
@@ -102,6 +102,7 @@ class DefaultThemeTest extends AccessibleThemeTestCase {
$this->config,
$this->l10n,
$this->appManager,
+ null,
);
parent::setUp();
diff --git a/apps/theming/tests/Themes/DyslexiaFontTest.php b/apps/theming/tests/Themes/DyslexiaFontTest.php
index 138aeeace95..05f489449b8 100644
--- a/apps/theming/tests/Themes/DyslexiaFontTest.php
+++ b/apps/theming/tests/Themes/DyslexiaFontTest.php
@@ -103,6 +103,7 @@ class DyslexiaFontTest extends TestCase {
$this->config,
$this->l10n,
$this->appManager,
+ null,
);
parent::setUp();
diff --git a/apps/theming/tests/Themes/HighContrastThemeTest.php b/apps/theming/tests/Themes/HighContrastThemeTest.php
index fc323811ffc..47c4b3bb374 100644
--- a/apps/theming/tests/Themes/HighContrastThemeTest.php
+++ b/apps/theming/tests/Themes/HighContrastThemeTest.php
@@ -101,6 +101,7 @@ class HighContrastThemeTest extends AccessibleThemeTestCase {
$this->config,
$this->l10n,
$this->appManager,
+ null,
);
parent::setUp();