diff options
author | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2020-01-13 21:02:39 +0800 |
---|---|---|
committer | Robert Mader <robert.mader@posteo.de> | 2020-02-04 19:48:01 +0000 |
commit | 76240e24f7981a2a0f7e4e83ff641ed7b3562894 (patch) | |
tree | 90ea22820caae3e7f27cca5a0d870543d10a1bc8 /src/compositor/meta-background.c | |
parent | 9b0392e9882a820fd97101d0df1bf1a96471cc02 (diff) | |
download | mutter-76240e24f7981a2a0f7e4e83ff641ed7b3562894.tar.gz |
background: Scale monitor_area after texture creation
Scaling the `monitor_area` before texture creation was just wasting
megabytes of memory on resolution that the monitor can't display. This
was also hurting runtime performance.
Example:
Monitor is natively 1920x1080 and scale set to 3.
Before: The monitor texture allocated was 5760x3250x4 = 74.6 MB
After: The monitor texture allocated is 1920x1080x4 = 8.3 MB
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/2118
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1004
Diffstat (limited to 'src/compositor/meta-background.c')
-rw-r--r-- | src/compositor/meta-background.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c index 3bd52aa2f..30be33261 100644 --- a/src/compositor/meta-background.c +++ b/src/compositor/meta-background.c @@ -23,6 +23,7 @@ #include <string.h> +#include "backends/meta-backend-private.h" #include "compositor/cogl-utils.h" #include "meta/display.h" #include "meta/meta-background-image.h" @@ -799,26 +800,39 @@ meta_background_get_texture (MetaBackground *self, { GError *catch_error = NULL; gboolean bare_region_visible = FALSE; + int texture_width, texture_height; - if (self->style != G_DESKTOP_BACKGROUND_STYLE_WALLPAPER) + if (meta_is_stage_views_scaled ()) { - monitor_area.x *= monitor_scale; - monitor_area.y *= monitor_scale; - monitor_area.width *= monitor_scale; - monitor_area.height *= monitor_scale; + texture_width = monitor_area.width * monitor_scale; + texture_height = monitor_area.height * monitor_scale; + } + else + { + texture_width = monitor_area.width; + texture_height = monitor_area.height; } if (monitor->texture == NULL) { CoglOffscreen *offscreen; - monitor->texture = meta_create_texture (monitor_area.width, monitor_area.height, + monitor->texture = meta_create_texture (texture_width, + texture_height, COGL_TEXTURE_COMPONENTS_RGBA, META_TEXTURE_FLAGS_NONE); offscreen = cogl_offscreen_new_with_texture (monitor->texture); monitor->fbo = COGL_FRAMEBUFFER (offscreen); } + if (self->style != G_DESKTOP_BACKGROUND_STYLE_WALLPAPER) + { + monitor_area.x *= monitor_scale; + monitor_area.y *= monitor_scale; + monitor_area.width *= monitor_scale; + monitor_area.height *= monitor_scale; + } + if (!cogl_framebuffer_allocate (monitor->fbo, &catch_error)) { /* Texture or framebuffer allocation failed; it's unclear why this happened; |