mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Performance: add option to disable window shadows
Rendering window shadows in GTK4 doubles GPU usage. This commit adds an option to disable them for performance gain (useful on low-end devices).
This commit is contained in:
@@ -6,6 +6,7 @@ const Menu = imports.clapper_src.menu;
|
|||||||
const Misc = imports.clapper_src.misc;
|
const Misc = imports.clapper_src.misc;
|
||||||
|
|
||||||
let { debug } = Debug;
|
let { debug } = Debug;
|
||||||
|
let { settings } = Misc;
|
||||||
|
|
||||||
var App = GObject.registerClass(
|
var App = GObject.registerClass(
|
||||||
class ClapperApp extends Gtk.Application
|
class ClapperApp extends Gtk.Application
|
||||||
@@ -30,6 +31,11 @@ class ClapperApp extends Gtk.Application
|
|||||||
application: this,
|
application: this,
|
||||||
title: Misc.appName,
|
title: Misc.appName,
|
||||||
});
|
});
|
||||||
|
window.isClapperApp = true;
|
||||||
|
window.add_css_class('nobackground');
|
||||||
|
|
||||||
|
if(!settings.get_boolean('render-shadows'))
|
||||||
|
window.add_css_class('gpufriendly');
|
||||||
|
|
||||||
for(let action in Menu.actions) {
|
for(let action in Menu.actions) {
|
||||||
let simpleAction = new Gio.SimpleAction({
|
let simpleAction = new Gio.SimpleAction({
|
||||||
|
8
clapper_src/controls.js
vendored
8
clapper_src/controls.js
vendored
@@ -206,8 +206,8 @@ class ClapperControls extends Gtk.Box
|
|||||||
if(checkButton.activeId < 0) {
|
if(checkButton.activeId < 0) {
|
||||||
/* Disabling video leaves last frame frozen,
|
/* Disabling video leaves last frame frozen,
|
||||||
* so we hide it by making it transparent */
|
* so we hide it by making it transparent */
|
||||||
if(checkButton.type === 'video')
|
//if(checkButton.type === 'video')
|
||||||
clapperWidget.player.widget.set_opacity(0);
|
// clapperWidget.player.widget.set_opacity(0);
|
||||||
|
|
||||||
return clapperWidget.player[
|
return clapperWidget.player[
|
||||||
`set_${checkButton.type}_track_enabled`
|
`set_${checkButton.type}_track_enabled`
|
||||||
@@ -219,8 +219,8 @@ class ClapperControls extends Gtk.Box
|
|||||||
clapperWidget.player[setTrack](checkButton.activeId);
|
clapperWidget.player[setTrack](checkButton.activeId);
|
||||||
clapperWidget.player[`${setTrack}_enabled`](true);
|
clapperWidget.player[`${setTrack}_enabled`](true);
|
||||||
|
|
||||||
if(checkButton.type === 'video' && !clapperWidget.player.widget.opacity)
|
//if(checkButton.type === 'video' && !clapperWidget.player.widget.opacity)
|
||||||
clapperWidget.player.widget.set_opacity(1);
|
// clapperWidget.player.widget.set_opacity(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleVisualizationChange(checkButton)
|
_handleVisualizationChange(checkButton)
|
||||||
|
@@ -164,6 +164,10 @@ class ClapperPrefsDialog extends Gtk.Dialog
|
|||||||
{
|
{
|
||||||
title: 'GStreamer',
|
title: 'GStreamer',
|
||||||
widget: Prefs.GStreamerPage,
|
widget: Prefs.GStreamerPage,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Tweaks',
|
||||||
|
widget: Prefs.TweaksPage,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,6 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
this.widget = gtkglsink.widget;
|
this.widget = gtkglsink.widget;
|
||||||
this.widget.vexpand = true;
|
this.widget.vexpand = true;
|
||||||
this.widget.hexpand = true;
|
this.widget.hexpand = true;
|
||||||
this.widget.set_opacity(0);
|
|
||||||
|
|
||||||
this.visualization_enabled = false;
|
this.visualization_enabled = false;
|
||||||
|
|
||||||
@@ -192,6 +191,20 @@ class ClapperPlayerBase extends GstPlayer.Player
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'render-shadows':
|
||||||
|
let root = this.widget.get_root();
|
||||||
|
if(root && root.isClapperApp) {
|
||||||
|
let cssClass = 'gpufriendly';
|
||||||
|
let renderShadows = settings.get_boolean('render-shadows');
|
||||||
|
let hasShadows = !root.has_css_class(cssClass);
|
||||||
|
|
||||||
|
if(renderShadows === hasShadows)
|
||||||
|
break;
|
||||||
|
|
||||||
|
let action = (renderShadows) ? 'remove' : 'add';
|
||||||
|
root[action + '_css_class'](cssClass);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -241,3 +241,15 @@ class ClapperGStreamerPage extends PrefsBase.Grid
|
|||||||
this.settingsChangedSignal = null;
|
this.settingsChangedSignal = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var TweaksPage = GObject.registerClass(
|
||||||
|
class ClapperTweaksPage extends PrefsBase.Grid
|
||||||
|
{
|
||||||
|
_init()
|
||||||
|
{
|
||||||
|
super._init();
|
||||||
|
|
||||||
|
this.addTitle('Performance');
|
||||||
|
this.addCheckButton('Render window shadows', 'render-shadows');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@@ -52,8 +52,14 @@ var Widget = GObject.registerClass({
|
|||||||
this.revealerBottom = new Revealers.RevealerBottom();
|
this.revealerBottom = new Revealers.RevealerBottom();
|
||||||
this.controls = new Controls();
|
this.controls = new Controls();
|
||||||
|
|
||||||
|
this.controlsBox = new Gtk.Box({
|
||||||
|
orientation: Gtk.Orientation.HORIZONTAL,
|
||||||
|
});
|
||||||
|
this.controlsBox.add_css_class('controlsbox');
|
||||||
|
this.controlsBox.append(this.controls);
|
||||||
|
|
||||||
this.attach(this.overlay, 0, 0, 1, 1);
|
this.attach(this.overlay, 0, 0, 1, 1);
|
||||||
this.attach(this.controls, 0, 1, 1, 1);
|
this.attach(this.controlsBox, 0, 1, 1, 1);
|
||||||
|
|
||||||
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
||||||
|
|
||||||
@@ -101,7 +107,7 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
let root = this.get_root();
|
let root = this.get_root();
|
||||||
let action = (isFullscreen) ? 'add' : 'remove';
|
let action = (isFullscreen) ? 'add' : 'remove';
|
||||||
root[action + '_css_class']('gpufriendly');
|
root[action + '_css_class']('gpufriendlyfs');
|
||||||
|
|
||||||
if(!this.floatingMode)
|
if(!this.floatingMode)
|
||||||
this._changeControlsPlacement(isFullscreen);
|
this._changeControlsPlacement(isFullscreen);
|
||||||
@@ -185,12 +191,12 @@ var Widget = GObject.registerClass({
|
|||||||
_changeControlsPlacement(isOnTop)
|
_changeControlsPlacement(isOnTop)
|
||||||
{
|
{
|
||||||
if(isOnTop) {
|
if(isOnTop) {
|
||||||
this.remove(this.controls);
|
this.controlsBox.remove(this.controls);
|
||||||
this.revealerBottom.append(this.controls);
|
this.revealerBottom.append(this.controls);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.revealerBottom.remove(this.controls);
|
this.revealerBottom.remove(this.controls);
|
||||||
this.attach(this.controls, 0, 1, 1, 1);
|
this.controlsBox.append(this.controls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,8 +97,8 @@ scale marks {
|
|||||||
|
|
||||||
/* Floating Mode */
|
/* Floating Mode */
|
||||||
.floatingwindow {
|
.floatingwindow {
|
||||||
background: none;
|
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
box-shadow: -8px -8px transparent, 8px 8px transparent;
|
||||||
}
|
}
|
||||||
.osd.floatingcontrols .playercontrols {
|
.osd.floatingcontrols .playercontrols {
|
||||||
-gtk-icon-size: 16px;
|
-gtk-icon-size: 16px;
|
||||||
@@ -144,8 +144,16 @@ scale marks {
|
|||||||
margin: 12px;
|
margin: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Other */
|
/* Tweaks */
|
||||||
.gpufriendly {
|
.nobackground {
|
||||||
box-shadow: none;
|
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
.controlsbox {
|
||||||
|
background: @theme_bg_color;
|
||||||
|
}
|
||||||
|
.gpufriendly {
|
||||||
|
box-shadow: -8px -8px transparent, 8px 8px transparent;
|
||||||
|
}
|
||||||
|
.gpufriendlyfs {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
@@ -29,6 +29,12 @@
|
|||||||
<summary>Unit to use with seeking value</summary>
|
<summary>Unit to use with seeking value</summary>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<!-- Tweaks -->
|
||||||
|
<key name="render-shadows" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Enable rendering window shadows (only if theme has them)</summary>
|
||||||
|
</key>
|
||||||
|
|
||||||
<!-- GStreamer -->
|
<!-- GStreamer -->
|
||||||
<key name="plugin-ranking" type="s">
|
<key name="plugin-ranking" type="s">
|
||||||
<default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default>
|
<default>'[{"apply":false,"name":"vah264dec","rank":300}]'</default>
|
||||||
|
Reference in New Issue
Block a user