[PATCH weston] protocol,compositor: wl_viewport destination 1x1 min

Pekka Paalanen ppaalanen at gmail.com
Wed Apr 2 00:18:29 PDT 2014


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Ensure, that the resulting surface size is at least 1x1, even when
destination size is not set and source size is zero. Previously this
lead to zero surface size.

Tested by hacking clients/scaler.c to set src_width and src_height to 0.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

---

There is something wrong in the Pixman renderer, when using 0 or 1/256
as the source width and height, but I can't investigate right now.
---
 protocol/scaler.xml | 8 +++++---
 src/compositor.c    | 7 ++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/protocol/scaler.xml b/protocol/scaler.xml
index 5094616..580b026 100644
--- a/protocol/scaler.xml
+++ b/protocol/scaler.xml
@@ -86,13 +86,15 @@
       dst_width, dst_height. The source (rectangle) is scaled to exactly
       this size. This overrides whatever the attached wl_buffer size is,
       unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
-      has no content and therefore no size.
+      has no content and therefore no size. Otherwise, the size is always
+      at least 1x1 in surface coordinates.
 
       If the source rectangle is set, it defines what area of the
       wl_buffer is taken as the source. If the source rectangle is set and
       the destination size is not set, the surface size becomes the source
-      rectangle size rounded up to the nearest integer. If the source size
-      is already exactly integers, this results in cropping without scaling.
+      rectangle size rounded up to the nearest integer (note: 0
+      destination width or height becomes 1). If the source size is
+      already exactly integers, this results in cropping without scaling.
 
       The coordinate transformations from buffer pixel coordinates up to
       the surface-local coordinates happen in the following order:
diff --git a/src/compositor.c b/src/compositor.c
index 016f514..a80fde9 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1245,9 +1245,10 @@ weston_surface_set_size_from_buffer(struct weston_surface *surface)
 	}
 
 	if (vp->buffer.src_width != wl_fixed_from_int(-1)) {
-		surface_set_size(surface,
-				 fixed_round_up_to_int(vp->buffer.src_width),
-				 fixed_round_up_to_int(vp->buffer.src_height));
+		int32_t w = fixed_round_up_to_int(vp->buffer.src_width);
+		int32_t h = fixed_round_up_to_int(vp->buffer.src_height);
+
+		surface_set_size(surface, w ?: 1, h ?: 1);
 		return;
 	}
 
-- 
1.8.3.2



More information about the wayland-devel mailing list