[PATCH 5/9] compositor: Store modes in physical units

alexl at redhat.com alexl at redhat.com
Tue May 28 07:23:36 PDT 2013


From: Alexander Larsson <alexl at redhat.com>

We changed the protocol to always list modes in physical pixel
units (not scaled). And we removed the scaled mode flag. This
just updates the DRM and X11 compositors and the gl and pixman renderers
to handle this.
---
 src/compositor-drm.c  | 37 +++++++++++++------------------------
 src/compositor-x11.c  |  6 ++----
 src/compositor.c      | 27 +++++++++++----------------
 src/compositor.h      |  2 +-
 src/gl-renderer.c     |  4 ++--
 src/pixman-renderer.c |  4 ++--
 6 files changed, 31 insertions(+), 49 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 4435162..4222e57 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -449,7 +449,6 @@ drm_output_prepare_scanout_surface(struct weston_output *_output,
 	    buffer->width != output->base.current->width ||
 	    buffer->height != output->base.current->height ||
 	    output->base.transform != es->buffer_transform ||
-	    output->base.scale != es->buffer_scale ||
 	    es->transform.enabled)
 		return NULL;
 
@@ -1249,7 +1248,7 @@ init_pixman(struct drm_compositor *ec)
 }
 
 static struct drm_mode *
-drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info, int scale)
+drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
 {
 	struct drm_mode *mode;
 	uint64_t refresh;
@@ -1258,15 +1257,9 @@ drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info, int scale)
 	if (mode == NULL)
 		return NULL;
 
-	if (info->hdisplay % scale != 0 ||
-	    info->vdisplay % scale) {
-		weston_log("Mode %dx%d not multiple of scale %d\n", info->hdisplay, info->vdisplay, scale);
-		return NULL;
-	}
-
 	mode->base.flags = 0;
-	mode->base.width = info->hdisplay / scale;
-	mode->base.height = info->vdisplay / scale;
+	mode->base.width = info->hdisplay;
+	mode->base.height = info->vdisplay;
 
 	/* Calculate higher precision (mHz) refresh rate */
 	refresh = (info->clock * 1000000LL / info->htotal +
@@ -1282,9 +1275,6 @@ drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info, int scale)
 	mode->base.refresh = refresh;
 	mode->mode_info = *info;
 
-	if (scale != 1)
-		mode->base.flags |= WL_OUTPUT_MODE_SCALED;
-
 	if (info->type & DRM_MODE_TYPE_PREFERRED)
 		mode->base.flags |= WL_OUTPUT_MODE_PREFERRED;
 
@@ -1446,8 +1436,8 @@ drm_output_init_egl(struct drm_output *output, struct drm_compositor *ec)
 	int i, flags;
 
 	output->surface = gbm_surface_create(ec->gbm,
-					     output->base.current->width * output->base.scale,
-					     output->base.current->height * output->base.scale,
+					     output->base.current->width,
+					     output->base.current->height,
 					     GBM_FORMAT_XRGB8888,
 					     GBM_BO_USE_SCANOUT |
 					     GBM_BO_USE_RENDERING);
@@ -1491,12 +1481,12 @@ drm_output_init_pixman(struct drm_output *output, struct drm_compositor *c)
 	/* FIXME error checking */
 
 	for (i = 0; i < ARRAY_LENGTH(output->dumb); i++) {
-		output->dumb[i] = drm_fb_create_dumb(c, w * output->base.scale, h * output->base.scale);
+		output->dumb[i] = drm_fb_create_dumb(c, w, h);
 		if (!output->dumb[i])
 			goto err;
 
 		output->image[i] =
-			pixman_image_create_bits(PIXMAN_x8r8g8b8, w * output->base.scale, h * output->base.scale,
+			pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h,
 						 output->dumb[i]->map,
 						 output->dumb[i]->stride);
 		if (!output->image[i])
@@ -1507,7 +1497,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_compositor *c)
 		goto err;
 
 	pixman_region32_init_rect(&output->previous_damage,
-				  output->base.x, output->base.y, w, h);
+				  output->base.x, output->base.y, output->base.width, output->base.height);
 
 	return 0;
 
@@ -1839,8 +1829,7 @@ create_output_for_connector(struct drm_compositor *ec,
 	}
 
 	for (i = 0; i < connector->count_modes; i++) {
-		drm_mode = drm_output_add_mode(output, 
-					       &connector->modes[i], scale);
+		drm_mode = drm_output_add_mode(output, &connector->modes[i]);
 		if (!drm_mode)
 			goto err_free;
 	}
