[vlc-commits] wayland/shm: update to wp_viewporter protocol version 1 (fixes #16834)

Rémi Denis-Courmont git at videolan.org
Sun Jan 29 14:36:58 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 29 15:27:47 2017 +0200| [c73072e1caf8207f1d1b2ef0cd524360564bea8a] | committer: Rémi Denis-Courmont

wayland/shm: update to wp_viewporter protocol version 1 (fixes #16834)

The wl_scaler protocol no longer exists. wp_viewporter replaces it.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c73072e1caf8207f1d1b2ef0cd524360564bea8a
---

 modules/video_output/Makefile.am        |  15 ++-
 modules/video_output/wayland/scaler.xml | 210 --------------------------------
 modules/video_output/wayland/shm.c      |  31 ++---
 3 files changed, 28 insertions(+), 228 deletions(-)

diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index fefdf2f..7223479 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -120,14 +120,23 @@ endif
 
 ### Wayland ###
 libwl_shm_plugin_la_SOURCES = video_output/wayland/shm.c
-nodist_libwl_shm_plugin_la_SOURCES = video_output/wayland/scaler-protocol.c
+nodist_libwl_shm_plugin_la_SOURCES = \
+	video_output/wayland/viewporter-client-protocol.h \
+	video_output/wayland/viewporter-protocol.c
 libwl_shm_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
 	-I$(builddir)/video_output/wayland
 libwl_shm_plugin_la_CFLAGS = $(WAYLAND_CLIENT_CFLAGS)
 libwl_shm_plugin_la_LIBADD = $(WAYLAND_CLIENT_LIBS)
-EXTRA_DIST += video_output/wayland/scaler.xml
 CLEANFILES += $(nodist_libwl_shm_plugin_la_SOURCES)
 
+video_output/wayland/viewporter-client-protocol.h: \
+		$(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml
+	$(AM_V_GEN)$(WAYLAND_SCANNER) client-header $< $@
+
+video_output/wayland/viewporter-protocol.c: \
+		$(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml
+	$(AM_V_GEN)$(WAYLAND_SCANNER) code $< $@
+
 libwl_shell_surface_plugin_la_SOURCES = video_output/wayland/shell_surface.c
 libwl_shell_surface_plugin_la_CFLAGS = $(WAYLAND_CLIENT_CFLAGS)
 libwl_shell_surface_plugin_la_LIBADD = $(WAYLAND_CLIENT_LIBS) $(LIBPTHREAD)
@@ -138,7 +147,7 @@ libegl_wl_plugin_la_CFLAGS = $(AM_CFLAGS) $(EGL_CFLAGS) $(WAYLAND_EGL_CFLAGS)
 libegl_wl_plugin_la_LIBADD = $(EGL_LIBS) $(WAYLAND_EGL_LIBS)
 
 if HAVE_WAYLAND
-BUILT_SOURCES += video_output/wayland/scaler-client-protocol.h
+BUILT_SOURCES += $(nodist_libwl_shm_plugin_la_SOURCES)
 vout_LTLIBRARIES += libwl_shm_plugin.la
 vout_LTLIBRARIES += libwl_shell_surface_plugin.la
 if HAVE_WAYLAND_EGL
diff --git a/modules/video_output/wayland/scaler.xml b/modules/video_output/wayland/scaler.xml
deleted file mode 100644
index 9642af2..0000000
--- a/modules/video_output/wayland/scaler.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
-
-  <copyright>
-    Copyright © 2013-2014 Collabora, Ltd.
-
-    Permission to use, copy, modify, distribute, and sell this
-    software and its documentation for any purpose is hereby granted
-    without fee, provided that the above copyright notice appear in
-    all copies and that both that copyright notice and this permission
-    notice appear in supporting documentation, and that the name of
-    the copyright holders not be used in advertising or publicity
-    pertaining to distribution of the software without specific,
-    written prior permission.  The copyright holders make no
-    representations about the suitability of this software for any
-    purpose.  It is provided "as is" without express or implied
-    warranty.
-
-    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
-    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
-    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-    THIS SOFTWARE.
-  </copyright>
-
-  <interface name="wl_scaler" version="2">
-    <description summary="surface cropping and scaling">
-      The global interface exposing surface cropping and scaling
-      capabilities is used to instantiate an interface extension for a
-      wl_surface object. This extended interface will then allow
-      cropping and scaling the surface contents, effectively
-      disconnecting the direct relationship between the buffer and the
-      surface size.
-    </description>
-
-    <request name="destroy" type="destructor">
-      <description summary="unbind from the cropping and scaling interface">
-	Informs the server that the client will not be using this
-	protocol object anymore. This does not affect any other objects,
-	wl_viewport objects included.
-      </description>
-    </request>
-
-    <enum name="error">
-      <entry name="viewport_exists" value="0"
-             summary="the surface already has a viewport object associated"/>
-    </enum>
-
-    <request name="get_viewport">
-      <description summary="extend surface interface for crop and scale">
-	Instantiate an interface extension for the given wl_surface to
-	crop and scale its content. If the given wl_surface already has
-	a wl_viewport object associated, the viewport_exists
-	protocol error is raised.
-      </description>
-
-      <arg name="id" type="new_id" interface="wl_viewport"
-           summary="the new viewport interface id"/>
-      <arg name="surface" type="object" interface="wl_surface"
-           summary="the surface"/>
-    </request>
-  </interface>
-
-  <interface name="wl_viewport" version="2">
-    <description summary="crop and scale interface to a wl_surface">
-      An additional interface to a wl_surface object, which allows the
-      client to specify the cropping and scaling of the surface
-      contents.
-
-      This interface allows to define the source rectangle (src_x,
-      src_y, src_width, src_height) from where to take the wl_buffer
-      contents, and scale that to destination size (dst_width,
-      dst_height). This state is double-buffered, and is applied on the
-      next wl_surface.commit.
-
-      The two parts of crop and scale state are independent: the source
-      rectangle, and the destination size. Initially both are unset, that
-      is, no scaling is applied. The whole of the current wl_buffer is
-      used as the source, and the surface size is as defined in
-      wl_surface.attach.
-
-      If the destination size is set, it causes the surface size to become
-      dst_width, dst_height. The source (rectangle) is scaled to exactly
-      this size. This overrides whatever the attached wl_buffer size is,
-      unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
-      has no content and therefore no size. Otherwise, the size is always
-      at least 1x1 in surface coordinates.
-
-      If the source rectangle is set, it defines what area of the
-      wl_buffer is taken as the source. If the source rectangle is set and
-      the destination size is not set, the surface size becomes the source
-      rectangle size rounded up to the nearest integer. If the source size
-      is already exactly integers, this results in cropping without scaling.
-
-      The coordinate transformations from buffer pixel coordinates up to
-      the surface-local coordinates happen in the following order:
-        1. buffer_transform (wl_surface.set_buffer_transform)
-        2. buffer_scale (wl_surface.set_buffer_scale)
-        3. crop and scale (wl_viewport.set*)
-      This means, that the source rectangle coordinates of crop and scale
-      are given in the coordinates after the buffer transform and scale,
-      i.e. in the coordinates that would be the surface-local coordinates
-      if the crop and scale was not applied.
-
-      If the source rectangle is partially or completely outside of the
-      wl_buffer, then the surface contents are undefined (not void), and
-      the surface size is still dst_width, dst_height.
-
-      The x, y arguments of wl_surface.attach are applied as normal to
-      the surface. They indicate how many pixels to remove from the
-      surface size from the left and the top. In other words, they are
-      still in the surface-local coordinate system, just like dst_width
-      and dst_height are.
-
-      If the wl_surface associated with the wl_viewport is destroyed,
-      the wl_viewport object becomes inert.
-
-      If the wl_viewport object is destroyed, the crop and scale
-      state is removed from the wl_surface. The change will be applied
-      on the next wl_surface.commit.
-    </description>
-
-    <request name="destroy" type="destructor">
-      <description summary="remove scaling and cropping from the surface">
-	The associated wl_surface's crop and scale state is removed.
-	The change is applied on the next wl_surface.commit.
-      </description>
-    </request>
-
-    <enum name="error">
-      <entry name="bad_value" value="0"
-             summary="negative or zero values in width or height"/>
-    </enum>
-
-    <request name="set">
-      <description summary="set the crop and scale state">
-	Set both source rectangle and destination size of the associated
-	wl_surface. See wl_viewport for the description, and relation to
-	the wl_buffer size.
-
-	The bad_value protocol error is raised if src_width or
-	src_height is negative, or if dst_width or dst_height is not
-	positive.
-
-	The crop and scale state is double-buffered state, and will be
-	applied on the next wl_surface.commit.
-
-	Arguments dst_x and dst_y do not exist here, use the x and y
-	arguments to wl_surface.attach. The x, y, dst_width, and dst_height
-	define the surface-local coordinate system irrespective of the
-	attached wl_buffer size.
-      </description>
-
-      <arg name="src_x" type="fixed" summary="source rectangle x"/>
-      <arg name="src_y" type="fixed" summary="source rectangle y"/>
-      <arg name="src_width" type="fixed" summary="source rectangle width"/>
-      <arg name="src_height" type="fixed" summary="source rectangle height"/>
-      <arg name="dst_width" type="int" summary="surface width"/>
-      <arg name="dst_height" type="int" summary="surface height"/>
-    </request>
-
-    <request name="set_source" since="2">
-      <description summary="set the source rectangle for cropping">
-	Set the source rectangle of the associated wl_surface. See
-	wl_viewport for the description, and relation to the wl_buffer
-	size.
-
-	If width is -1.0 and height is -1.0, the source rectangle is unset
-	instead. Any other pair of values for width and height that
-	contains zero or negative values raises the bad_value protocol
-	error.
-
-	The crop and scale state is double-buffered state, and will be
-	applied on the next wl_surface.commit.
-      </description>
-
-      <arg name="x" type="fixed" summary="source rectangle x"/>
-      <arg name="y" type="fixed" summary="source rectangle y"/>
-      <arg name="width" type="fixed" summary="source rectangle width"/>
-      <arg name="height" type="fixed" summary="source rectangle height"/>
-    </request>
-
-    <request name="set_destination" since="2">
-      <description summary="set the surface size for scaling">
-	Set the destination size of the associated wl_surface. See
-	wl_viewport for the description, and relation to the wl_buffer
-	size.
-
-	If width is -1 and height is -1, the destination size is unset
-	instead. Any other pair of values for width and height that
-	contains zero or negative values raises the bad_value protocol
-	error.
-
-	The crop and scale state is double-buffered state, and will be
-	applied on the next wl_surface.commit.
-
-	Arguments x and y do not exist here, use the x and y arguments to
-	wl_surface.attach. The x, y, width, and height define the
-	surface-local coordinate system irrespective of the attached
-	wl_buffer size.
-      </description>
-
-      <arg name="width" type="int" summary="surface width"/>
-      <arg name="height" type="int" summary="surface height"/>
-    </request>
-  </interface>
-</protocol>
diff --git a/modules/video_output/wayland/shm.c b/modules/video_output/wayland/shm.c
index 547db7b..c7c6e8a 100644
--- a/modules/video_output/wayland/shm.c
+++ b/modules/video_output/wayland/shm.c
@@ -3,7 +3,7 @@
  * @brief Wayland shared memory video output module for VLC media player
  */
 /*****************************************************************************
- * Copyright © 2014 Rémi Denis-Courmont
+ * Copyright © 2014, 2017 Rémi Denis-Courmont
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -34,7 +34,7 @@
 #include <unistd.h>
 
 #include <wayland-client.h>
-#include "scaler-client-protocol.h"
+#include "viewporter-client-protocol.h"
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -49,8 +49,8 @@ struct vout_display_sys_t
     vout_window_t *embed; /* VLC window */
     struct wl_event_queue *eventq;
     struct wl_shm *shm;
-    struct wl_scaler *scaler;
-    struct wl_viewport *viewport;
+    struct wp_viewporter *viewporter;
+    struct wp_viewport *viewport;
 
     picture_pool_t *pool; /* picture pool */
 
@@ -322,11 +322,12 @@ static int Control(vout_display_t *vd, int query, va_list ap)
                 video_format_t fmt;
 
                 video_format_ApplyRotation(&fmt, src);
-                wl_viewport_set(sys->viewport,
+                wp_viewport_set_source(sys->viewport,
                                 wl_fixed_from_int(fmt.i_x_offset),
                                 wl_fixed_from_int(fmt.i_y_offset),
                                 wl_fixed_from_int(fmt.i_visible_width),
-                                wl_fixed_from_int(fmt.i_visible_height),
+                                wl_fixed_from_int(fmt.i_visible_height));
+                wp_viewport_set_destination(sys->viewport,
                                 place.width, place.height);
             }
             else
@@ -370,9 +371,9 @@ static void registry_global_cb(void *data, struct wl_registry *registry,
     if (!strcmp(iface, "wl_shm"))
         sys->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
     else
-    if (!strcmp(iface, "wl_scaler"))
-        sys->scaler = wl_registry_bind(registry, name, &wl_scaler_interface,
-                                       1);
+    if (!strcmp(iface, "wp_viewporter"))
+        sys->viewporter = wl_registry_bind(registry, name,
+                                           &wp_viewporter_interface, 1);
     else
     if (!strcmp(iface, "wl_compositor"))
         sys->use_buffer_transform = vers >= 2;
@@ -404,7 +405,7 @@ static int Open(vlc_object_t *obj)
     sys->embed = NULL;
     sys->eventq = NULL;
     sys->shm = NULL;
-    sys->scaler = NULL;
+    sys->viewporter = NULL;
     sys->pool = NULL;
     sys->x = 0;
     sys->y = 0;
@@ -437,8 +438,8 @@ static int Open(vlc_object_t *obj)
     wl_display_roundtrip_queue(display, sys->eventq);
 
     struct wl_surface *surface = sys->embed->handle.wl;
-    if (sys->scaler != NULL)
-        sys->viewport = wl_scaler_get_viewport(sys->scaler, surface);
+    if (sys->viewporter != NULL)
+        sys->viewport = wp_viewporter_get_viewport(sys->viewporter, surface);
     else
         sys->viewport = NULL;
 
@@ -494,9 +495,9 @@ static void Close(vlc_object_t *obj)
     ResetPictures(vd);
 
     if (sys->viewport != NULL)
-        wl_viewport_destroy(sys->viewport);
-    if (sys->scaler != NULL)
-        wl_scaler_destroy(sys->scaler);
+        wp_viewport_destroy(sys->viewport);
+    if (sys->viewporter != NULL)
+        wp_viewporter_destroy(sys->viewporter);
     wl_shm_destroy(sys->shm);
     wl_display_flush(sys->embed->display.wl);
     wl_event_queue_destroy(sys->eventq);



More information about the vlc-commits mailing list