[RFC weston 3/3] client: image client requesting for scaling filter type.
Sameer Lattannavar
sameer.lattannavar at intel.com
Fri Dec 20 06:56:09 UTC 2019
Modify existing sample weston client image application to add
a scaling_filter request through commandline parameter.
Signed-off-by: Sameer Lattannavar <sameer.lattannavar at intel.com>
---
clients/image.c | 49 ++++++++++++++++++++++++++++++++++++++++--------
clients/window.c | 7 +++++++
clients/window.h | 4 ++++
3 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/clients/image.c b/clients/image.c
index 0a8fb5b5..b1bc5637 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -44,6 +44,17 @@
#include "window.h"
#include "shared/cairo-util.h"
+enum weston_scaling_filters {
+ WDRM_SCALING_FILTER_DEFAULT = 0,
+ WDRM_SCALING_FILTER_MEDIUM,
+ WDRM_SCALING_FILTER_BILINEAR,
+ WDRM_SCALING_FILTER_NN,
+ WDRM_SCALING_FILTER_NN_IS_ONLY,
+ WDRM_SCALING_FILTER_EDGE_ENHANCE,
+ WDRM_SCALING_FILTER_INVALID,
+ WDRM_SCALING_FILTER__COUNT
+};
+
struct image {
struct window *window;
struct widget *widget;
@@ -355,6 +366,8 @@ close_handler(void *data)
free(image);
}
+int request_scaling_filter;
+
static struct image *
image_create(struct display *display, const char *filename,
int *image_counter)
@@ -402,20 +415,38 @@ image_create(struct display *display, const char *filename,
widget_set_axis_handler(image->widget, axis_handler);
window_set_key_handler(image->window, key_handler);
widget_schedule_resize(image->widget, 500, 400);
+ if (request_scaling_filter)
+ window_set_scaling_filter(image->window,
+ WDRM_SCALING_FILTER_NN);
return image;
}
+static void
+usage()
+{
+ fprintf(stderr, "Usage: weston-image [OPTIONS]\n\n");
+ fprintf(stderr, "Options:"
+ "-is <Image Path>\t Image to display withi \t"
+ "scaling filter type for integer scaling\n"
+ "<Image/s> ...\n"
+ "-h\tThis help text\n\n");
+
+ exit(0);
+}
+
int
main(int argc, char *argv[])
{
struct display *d;
int i;
int image_counter = 0;
-
- if (argc <= 1 || argv[1][0]=='-') {
- printf("Usage: %s image...\n", argv[0]);
- return 1;
+ for (i = 0; i < argc; i++) {
+ if (strcmp("-is", argv[i]) == 0 && argc == 3) {
+ request_scaling_filter = 1;
+ } else if (argc <= 1 || (strcmp("-h", argv[i]) == 0)
+ || (strcmp("-help", argv[i]) == 0))
+ usage();
}
d = display_create(&argc, argv);
@@ -424,10 +455,12 @@ main(int argc, char *argv[])
strerror(errno));
return -1;
}
-
- for (i = 1; i < argc; i++)
- image_create(d, argv[i], &image_counter);
-
+ if (request_scaling_filter) {
+ image_create(d, argv[2], &image_counter);
+ } else {
+ for (i = 1; i < argc; i++)
+ image_create(d, argv[i], &image_counter);
+ }
if (image_counter > 0)
display_run(d);
diff --git a/clients/window.c b/clients/window.c
index 2bd303ee..03ec80ab 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1505,6 +1505,13 @@ window_set_buffer_scale(struct window *window,
scale);
}
+void
+window_set_scaling_filter(struct window *window,
+ int scaling_filter)
+{
+ wl_surface_set_scaling_filter(window->main_surface->surface,
+ scaling_filter);
+}
uint32_t
window_get_buffer_scale(struct window *window)
{
diff --git a/clients/window.h b/clients/window.h
index c66dd065..f86c579c 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -345,6 +345,10 @@ void
window_set_buffer_scale(struct window *window,
int32_t scale);
+void
+window_set_scaling_filter(struct window *window,
+ int scaling_filter);
+
uint32_t
window_get_output_scale(struct window *window);
--
2.17.1
More information about the wayland-devel
mailing list