@@ -1858,8 +1847,8 @@ create_output_for_connector(struct drm_compositor *ec,
 
 	wl_list_for_each(drm_mode, &output->base.mode_list, base.link) {
 		if (config == OUTPUT_CONFIG_MODE &&
-		    width == drm_mode->base.width * scale &&
-		    height == drm_mode->base.height * scale)
+		    width == drm_mode->base.width &&
+		    height == drm_mode->base.height)
 			configured = drm_mode;
 		if (!memcmp(&crtc_mode, &drm_mode->mode_info, sizeof crtc_mode))
 			current = drm_mode;
@@ -1868,13 +1857,13 @@ create_output_for_connector(struct drm_compositor *ec,
 	}
 
 	if (config == OUTPUT_CONFIG_MODELINE) {
-		configured = drm_output_add_mode(output, &modeline, scale);
+		configured = drm_output_add_mode(output, &modeline);
 		if (!configured)
 			goto err_free;
 	}
 
 	if (current == NULL && crtc_mode.clock != 0) {
-		current = drm_output_add_mode(output, &crtc_mode, scale);
+		current = drm_output_add_mode(output, &crtc_mode);
 		if (!current)
 			goto err_free;
 	}
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index ba6d053..5e476c1 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -823,11 +823,9 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
 
 	output->mode.flags =
 		WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
-	if (output->scale != 1)
-		output->mode.flags |= WL_OUTPUT_MODE_SCALED;
 
-	output->mode.width = width;
-	output->mode.height = height;
+	output->mode.width = output_width;
+	output->mode.height = output_height;
 	output->mode.refresh = 60000;
 	output->scale = scale;
 	wl_list_init(&output->base.mode_list);
diff --git a/src/compositor.c b/src/compositor.c
index f9bdb09..79acc76 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -92,9 +92,7 @@ sigchld_handler(int signal_number, void *data)
 }
 
 static void
-weston_output_transform_init(struct weston_output *output, uint32_t transform);
-static void
-weston_output_scale_init(struct weston_output *output, uint32_t scale);
+weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale);
 
 WL_EXPORT int
 weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode)
@@ -114,8 +112,7 @@ weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode
 	pixman_region32_copy(&old_output_region, &output->region);
 
 	/* Update output region and transformation matrix */
-	weston_output_transform_init(output, output->transform);
-	weston_output_scale_init(output, output->scale);
+	weston_output_transform_scale_init(output, output->transform, output->scale);
 
 	pixman_region32_init(&output->previous_damage);
 	pixman_region32_init_rect(&output->region, output->x, output->y,
@@ -2643,7 +2640,7 @@ weston_output_update_matrix(struct weston_output *output)
 }
 
 static void
-weston_output_transform_init(struct weston_output *output, uint32_t transform)
+weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
 {
 	output->transform = transform;
 
@@ -2666,12 +2663,11 @@ weston_output_transform_init(struct weston_output *output, uint32_t transform)
 	default:
 		break;
 	}
-}
 
-static void
-weston_output_scale_init(struct weston_output *output, uint32_t scale)
-{
-        output->scale = scale;
+	output->scale = scale;
+
+	output->width /= scale;
+	output->height /= scale;
 }
 
 WL_EXPORT void
@@ -2688,7 +2684,7 @@ weston_output_move(struct weston_output *output, int x, int y)
 
 WL_EXPORT void
 weston_output_init(struct weston_output *output, struct weston_compositor *c,
-		   int x, int y, int width, int height, uint32_t transform,
+		   int x, int y, int mm_width, int mm_height, uint32_t transform,
 		   uint32_t scale)
 {
 	output->compositor = c;
@@ -2698,12 +2694,11 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
 	output->border.bottom = 0;
 	output->border.left = 0;
 	output->border.right = 0;
-	output->mm_width = width;
-	output->mm_height = height;
+	output->mm_width = mm_width;
+	output->mm_height = mm_height;
 	output->dirty = 1;
 
-	weston_output_transform_init(output, transform);
-	weston_output_scale_init(output, scale);
+	weston_output_transform_scale_init(output, transform, scale);
 	weston_output_init_zoom(output);
 
 	weston_output_move(output, x, y);
diff --git a/src/compositor.h b/src/compositor.h
index e3a798e..3b428c5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1025,7 +1025,7 @@ void
 weston_output_move(struct weston_output *output, int x, int y);
 void
 weston_output_init(struct weston_output *output, struct weston_compositor *c,
-		   int x, int y, int width, int height, uint32_t transform, uint32_t scale);
+		   int x, int y, int mm_width, int mm_height, uint32_t transform, uint32_t scale);
 void
 weston_output_destroy(struct weston_output *output);
 
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index c89b916..4b449d1 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1014,9 +1014,9 @@ gl_renderer_repaint_output(struct weston_output *output,
 	int32_t width, height;
 	pixman_region32_t buffer_damage, total_damage;
 
-	width = output->current->width * output->scale +
+	width = output->current->width +
 		output->border.left + output->border.right;
-	height = output->current->height * output->scale +
+	height = output->current->height +
 		output->border.top + output->border.bottom;
 
 	glViewport(0, 0, width, height);
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 315ea15..ba7cb43 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -691,8 +691,8 @@ pixman_renderer_output_create(struct weston_output *output)
 		return -1;
 
 	/* set shadow image transformation */
-	w = output->current->width * output->scale;
-	h = output->current->height * output->scale;
+	w = output->current->width;
+	h = output->current->height;
 
 	po->shadow_buffer = malloc(w * h * 4);
 
-- 
1.8.1.4



More information about the wayland-devel mailing list