[RFC weston 1/3] libweston: add set_scaling_filter API and implementation

Sameer Lattannavar sameer.lattannavar at intel.com
Fri Dec 20 06:56:07 UTC 2019


set_scaling_filter is a libweston API for setting scaling filter and
wayland protocol extension implementation for setting crtc property as
per client's request.

Signed-off-by: Sameer Lattannavar <sameer.lattannavar at intel.com>
---
 include/libweston/libweston.h |  7 +++++++
 libweston/compositor.c        | 25 ++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
index dc54b170..12e25c67 100644
--- a/include/libweston/libweston.h
+++ b/include/libweston/libweston.h
@@ -321,6 +321,13 @@ struct weston_output {
 	bool enabled; /**< is in the output_list, not pending list */
 	int scale;
 
+	/*
+	 * set_scaling_filter: this function pointer calls into
+	 * drm_scaling_filter to set CRTC property to NN filter to get
+	 * non-blurry frames for Pixel-Art games.
+	 */
+	void (*set_scaling_filter)(struct weston_output *output, int filter);
+
 	int (*enable)(struct weston_output *output);
 	int (*disable)(struct weston_output *output);
 
diff --git a/libweston/compositor.c b/libweston/compositor.c
index dbc64927..28f5054c 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -3753,6 +3753,28 @@ surface_set_buffer_scale(struct wl_client *client,
 	surface->pending.buffer_viewport.changed = 1;
 }
 
+static void
+surface_set_scaling_filter(struct wl_client *client,
+			   struct wl_resource *resource,
+			   int scaling_filter)
+{
+	struct weston_surface *surface = wl_resource_get_user_data(resource);
+	struct weston_output *w_output;
+
+	if (scaling_filter < 0) {
+		wl_resource_post_error(resource,
+			WL_SURFACE_ERROR_INVALID_SCALE,
+			"Supported Scaling Filter not selected",
+			"(%d' specified)", scaling_filter);
+		return;
+	}
+	wl_list_for_each(w_output, &surface->compositor->output_list, link) {
+		weston_log("Scaling_filter: weston_output Name: %s\n",
+			w_output->name);
+		w_output->set_scaling_filter(w_output, scaling_filter);
+	}
+}
+
 static const struct wl_surface_interface surface_interface = {
 	surface_destroy,
 	surface_attach,
@@ -3763,7 +3785,8 @@ static const struct wl_surface_interface surface_interface = {
 	surface_commit,
 	surface_set_buffer_transform,
 	surface_set_buffer_scale,
-	surface_damage_buffer
+	surface_damage_buffer,
+	surface_set_scaling_filter
 };
 
 static void
-- 
2.17.1



More information about the wayland-devel mailing list