[PATCH weston 1/2] compositor: Be more careful about setting buffer_viewport.changed

Derek Foreman derekf at osg.samsung.com
Wed Dec 2 12:56:38 PST 2015


We've been setting it every time a client does something that can change
the viewport (as opposed to something that does change the viewport).

However, as an example, a client could be calling set_buffer_scale() with
the same value every commit.  This would lead us to performing operations
only required when the viewport changes when it didn't actually change
at all.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/compositor.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 8bf55dc..33d500e 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2861,6 +2861,10 @@ surface_set_buffer_transform(struct wl_client *client,
 		return;
 	}
 
+	if (surface->pending.buffer_viewport.buffer.transform ==
+	    (unsigned int)transform)
+		return;
+
 	surface->pending.buffer_viewport.buffer.transform = transform;
 	surface->pending.buffer_viewport.changed = 1;
 }
@@ -2880,6 +2884,9 @@ surface_set_buffer_scale(struct wl_client *client,
 		return;
 	}
 
+	if (surface->pending.buffer_viewport.buffer.scale == scale)
+		return;
+
 	surface->pending.buffer_viewport.buffer.scale = scale;
 	surface->pending.buffer_viewport.changed = 1;
 }
@@ -4221,6 +4228,14 @@ viewport_set(struct wl_client *client,
 		return;
 	}
 
+	if (surface->pending.buffer_viewport.buffer.src_x == src_x &&
+	    surface->pending.buffer_viewport.buffer.src_y == src_y &&
+	    surface->pending.buffer_viewport.buffer.src_width == src_width &&
+	    surface->pending.buffer_viewport.buffer.src_height == src_height &&
+	    surface->pending.buffer_viewport.surface.width == dst_width &&
+	    surface->pending.buffer_viewport.surface.height == dst_height)
+		return;
+
 	surface->pending.buffer_viewport.buffer.src_x = src_x;
 	surface->pending.buffer_viewport.buffer.src_y = src_y;
 	surface->pending.buffer_viewport.buffer.src_width = src_width;
@@ -4261,6 +4276,12 @@ viewport_set_source(struct wl_client *client,
 		return;
 	}
 
+	if (surface->pending.buffer_viewport.buffer.src_x == src_x &&
+	    surface->pending.buffer_viewport.buffer.src_y == src_y &&
+	    surface->pending.buffer_viewport.buffer.src_width == src_width &&
+	    surface->pending.buffer_viewport.buffer.src_height == src_height)
+		return;
+
 	surface->pending.buffer_viewport.buffer.src_x = src_x;
 	surface->pending.buffer_viewport.buffer.src_y = src_y;
 	surface->pending.buffer_viewport.buffer.src_width = src_width;
@@ -4294,6 +4315,10 @@ viewport_set_destination(struct wl_client *client,
 		return;
 	}
 
+	if (surface->pending.buffer_viewport.surface.width == dst_width &&
+	    surface->pending.buffer_viewport.surface.height == dst_height)
+		return;
+
 	surface->pending.buffer_viewport.surface.width = dst_width;
 	surface->pending.buffer_viewport.surface.height = dst_height;
 	surface->pending.buffer_viewport.changed = 1;
-- 
2.6.2



More information about the wayland-devel mailing list