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
This commit is contained in:
parent
9b0392e988
commit
76240e24f7
@ -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,6 +800,30 @@ meta_background_get_texture (MetaBackground *self,
|
||||
{
|
||||
GError *catch_error = NULL;
|
||||
gboolean bare_region_visible = FALSE;
|
||||
int texture_width, texture_height;
|
||||
|
||||
if (meta_is_stage_views_scaled ())
|
||||
{
|
||||
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 (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)
|
||||
{
|
||||
@ -808,17 +833,6 @@ meta_background_get_texture (MetaBackground *self,
|
||||
monitor_area.height *= monitor_scale;
|
||||
}
|
||||
|
||||
if (monitor->texture == NULL)
|
||||
{
|
||||
CoglOffscreen *offscreen;
|
||||
|
||||
monitor->texture = meta_create_texture (monitor_area.width, monitor_area.height,
|
||||
COGL_TEXTURE_COMPONENTS_RGBA,
|
||||
META_TEXTURE_FLAGS_NONE);
|
||||
offscreen = cogl_offscreen_new_with_texture (monitor->texture);
|
||||
monitor->fbo = COGL_FRAMEBUFFER (offscreen);
|
||||
}
|
||||
|
||||
if (!cogl_framebuffer_allocate (monitor->fbo, &catch_error))
|
||||
{
|
||||
/* Texture or framebuffer allocation failed; it's unclear why this happened;
|
||||
|
Loading…
Reference in New Issue
Block a user