Bug 1707226 - [wayland] Only set buffer scale when necessary, r=stransky

Avoids some unnecessary noise, e.g. when using `WAYLAND_DEBUG`,
and cpu overhead.

Differential Revision: https://phabricator.services.mozilla.com/D113222
This commit is contained in:
Robert Mader 2021-04-23 13:50:06 +00:00
parent 46426e47c7
commit cfdc61dfc5
2 changed files with 10 additions and 1 deletions

View File

@ -173,6 +173,7 @@ void moz_container_wayland_init(MozContainerWayland* container) {
container->subsurface_dx = 0;
container->subsurface_dy = 0;
container->before_first_size_alloc = true;
container->buffer_scale = 1;
container->initial_draw_cbs.clear();
container->container_lock = new mozilla::Mutex("MozContainer lock");
}
@ -279,6 +280,7 @@ static void moz_container_wayland_unmap_internal(MozContainer* container) {
wl_container->surface_needs_clear = true;
wl_container->ready_to_draw = false;
wl_container->buffer_scale = 1;
LOGWAYLAND(("%s [%p]\n", __FUNCTION__, (void*)container));
}
@ -421,11 +423,17 @@ static void moz_container_wayland_set_opaque_region(MozContainer* container) {
static void moz_container_wayland_set_scale_factor_locked(
MozContainer* container) {
MozContainerWayland* wl_container = &container->wl_container;
nsWindow* window = moz_container_get_nsWindow(container);
int scale = window ? window->GdkScaleFactor() : 1;
if (scale == wl_container->buffer_scale) {
return;
}
LOGWAYLAND(("%s [%p] scale %d\n", __FUNCTION__, (void*)container, scale));
wl_surface_set_buffer_scale(container->wl_container.surface, scale);
wl_surface_set_buffer_scale(wl_container->surface, scale);
wl_container->buffer_scale = scale;
}
void moz_container_wayland_set_scale_factor(MozContainer* container) {

View File

@ -43,6 +43,7 @@ struct MozContainerWayland {
gboolean surface_needs_clear;
gboolean ready_to_draw;
gboolean before_first_size_alloc;
int buffer_scale;
std::vector<std::function<void(void)>> initial_draw_cbs;
// mozcontainer is used from Compositor and Rendering threads
// so we need to control access to mozcontainer where wayland internals