[PATCH weston v3 10/17] clients/scaler: migrate to wp_viewporter

Pekka Paalanen ppaalanen at gmail.com
Tue Apr 26 12:51:02 UTC 2016


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

Use wp_viewporter instead of wl_scaler and rename things accordingly.

Since interface versions were reset, there is no need to check the
interface version anymore, and the wl_scaler.set request disappeared.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 Makefile.am      |  4 ++++
 clients/scaler.c | 43 +++++++++++++------------------------------
 2 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9056045..22647ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -573,6 +573,8 @@ nodist_libtoytoolkit_la_SOURCES =			\
 	protocol/text-cursor-position-client-protocol.h	\
 	protocol/scaler-protocol.c			\
 	protocol/scaler-client-protocol.h		\
+	protocol/viewporter-protocol.c			\
+	protocol/viewporter-client-protocol.h		\
 	protocol/xdg-shell-unstable-v5-protocol.c			\
 	protocol/xdg-shell-unstable-v5-client-protocol.h		\
 	protocol/ivi-application-protocol.c		\
@@ -778,6 +780,8 @@ BUILT_SOURCES +=					\
 	protocol/weston-desktop-shell-protocol.c			\
 	protocol/scaler-client-protocol.h		\
 	protocol/scaler-protocol.c			\
+	protocol/viewporter-client-protocol.h		\
+	protocol/viewporter-protocol.c			\
 	protocol/presentation-time-protocol.c				\
 	protocol/presentation-time-client-protocol.h			\
 	protocol/fullscreen-shell-unstable-v1-protocol.c		\
diff --git a/clients/scaler.c b/clients/scaler.c
index 1fcf2c0..f504c73 100644
--- a/clients/scaler.c
+++ b/clients/scaler.c
@@ -32,7 +32,7 @@
 #include <linux/input.h>
 
 #include "window.h"
-#include "scaler-client-protocol.h"
+#include "viewporter-client-protocol.h"
 
 #define BUFFER_SCALE 2
 static const int BUFFER_WIDTH = 421 * BUFFER_SCALE;
@@ -50,9 +50,8 @@ struct box {
 	struct widget *widget;
 	int width, height;
 
-	struct wl_scaler *scaler;
-	int scaler_version;
-	struct wl_viewport *viewport;
+	struct wp_viewporter *viewporter;
+	struct wp_viewport *viewport;
 
 	enum {
 		MODE_NO_VIEWPORT,
@@ -84,33 +83,20 @@ set_my_viewport(struct box *box)
 	src_width = wl_fixed_from_double((RECT_W - 0.5) / BUFFER_SCALE);
 	src_height = wl_fixed_from_double((RECT_H - 0.5) / BUFFER_SCALE);
 
-	if (box->scaler_version < 2 && box->mode != MODE_SRC_DST) {
-		fprintf(stderr, "Error: server's wl_scaler interface version "
-			"%d does not support this mode.\n",
-			box->scaler_version);
-		exit(1);
-	}
-
 	switch (box->mode){
 	case MODE_SRC_ONLY:
-		wl_viewport_set_source(box->viewport, src_x, src_y,
+		wp_viewport_set_source(box->viewport, src_x, src_y,
 				       src_width, src_height);
 		break;
 	case MODE_DST_ONLY:
-		wl_viewport_set_destination(box->viewport,
+		wp_viewport_set_destination(box->viewport,
 					    dst_width, dst_height);
 		break;
 	case MODE_SRC_DST:
-		if (box->scaler_version < 2) {
-			wl_viewport_set(box->viewport,
-					src_x, src_y, src_width, src_height,
-					dst_width, dst_height);
-		} else {
-			wl_viewport_set_source(box->viewport, src_x, src_y,
-					       src_width, src_height);
-			wl_viewport_set_destination(box->viewport,
-						    dst_width, dst_height);
-		}
+		wp_viewport_set_source(box->viewport, src_x, src_y,
+				       src_width, src_height);
+		wp_viewport_set_destination(box->viewport,
+					    dst_width, dst_height);
 		break;
 	default:
 		assert(!"not reached");
@@ -188,14 +174,11 @@ global_handler(struct display *display, uint32_t name,
 {
 	struct box *box = data;
 
-	if (strcmp(interface, "wl_scaler") == 0) {
-		box->scaler_version = version < 2 ? version : 2;
-
-		box->scaler = display_bind(display, name,
-					   &wl_scaler_interface,
-					   box->scaler_version);
+	if (strcmp(interface, "wp_viewporter") == 0) {
+		box->viewporter = display_bind(display, name,
+					       &wp_viewporter_interface, 1);
 
-		box->viewport = wl_scaler_get_viewport(box->scaler,
+		box->viewport = wp_viewporter_get_viewport(box->viewporter,
 			widget_get_wl_surface(box->widget));
 
 		set_my_viewport(box);
-- 
2.7.3



More information about the wayland-devel mailing list