[PATCH weston 2/2] compositor-drm: don't attempt sprite for out of bounds dimensions

Rob Clark rob.clark at linaro.org
Thu Aug 9 12:18:28 PDT 2012


From: Rob Clark <rob at ti.com>

The drmModeAddFB2() call will fail anyways, and cause us to unnecessarily
set sprites_are_broken.

Signed-off-by: Rob Clark <rob at ti.com>
---
 src/compositor-drm.c |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index d6e6c98..9132206 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -74,6 +74,13 @@ struct drm_compositor {
 	struct gbm_surface *dummy_surface;
 	EGLSurface dummy_egl_surface;
 
+	/* we need these parameters in order to not fail drmModeAddFB2()
+	 * due to out of bounds dimensions, and then mistakenly set
+	 * sprites_are_broken:
+	 */
+	uint32_t min_width, max_width;
+	uint32_t min_height, max_height;
+
 	struct wl_list sprite_list;
 	int sprites_are_broken;
 
@@ -556,6 +563,7 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base,
 	pixman_box32_t *box;
 	uint32_t format;
 	wl_fixed_t sx1, sy1, sx2, sy2;
+	int32_t width, height;
 
 	if (c->sprites_are_broken)
 		return -1;
@@ -603,11 +611,21 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base,
 	if (!handle)
 		return -1;
 
+	width = es->geometry.width;
+	height = es->geometry.height;
+
+	/* if geometry is out of bounds, don't even bother trying because
+	 * we know the AddFB2() call will fail:
+	 */
+	if ((c->min_width > width) || (width > c->max_width) ||
+			(c->min_height > height) || (height > c->max_height))
+		return -1;
+
 	handles[0] = handle;
 	pitches[0] = stride;
 	offsets[0] = 0;
 
-	ret = drmModeAddFB2(c->drm.fd, es->geometry.width, es->geometry.height,
+	ret = drmModeAddFB2(c->drm.fd, width, height,
 			    format, handles, pitches, offsets,
 			    &fb_id, 0);
 	if (ret) {
@@ -1527,6 +1545,11 @@ create_outputs(struct drm_compositor *ec, uint32_t option_connector,
 		return -1;
 	}
 
+	ec->min_width  = resources->min_width;
+	ec->max_width  = resources->max_width;
+	ec->min_height = resources->min_height;
+	ec->max_height = resources->max_height;
+
 	ec->num_crtcs = resources->count_crtcs;
 	memcpy(ec->crtcs, resources->crtcs, sizeof(uint32_t) * ec->num_crtcs);
 
-- 
1.7.9.5



More information about the wayland-devel mailing list