Discussion:
[PATCH wayland-protocols weston 0/7] Stabilize wl_scaler as wp_viewporter
Pekka Paalanen
2016-04-15 14:53:14 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Hi,

it's a high time we declare the scaling and cropping extension as stable. I
took wl_scaler from Weston, renamed it to wp_viewporter, and removed the
redundant wp_viewport.set request.

There must be a wayland-protocols release, before the Weston patches can be
landed, and when that happens, the wayland-protocols dependency must be bumped
accordingly.


Thanks,
pq

Pekka Paalanen (2):
stable: add viewporter draft
stable/viewporter: finish stabilization

Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 181 +++++++++++++++++++++++++++++++++++++++
3 files changed, 189 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml

Pekka Paalanen (5):
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml

Makefile.am | 17 ++--
clients/scaler.c | 43 +++-------
clients/simple-damage.c | 32 ++++----
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------------------------------------
src/compositor.c | 110 ++++++++-----------------
src/compositor.h | 5 +-
7 files changed, 76 insertions(+), 341 deletions(-)
delete mode 100644 protocol/scaler.xml
--
2.7.3
Pekka Paalanen
2016-04-15 14:53:15 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.

The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml

diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+Maintainers:
+Pekka Paalanen <***@collabora.co.uk>
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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>
--
2.7.3
Yong Bakos
2016-04-18 12:15:28 UTC
Permalink
Post by Pekka Paalanen
This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.
The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.
There's one paragraph I think could use a rewriting, noted inline below,
but since this is just a move, the writing and such is
Reviewed-by: Yong Bakos <***@humanoriented.com>

yong
Post by Pekka Paalanen
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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 first sentence of this paragraph is a bit cumbersome. Maybe:

This interface defines a source rectangle of the wl_buffer
contents (src_x, src_y, src_width, src_height), and a means of
scaling the source rectangle to a destination size (dst_width,
dst_height).
Post by Pekka Paalanen
+
+ 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
+ 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>
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-04-19 10:49:14 UTC
Permalink
On Mon, 18 Apr 2016 07:15:28 -0500
Post by Yong Bakos
Post by Pekka Paalanen
This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.
The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.
There's one paragraph I think could use a rewriting, noted inline below,
but since this is just a move, the writing and such is
yong
Post by Pekka Paalanen
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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.
This interface defines a source rectangle of the wl_buffer
contents (src_x, src_y, src_width, src_height), and a means of
scaling the source rectangle to a destination size (dst_width,
dst_height).
Right. We also need to be careful to not imply an incorrect coordinate
space. The src coordinates are not buffer coordinates. It is also a
source not for wl_buffer but from wl_buffer.

I've had lots of issues in writing this, because there are two concepts
of surface content: the one before wp_viewport, and the one after
wp_viewport.

The src coordinates are in surface local coordinates as if there was no
wp_viewport defined at all. This is explained further below.

So, what to write here... "allows to define" was to mean that simply
creating a wp_viewport does not change anything, but you could use it
to change things.

How about:

This interface works with two concepts: the source rectangle
(src_x, src_y, src_width, src_height), and the destination size
(dst_width, dst_height). The contents of the source rectangle
are scaled to the destination size, and content outside the
source rectangle is culled. This state is double-buffered, and
is applied on the next wl_surface.commit.

Maybe I should keep the argument names src_x, src_y, src_width,
src_height, dst_width, dst_height also in the wp_viewport.set_source
and wp_viewport.set_destination requests to make a clear connection to
this documentation?


Thanks,
pq
Post by Yong Bakos
Post by Pekka Paalanen
+
+ 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
+ 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>
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Daniel Stone
2016-04-18 14:16:39 UTC
Permalink
Hi,
Post by Pekka Paalanen
+ 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.
I like Yong's rewording, except with an additional bikeshed of 'allows
the client to control the [...]' perhaps.
Post by Pekka Paalanen
+ 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.
Ugh, I really intensely dislike that middle section. The cropping and
scaling are completely independent ... except where they aren't,
because sometimes we'll magically do it for you. I'd very much prefer
to see fractional crop + no scale defined as a protocol error, i.e.
the user must always explicitly set a configuration that results in an
integral destination size.
Post by Pekka Paalanen
+ 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.
Again, I'd rather see this defined as a protocol error. Without
explicit border-colour/mode controls (e.g. 'sample this colour for
anything outside buffer bounds'), the result of sampling outside the
source image can never be useful (at least AFAICT). So, why would you
ever want to do so? To achieve more perfect scaling factors, at the
expense of having to display some fractional garbage?
Post by Pekka Paalanen
+ If the wl_surface associated with the wl_viewport is destroyed,
+ the wl_viewport object becomes inert.
Should attempting to call wl_viewport::set_* then result in an error?
Post by Pekka Paalanen
+ Arguments dst_x and dst_y do not exist here, use the x and y
+ arguments to wl_surface.attach.
The x and y arguments perform relative translation of the surface, and
as such I don't think are really analagous. I'd suggest just deleting
this to avoid confusion.
Post by Pekka Paalanen
+ <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.
This is different to the bare 'set' request, which doesn't (at least
in its documentation) allow for this. But that's being removed anyway,
so no problem. Should we require a pair of fixed values for x and y
here, either (0,0) as the state they'll be fixed to, or (-1,-1) for
symmetry?

Cheers,
Daniel
Pekka Paalanen
2016-04-19 11:13:02 UTC
Permalink
On Mon, 18 Apr 2016 15:16:39 +0100
Post by Daniel Stone
Hi,
Post by Pekka Paalanen
+ 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.
I like Yong's rewording, except with an additional bikeshed of 'allows
the client to control the [...]' perhaps.
I ended up rewriting it too, please see if it's better in my reply to
Yong.
Post by Daniel Stone
Post by Pekka Paalanen
+ 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.
Ugh, I really intensely dislike that middle section. The cropping and
scaling are completely independent ... except where they aren't,
because sometimes we'll magically do it for you. I'd very much prefer
to see fractional crop + no scale defined as a protocol error, i.e.
the user must always explicitly set a configuration that results in an
integral destination size.
Ok, so it is an error to have destination size unset and use
non-integer source size. However, integer source size is allowed.

I'll change that and add a error code for it.
Post by Daniel Stone
Post by Pekka Paalanen
+ 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.
Again, I'd rather see this defined as a protocol error. Without
explicit border-colour/mode controls (e.g. 'sample this colour for
anything outside buffer bounds'), the result of sampling outside the
source image can never be useful (at least AFAICT). So, why would you
ever want to do so? To achieve more perfect scaling factors, at the
expense of having to display some fractional garbage?
Yup, I'll add an error code for it and make it an error.
Post by Daniel Stone
Post by Pekka Paalanen
+ If the wl_surface associated with the wl_viewport is destroyed,
+ the wl_viewport object becomes inert.
Should attempting to call wl_viewport::set_* then result in an error?
Inert follows the example of wl_subsurface. I'll make this an error,
too. There is no reason to assume that different code modules would be
in charge of the wp_viewport and wl_surface, unlike with sub-surfaces.
Post by Daniel Stone
Post by Pekka Paalanen
+ Arguments dst_x and dst_y do not exist here, use the x and y
+ arguments to wl_surface.attach.
The x and y arguments perform relative translation of the surface, and
as such I don't think are really analagous. I'd suggest just deleting
this to avoid confusion.
Ok. This sentence was here to silence any questions about "how do I
control where the destination rectangle goes on the wl_surface?" - a
question that doesn't make sense on closer inspection.
Post by Daniel Stone
Post by Pekka Paalanen
+ <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.
This is different to the bare 'set' request, which doesn't (at least
in its documentation) allow for this. But that's being removed anyway,
so no problem. Should we require a pair of fixed values for x and y
here, either (0,0) as the state they'll be fixed to, or (-1,-1) for
symmetry?
Right, these are new requests that supersede 'set'.

(-1, -1) for x,y would make sense. They are illegal values otherwise,
so they obviously do something special. So rather than ignore x,y for
unsetting, I will require them to be -1.


Thanks,
pq
Pekka Paalanen
2016-04-15 14:53:16 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Rename interfaces and the protocol to follow the policy.

Reset interface versions.

Remove the redundant wp_viewport.set request.

Replace "surface coordinates" with "surface local coordinates".

Hook up to build and install.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 1 +
stable/viewporter/viewporter.xml | 57 +++++++++++-----------------------------
2 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 033789f..71d2632 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ unstable_protocols = \

stable_protocols = \
stable/presentation-time/presentation-time.xml \
+ stable/viewporter/viewporter.xml \
$(NULL)

nobase_dist_pkgdata_DATA = \
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 0e482a6..1b47997 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
+<protocol name="viewporter">

<copyright>
Copyright © 2013-2014 Collabora, Ltd.
@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>

- <interface name="wl_scaler" version="2">
+ <interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
@@ -38,7 +38,7 @@
<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.
+ wp_viewport objects included.
</description>
</request>

@@ -51,18 +51,18 @@
<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
+ a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>

- <arg name="id" type="new_id" interface="wl_viewport"
+ <arg name="id" type="new_id" interface="wp_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">
+ <interface name="wp_viewport" version="1">
<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
@@ -85,7 +85,7 @@
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.
+ at least 1x1 in surface local 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
@@ -97,7 +97,7 @@
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*)
+ 3. crop and scale (wp_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
@@ -113,10 +113,10 @@
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_surface associated with the wp_viewport is destroyed,
+ the wp_viewport object becomes inert.

- If the wl_viewport object is destroyed, the crop and scale
+ If the wp_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>
@@ -133,37 +133,10 @@
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">
+ <request name="set_source">
<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
+ wp_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
@@ -181,10 +154,10 @@
<arg name="height" type="fixed" summary="source rectangle height"/>
</request>

- <request name="set_destination" since="2">
+ <request name="set_destination">
<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
+ wp_viewport for the description, and relation to the wl_buffer
size.

If width is -1 and height is -1, the destination size is unset
--
2.7.3
Yong Bakos
2016-04-18 12:19:15 UTC
Permalink
Post by Pekka Paalanen
Rename interfaces and the protocol to follow the policy.
Reset interface versions.
Remove the redundant wp_viewport.set request.
Replace "surface coordinates" with "surface local coordinates".
Hook up to build and install.
All name replacements look good to me. I would add one line break
before the closing protocol tag, to match other xml docs. Not sure if
that should happen here, in 1/2, or in a minor patch after all of this
makes it into master.

Otherwise Reviewed-by: Yong Bakos <***@humanoriented.com>

(always, my r'bs are just fwiw)

yong
Post by Pekka Paalanen
---
Makefile.am | 1 +
stable/viewporter/viewporter.xml | 57 +++++++++++-----------------------------
2 files changed, 16 insertions(+), 42 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 033789f..71d2632 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ unstable_protocols = \
stable_protocols = \
stable/presentation-time/presentation-time.xml \
+ stable/viewporter/viewporter.xml \
$(NULL)
nobase_dist_pkgdata_DATA = \
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 0e482a6..1b47997 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
+<protocol name="viewporter">
<copyright>
Copyright © 2013-2014 Collabora, Ltd.
@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="wl_scaler" version="2">
+ <interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
@@ -38,7 +38,7 @@
<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.
+ wp_viewport objects included.
</description>
</request>
@@ -51,18 +51,18 @@
<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
+ a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>
- <arg name="id" type="new_id" interface="wl_viewport"
+ <arg name="id" type="new_id" interface="wp_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">
+ <interface name="wp_viewport" version="1">
<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
@@ -85,7 +85,7 @@
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.
+ at least 1x1 in surface local 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
@@ -97,7 +97,7 @@
1. buffer_transform (wl_surface.set_buffer_transform)
2. buffer_scale (wl_surface.set_buffer_scale)
- 3. crop and scale (wl_viewport.set*)
+ 3. crop and scale (wp_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
@@ -113,10 +113,10 @@
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_surface associated with the wp_viewport is destroyed,
+ the wp_viewport object becomes inert.
- If the wl_viewport object is destroyed, the crop and scale
+ If the wp_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>
@@ -133,37 +133,10 @@
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">
+ <request name="set_source">
<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
+ wp_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
@@ -181,10 +154,10 @@
<arg name="height" type="fixed" summary="source rectangle height"/>
</request>
- <request name="set_destination" since="2">
+ <request name="set_destination">
<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
+ wp_viewport for the description, and relation to the wl_buffer
size.
If width is -1 and height is -1, the destination size is unset
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-04-15 14:53:17 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Migrate from wl_scaler to wp_viewporter extension. The viewporter.xml
file is provided by wayland-protocols.

This stops Weston from advertising wl_scaler, and advertises
wp_viewporter instead.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 4 ++--
configure.ac | 2 ++
src/compositor.c | 68 +++++++++++---------------------------------------------
src/compositor.h | 5 +++--
4 files changed, 20 insertions(+), 59 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9bed32c..9cb0dac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,8 +124,8 @@ nodist_weston_SOURCES = \
protocol/input-method-unstable-v1-server-protocol.h \
protocol/presentation-time-protocol.c \
protocol/presentation-time-server-protocol.h \
- protocol/scaler-protocol.c \
- protocol/scaler-server-protocol.h \
+ protocol/viewporter-protocol.c \
+ protocol/viewporter-server-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-server-protocol.h

diff --git a/configure.ac b/configure.ac
index 447cf6b..6f7b349 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,8 @@ m4_define([weston_micro_version], [90])
m4_define([weston_version],
[weston_major_version.weston_minor_version.weston_micro_version])

+# XXX: bump wayland-protocols dependency to include viewporter.xml
+
AC_PREREQ([2.64])
AC_INIT([weston],
[weston_version],
diff --git a/src/compositor.c b/src/compositor.c
index 5500197..551d4ed 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -54,7 +54,7 @@
#include "timeline.h"

#include "compositor.h"
-#include "scaler-server-protocol.h"
+#include "viewporter-server-protocol.h"
#include "presentation-time-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
@@ -923,7 +923,7 @@ weston_surface_to_buffer_float(struct weston_surface *surface,

/** Transform a rectangle from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param rect The rectangle to transform.
* \return The transformed rectangle.
@@ -963,7 +963,7 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,

/** Transform a region from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param surface_region[in] The region in surface coordinates.
* \param buffer_region[out] The region converted to buffer coordinates.
@@ -2826,7 +2826,8 @@ weston_surface_commit_state(struct weston_surface *surface,

/* wl_surface.set_buffer_transform */
/* wl_surface.set_buffer_scale */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
surface->buffer_viewport = state->buffer_viewport;

/* wl_surface.attach */
@@ -4365,48 +4366,6 @@ viewport_destroy(struct wl_client *client,
}

static void
-viewport_set(struct wl_client *client,
- struct wl_resource *resource,
- wl_fixed_t src_x,
- wl_fixed_t src_y,
- wl_fixed_t src_width,
- wl_fixed_t src_height,
- int32_t dst_width,
- int32_t dst_height)
-{
- struct weston_surface *surface =
- wl_resource_get_user_data(resource);
-
- assert(surface->viewport_resource != NULL);
-
- if (wl_fixed_to_double(src_width) < 0 ||
- wl_fixed_to_double(src_height) < 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "source dimensions must be non-negative (%fx%f)",
- wl_fixed_to_double(src_width),
- wl_fixed_to_double(src_height));
- return;
- }
-
- if (dst_width <= 0 || dst_height <= 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "destination dimensions must be positive (%dx%d)",
- dst_width, dst_height);
- return;
- }
-
- surface->pending.buffer_viewport.buffer.src_x = src_x;
- surface->pending.buffer_viewport.buffer.src_y = src_y;
- surface->pending.buffer_viewport.buffer.src_width = src_width;
- surface->pending.buffer_viewport.buffer.src_height = src_height;
- surface->pending.buffer_viewport.surface.width = dst_width;
- surface->pending.buffer_viewport.surface.height = dst_height;
- surface->pending.buffer_viewport.changed = 1;
-}
-
-static void
viewport_set_source(struct wl_client *client,
struct wl_resource *resource,
wl_fixed_t src_x,
@@ -4430,7 +4389,7 @@ viewport_set_source(struct wl_client *client,

if (src_width <= 0 || src_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"source size must be positive (%fx%f)",
wl_fixed_to_double(src_width),
wl_fixed_to_double(src_height));
@@ -4464,7 +4423,7 @@ viewport_set_destination(struct wl_client *client,

if (dst_width <= 0 || dst_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"destination size must be positive (%dx%d)",
dst_width, dst_height);
return;
@@ -4475,9 +4434,8 @@ viewport_set_destination(struct wl_client *client,
surface->pending.buffer_viewport.changed = 1;
}

-static const struct wl_viewport_interface viewport_interface = {
+static const struct wp_viewport_interface viewport_interface = {
viewport_destroy,
- viewport_set,
viewport_set_source,
viewport_set_destination
};
@@ -4502,12 +4460,12 @@ scaler_get_viewport(struct wl_client *client,

if (surface->viewport_resource) {
wl_resource_post_error(scaler,
- WL_SCALER_ERROR_VIEWPORT_EXISTS,
+ WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
}

- resource = wl_resource_create(client, &wl_viewport_interface,
+ resource = wl_resource_create(client, &wp_viewport_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4520,7 +4478,7 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}

-static const struct wl_scaler_interface scaler_interface = {
+static const struct wp_viewporter_interface scaler_interface = {
scaler_destroy,
scaler_get_viewport
};
@@ -4531,7 +4489,7 @@ bind_scaler(struct wl_client *client,
{
struct wl_resource *resource;

- resource = wl_resource_create(client, &wl_scaler_interface,
+ resource = wl_resource_create(client, &wp_viewporter_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4720,7 +4678,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
ec, bind_subcompositor))
goto fail;

- if (!wl_global_create(ec->wl_display, &wl_scaler_interface, 2,
+ if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
ec, bind_scaler))
goto fail;

diff --git a/src/compositor.h b/src/compositor.h
index 0ba00be..bc4000b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -973,7 +973,8 @@ struct weston_surface_state {

/* wl_surface.set_buffer_transform */
/* wl_surface.set_scaling_factor */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
struct weston_buffer_viewport buffer_viewport;
};

@@ -1021,7 +1022,7 @@ struct weston_surface {
int32_t height_from_buffer;
bool keep_buffer; /* for backends to prevent early release */

- /* wl_viewport resource for this surface */
+ /* wp_viewport resource for this surface */
struct wl_resource *viewport_resource;

/* All the pending state, that wl_surface.commit will apply. */
--
2.7.3
Pekka Paalanen
2016-04-15 14:53:18 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Since the interface is now called wp_viewport, rename functions from
"scaler" to "viewporter" as well.

scaler_surface_to_buffer() is renamed to viewport_surface_to_buffer()
because it is more about viewport than viewporter.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 551d4ed..b6a9aeb 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -877,8 +877,8 @@ weston_transformed_region(int width, int height,
}

static void
-scaler_surface_to_buffer(struct weston_surface *surface,
- float sx, float sy, float *bx, float *by)
+viewport_surface_to_buffer(struct weston_surface *surface,
+ float sx, float sy, float *bx, float *by)
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
double src_width, src_height;
@@ -912,8 +912,8 @@ weston_surface_to_buffer_float(struct weston_surface *surface,
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;

- /* first transform coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, sx, sy, bx, by);
+ /* first transform coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, sx, sy, bx, by);

weston_transformed_coord(surface->width_from_buffer,
surface->height_from_buffer,
@@ -946,12 +946,12 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
float xf, yf;

- /* first transform box coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
+ /* first transform box coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
rect.x1 = floorf(xf);
rect.y1 = floorf(yf);

- scaler_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
+ viewport_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
rect.x2 = ceilf(xf);
rect.y2 = ceilf(yf);

@@ -4441,25 +4441,25 @@ static const struct wp_viewport_interface viewport_interface = {
};

static void
-scaler_destroy(struct wl_client *client,
- struct wl_resource *resource)
+viewporter_destroy(struct wl_client *client,
+ struct wl_resource *resource)
{
wl_resource_destroy(resource);
}

static void
-scaler_get_viewport(struct wl_client *client,
- struct wl_resource *scaler,
- uint32_t id,
- struct wl_resource *surface_resource)
+viewporter_get_viewport(struct wl_client *client,
+ struct wl_resource *viewporter,
+ uint32_t id,
+ struct wl_resource *surface_resource)
{
- int version = wl_resource_get_version(scaler);
+ int version = wl_resource_get_version(viewporter);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct wl_resource *resource;

if (surface->viewport_resource) {
- wl_resource_post_error(scaler,
+ wl_resource_post_error(viewporter,
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
@@ -4478,14 +4478,14 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}

-static const struct wp_viewporter_interface scaler_interface = {
- scaler_destroy,
- scaler_get_viewport
+static const struct wp_viewporter_interface viewporter_interface = {
+ viewporter_destroy,
+ viewporter_get_viewport
};

static void
-bind_scaler(struct wl_client *client,
- void *data, uint32_t version, uint32_t id)
+bind_viewporter(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
{
struct wl_resource *resource;

@@ -4496,7 +4496,7 @@ bind_scaler(struct wl_client *client,
return;
}

- wl_resource_set_implementation(resource, &scaler_interface,
+ wl_resource_set_implementation(resource, &viewporter_interface,
NULL, NULL);
}

@@ -4679,7 +4679,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
goto fail;

if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
- ec, bind_scaler))
+ ec, bind_viewporter))
goto fail;

if (!wl_global_create(ec->wl_display, &wp_presentation_interface, 1,
--
2.7.3
Yong Bakos
2016-04-18 12:22:41 UTC
Permalink
Post by Pekka Paalanen
Since the interface is now called wp_viewport, rename functions from
"scaler" to "viewporter" as well.
scaler_surface_to_buffer() is renamed to viewport_surface_to_buffer()
because it is more about viewport than viewporter.
This renaming looks fine to me.
Reviewed-by: Yong Bakos <***@humanoriented.com>

yong
Post by Pekka Paalanen
---
src/compositor.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 551d4ed..b6a9aeb 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -877,8 +877,8 @@ weston_transformed_region(int width, int height,
}
static void
-scaler_surface_to_buffer(struct weston_surface *surface,
- float sx, float sy, float *bx, float *by)
+viewport_surface_to_buffer(struct weston_surface *surface,
+ float sx, float sy, float *bx, float *by)
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
double src_width, src_height;
@@ -912,8 +912,8 @@ weston_surface_to_buffer_float(struct weston_surface *surface,
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
- /* first transform coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, sx, sy, bx, by);
+ /* first transform coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, sx, sy, bx, by);
weston_transformed_coord(surface->width_from_buffer,
surface->height_from_buffer,
@@ -946,12 +946,12 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
float xf, yf;
- /* first transform box coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
+ /* first transform box coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
rect.x1 = floorf(xf);
rect.y1 = floorf(yf);
- scaler_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
+ viewport_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
rect.x2 = ceilf(xf);
rect.y2 = ceilf(yf);
@@ -4441,25 +4441,25 @@ static const struct wp_viewport_interface viewport_interface = {
};
static void
-scaler_destroy(struct wl_client *client,
- struct wl_resource *resource)
+viewporter_destroy(struct wl_client *client,
+ struct wl_resource *resource)
{
wl_resource_destroy(resource);
}
static void
-scaler_get_viewport(struct wl_client *client,
- struct wl_resource *scaler,
- uint32_t id,
- struct wl_resource *surface_resource)
+viewporter_get_viewport(struct wl_client *client,
+ struct wl_resource *viewporter,
+ uint32_t id,
+ struct wl_resource *surface_resource)
{
- int version = wl_resource_get_version(scaler);
+ int version = wl_resource_get_version(viewporter);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct wl_resource *resource;
if (surface->viewport_resource) {
- wl_resource_post_error(scaler,
+ wl_resource_post_error(viewporter,
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
@@ -4478,14 +4478,14 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}
-static const struct wp_viewporter_interface scaler_interface = {
- scaler_destroy,
- scaler_get_viewport
+static const struct wp_viewporter_interface viewporter_interface = {
+ viewporter_destroy,
+ viewporter_get_viewport
};
static void
-bind_scaler(struct wl_client *client,
- void *data, uint32_t version, uint32_t id)
+bind_viewporter(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
{
struct wl_resource *resource;
@@ -4496,7 +4496,7 @@ bind_scaler(struct wl_client *client,
return;
}
- wl_resource_set_implementation(resource, &scaler_interface,
+ wl_resource_set_implementation(resource, &viewporter_interface,
NULL, NULL);
}
@@ -4679,7 +4679,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
goto fail;
if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
- ec, bind_scaler))
+ ec, bind_viewporter))
goto fail;
if (!wl_global_create(ec->wl_display, &wp_presentation_interface, 1,
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-04-15 14:53:19 UTC
Permalink
From: Pekka Paalanen <***@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 <***@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 9cb0dac..b5814d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -566,6 +566,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 \
@@ -771,6 +773,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
Pekka Paalanen
2016-04-15 14:53:21 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

The stable version of the scaling and cropping extension is found in
wayland-protocols as viewporter.xml.

Remove scaler.xml as nothing uses it.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 5 --
protocol/scaler.xml | 208 ----------------------------------------------------
2 files changed, 213 deletions(-)
delete mode 100644 protocol/scaler.xml

diff --git a/Makefile.am b/Makefile.am
index 546614f..2e3fc9e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -564,8 +564,6 @@ libtoytoolkit_la_SOURCES = \
nodist_libtoytoolkit_la_SOURCES = \
protocol/text-cursor-position-protocol.c \
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 \
@@ -771,8 +769,6 @@ BUILT_SOURCES += \
protocol/input-method-unstable-v1-client-protocol.h \
protocol/weston-desktop-shell-client-protocol.h \
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 \
@@ -1361,7 +1357,6 @@ EXTRA_DIST += \
protocol/weston-screenshooter.xml \
protocol/text-cursor-position.xml \
protocol/weston-test.xml \
- protocol/scaler.xml \
protocol/ivi-application.xml \
protocol/ivi-hmi-controller.xml

diff --git a/protocol/scaler.xml b/protocol/scaler.xml
deleted file mode 100644
index 0e482a6..0000000
--- a/protocol/scaler.xml
+++ /dev/null
@@ -1,208 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
-
- <copyright>
- Copyright © 2013-2014 Collabora, Ltd.
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice (including the next
- paragraph) shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE 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>
--
2.7.3
Pekka Paalanen
2016-04-15 14:53:20 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Use wp_viewporter instead of wl_scaler and rename things as appropriate.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 4 ++--
clients/simple-damage.c | 32 ++++++++++++++++----------------
2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b5814d3..546614f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -483,8 +483,8 @@ weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la

weston_simple_damage_SOURCES = clients/simple-damage.c
nodist_weston_simple_damage_SOURCES = \
- 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/fullscreen-shell-unstable-v1-protocol.c \
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index 321b90f..82091d5 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -40,7 +40,7 @@
#include "shared/zalloc.h"
#include "xdg-shell-unstable-v5-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
-#include "scaler-client-protocol.h"
+#include "viewporter-client-protocol.h"

int print_debug = 0;

@@ -49,7 +49,7 @@ struct display {
struct wl_registry *registry;
int compositor_version;
struct wl_compositor *compositor;
- struct wl_scaler *scaler;
+ struct wp_viewporter *viewporter;
struct xdg_shell *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
@@ -72,7 +72,7 @@ struct window {
struct display *display;
int width, height, border;
struct wl_surface *surface;
- struct wl_viewport *viewport;
+ struct wp_viewport *viewport;
struct xdg_surface *xdg_surface;
struct wl_callback *callback;
struct buffer buffers[2];
@@ -258,8 +258,8 @@ create_window(struct display *display, int width, int height,
exit(1);
}

- if (display->scaler == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) {
- fprintf(stderr, "Compositor does not support wl_viewport");
+ if (display->viewporter == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) {
+ fprintf(stderr, "Compositor does not support wp_viewport");
exit(1);
}

@@ -290,8 +290,8 @@ create_window(struct display *display, int width, int height,
window->surface = wl_compositor_create_surface(display->compositor);

if (window->flags & WINDOW_FLAG_USE_VIEWPORT)
- window->viewport = wl_scaler_get_viewport(display->scaler,
- window->surface);
+ window->viewport = wp_viewporter_get_viewport(display->viewporter,
+ window->surface);

if (display->shell) {
window->xdg_surface =
@@ -337,7 +337,7 @@ destroy_window(struct window *window)
if (window->xdg_surface)
xdg_surface_destroy(window->xdg_surface);
if (window->viewport)
- wl_viewport_destroy(window->viewport);
+ wp_viewport_destroy(window->viewport);
wl_surface_destroy(window->surface);
free(window);
}
@@ -560,7 +560,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
off_x = ty;
break;
}
- wl_viewport_set_source(window->viewport,
+ wp_viewport_set_source(window->viewport,
wl_fixed_from_int(window->width / 3),
wl_fixed_from_int(window->height / 5),
wl_fixed_from_int(window->width / 2),
@@ -640,7 +640,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
window->transform);

if (window->viewport)
- wl_viewport_set_destination(window->viewport,
+ wp_viewport_set_destination(window->viewport,
window->width,
window->height);

@@ -709,9 +709,9 @@ registry_handle_global(void *data, struct wl_registry *registry,
wl_registry_bind(registry,
id, &wl_compositor_interface,
d->compositor_version);
- } else if (strcmp(interface, "wl_scaler") == 0 && version >= 2) {
- d->scaler = wl_registry_bind(registry,
- id, &wl_scaler_interface, 2);
+ } else if (strcmp(interface, "wp_viewporter") == 0) {
+ d->viewporter = wl_registry_bind(registry, id,
+ &wp_viewporter_interface, 1);
} else if (strcmp(interface, "xdg_shell") == 0) {
d->shell = wl_registry_bind(registry,
id, &xdg_shell_interface, 1);
@@ -784,8 +784,8 @@ destroy_display(struct display *display)
if (display->fshell)
zwp_fullscreen_shell_v1_release(display->fshell);

- if (display->scaler)
- wl_scaler_destroy(display->scaler);
+ if (display->viewporter)
+ wp_viewporter_destroy(display->viewporter);

if (display->compositor)
wl_compositor_destroy(display->compositor);
@@ -816,7 +816,7 @@ print_usage(int retval)
" --scale=SCALE\t\tScale factor for the surface\n"
" --transform=TRANSFORM\tTransform for the surface\n"
" --rotating-transform\tUse a different buffer_transform for each frame\n"
- " --use-viewport\tUse wl_viewport\n"
+ " --use-viewport\tUse wp_viewport\n"
" --use-damage-buffer\tUse damage_buffer to post damage\n"
);
--
2.7.3
Pekka Paalanen
2016-04-19 12:23:35 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Hi,

comments for the v1 have been adressed, and here is the new series, for
wayland-protocols only. Once this got enough R-b's, I will post the Weston part
before merging this upstream.

Changes in v2:

- No changes in patch 1.

- Patch "stable/viewporter: finish stabilization" has been split into
"stable/viewporter: remove wp_viewport.set request" and "stable/viewporter:
rename and build", and it adds a newline before the '</protocol>'.

- Patches 4 and 5 address review comments: rephrasing and adding more error
conditions replace silent unexpected behaviour.

The final XML file is also verbatim at the end of this email to allow easy
overall review.

Thanks,
pq

Pekka Paalanen (5):
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases

Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml



<?xml version="1.0" encoding="UTF-8"?>
<protocol name="viewporter">

<copyright>
Copyright © 2013-2014 Collabora, Ltd.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>

<interface name="wp_viewporter" version="1">
<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,
wp_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 wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>

<arg name="id" type="new_id" interface="wp_viewport"
summary="the new viewport interface id"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface"/>
</request>
</interface>

<interface name="wp_viewport" version="1">
<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 works with two concepts: the source rectangle (src_x,
src_y, src_width, src_height), and the destination size (dst_width,
dst_height). The contents of the source rectangle are scaled to the
destination size, and content outside the source rectangle is culled.
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 local 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, then src_width and src_height must be integers, and the
surface size becomes the source rectangle size. This results in cropping
without scaling. If src_width or src_height are not integers and
destination size is not set, the bad_size protocol error is raised when
the surface state is applied.

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 (wp_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 src_x or src_y are negative, the bad_value protocol error is raised.
Otherwise, if the source rectangle is partially or completely outside of
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
when the surface state is applied. A NULL wl_buffer does not raise the
out_of_buffer error.

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 wp_viewport is destroyed,
all wp_viewport requests except 'destroy' raise the protocol error
no_surface.

If the wp_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"/>
<entry name="bad_size" value="1"
summary="destination size is not integer"/>
<entry name="out_of_buffer" value="2"
summary="source rectangle extends outside of the content area"/>
<entry name="no_surface" value="3"
summary="the wl_surface was destroyed"/>
</enum>

<request name="set_source">
<description summary="set the source rectangle for cropping">
Set the source rectangle of the associated wl_surface. See
wp_viewport for the description, and relation to the wl_buffer
size.

If all of x, y, width and height are -1.0, the source rectangle is
unset instead. Any other set of values where width or height are zero
or negative, or x or y are negative, raise 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">
<description summary="set the surface size for scaling">
Set the destination size of the associated wl_surface. See
wp_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.
</description>

<arg name="width" type="int" summary="surface width"/>
<arg name="height" type="int" summary="surface height"/>
</request>
</interface>

</protocol>
Pekka Paalanen
2016-04-19 12:23:37 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Remove the old, redundant request. The new way is to call both
wp_viewport.set_source and wp_viewport.set_destination when you want to
set everything.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
stable/viewporter/viewporter.xml | 27 ---------------------------
1 file changed, 27 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 0e482a6..e4322bd 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -133,33 +133,6 @@
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
--
2.7.3
Pekka Paalanen
2016-04-19 12:23:36 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.

The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml

diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+Maintainers:
+Pekka Paalanen <***@collabora.co.uk>
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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>
--
2.7.3
Pekka Paalanen
2016-04-19 12:23:38 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Rename interfaces and the protocol to follow the policy.

Reset interface versions.

Replace "surface coordinates" with "surface local coordinates".

Hook up to build and install.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
---
Makefile.am | 1 +
stable/viewporter/viewporter.xml | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 033789f..71d2632 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ unstable_protocols = \

stable_protocols = \
stable/presentation-time/presentation-time.xml \
+ stable/viewporter/viewporter.xml \
$(NULL)

nobase_dist_pkgdata_DATA = \
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index e4322bd..7d299eb 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
+<protocol name="viewporter">

<copyright>
Copyright © 2013-2014 Collabora, Ltd.
@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>

- <interface name="wl_scaler" version="2">
+ <interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
@@ -38,7 +38,7 @@
<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.
+ wp_viewport objects included.
</description>
</request>

@@ -51,18 +51,18 @@
<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
+ a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>

- <arg name="id" type="new_id" interface="wl_viewport"
+ <arg name="id" type="new_id" interface="wp_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">
+ <interface name="wp_viewport" version="1">
<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
@@ -85,7 +85,7 @@
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.
+ at least 1x1 in surface local 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
@@ -97,7 +97,7 @@
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*)
+ 3. crop and scale (wp_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
@@ -113,10 +113,10 @@
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_surface associated with the wp_viewport is destroyed,
+ the wp_viewport object becomes inert.

- If the wl_viewport object is destroyed, the crop and scale
+ If the wp_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>
@@ -133,10 +133,10 @@
summary="negative or zero values in width or height"/>
</enum>

- <request name="set_source" since="2">
+ <request name="set_source">
<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
+ wp_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
@@ -154,10 +154,10 @@
<arg name="height" type="fixed" summary="source rectangle height"/>
</request>

- <request name="set_destination" since="2">
+ <request name="set_destination">
<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
+ wp_viewport for the description, and relation to the wl_buffer
size.

If width is -1 and height is -1, the destination size is unset
@@ -178,4 +178,5 @@
<arg name="height" type="int" summary="surface height"/>
</request>
</interface>
+
</protocol>
--
2.7.3
Pekka Paalanen
2016-04-19 12:23:39 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Cc: Yong Bakos <***@humanoriented.com>
Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
stable/viewporter/viewporter.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 7d299eb..ea8c0f2 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -68,11 +68,12 @@
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.
+ This interface works with two concepts: the source rectangle (src_x,
+ src_y, src_width, src_height), and the destination size (dst_width,
+ dst_height). The contents of the source rectangle are scaled to the
+ destination size, and content outside the source rectangle is culled.
+ 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
--
2.7.3
Pekka Paalanen
2016-04-19 12:23:40 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Rather than silenty doing things, make them explicit and error if
anything is not quite right. Suggested by Daniel Stone.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
stable/viewporter/viewporter.xml | 42 +++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index ea8c0f2..e9a4641 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -88,11 +88,13 @@
has no content and therefore no size. Otherwise, the size is always
at least 1x1 in surface local 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.
+ 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, then src_width and src_height must be integers, and the
+ surface size becomes the source rectangle size. This results in cropping
+ without scaling. If src_width or src_height are not integers and
+ destination size is not set, the bad_size protocol error is raised when
+ the surface state is applied.

The coordinate transformations from buffer pixel coordinates up to
the surface-local coordinates happen in the following order:
@@ -104,9 +106,11 @@
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.
+ If src_x or src_y are negative, the bad_value protocol error is raised.
+ Otherwise, if the source rectangle is partially or completely outside of
+ the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
+ when the surface state is applied. A NULL wl_buffer does not raise the
+ out_of_buffer error.

The x, y arguments of wl_surface.attach are applied as normal to
the surface. They indicate how many pixels to remove from the
@@ -115,7 +119,8 @@
and dst_height are.

If the wl_surface associated with the wp_viewport is destroyed,
- the wp_viewport object becomes inert.
+ all wp_viewport requests except 'destroy' raise the protocol error
+ no_surface.

If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be applied
@@ -131,7 +136,13 @@

<enum name="error">
<entry name="bad_value" value="0"
- summary="negative or zero values in width or height"/>
+ summary="negative or zero values in width or height"/>
+ <entry name="bad_size" value="1"
+ summary="destination size is not integer"/>
+ <entry name="out_of_buffer" value="2"
+ summary="source rectangle extends outside of the content area"/>
+ <entry name="no_surface" value="3"
+ summary="the wl_surface was destroyed"/>
</enum>

<request name="set_source">
@@ -140,9 +151,9 @@
wp_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
+ If all of x, y, width and height are -1.0, the source rectangle is
+ unset instead. Any other set of values where width or height are zero
+ or negative, or x or y are negative, raise the bad_value protocol
error.

The crop and scale state is double-buffered state, and will be
@@ -168,11 +179,6 @@

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"/>
--
2.7.3
Yong Bakos
2016-04-19 14:46:19 UTC
Permalink
Post by Pekka Paalanen
Hi,
comments for the v1 have been adressed, and here is the new series, for
wayland-protocols only. Once this got enough R-b's, I will post the Weston part
before merging this upstream.
- No changes in patch 1.
- Patch "stable/viewporter: finish stabilization" has been split into
rename and build", and it adds a newline before the '</protocol>'.
- Patches 4 and 5 address review comments: rephrasing and adding more error
conditions replace silent unexpected behaviour.
The final XML file is also verbatim at the end of this email to allow easy
overall review.
Thanks,
pq
Hi Pekka,
v2 patches 1 - 4 look good and are
Reviewed-by: Yong Bakos <***@humanoriented.com>

I defer to Daniel/others regarding 5/5.

yong
Post by Pekka Paalanen
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="viewporter">
<copyright>
Copyright © 2013-2014 Collabora, Ltd.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="wp_viewporter" version="1">
<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,
wp_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 wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>
<arg name="id" type="new_id" interface="wp_viewport"
summary="the new viewport interface id"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface"/>
</request>
</interface>
<interface name="wp_viewport" version="1">
<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 works with two concepts: the source rectangle (src_x,
src_y, src_width, src_height), and the destination size (dst_width,
dst_height). The contents of the source rectangle are scaled to the
destination size, and content outside the source rectangle is culled.
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 local 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, then src_width and src_height must be integers, and the
surface size becomes the source rectangle size. This results in cropping
without scaling. If src_width or src_height are not integers and
destination size is not set, the bad_size protocol error is raised when
the surface state is applied.
The coordinate transformations from buffer pixel coordinates up to
1. buffer_transform (wl_surface.set_buffer_transform)
2. buffer_scale (wl_surface.set_buffer_scale)
3. crop and scale (wp_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 src_x or src_y are negative, the bad_value protocol error is raised.
Otherwise, if the source rectangle is partially or completely outside of
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
when the surface state is applied. A NULL wl_buffer does not raise the
out_of_buffer error.
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 wp_viewport is destroyed,
all wp_viewport requests except 'destroy' raise the protocol error
no_surface.
If the wp_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"/>
<entry name="bad_size" value="1"
summary="destination size is not integer"/>
<entry name="out_of_buffer" value="2"
summary="source rectangle extends outside of the content area"/>
<entry name="no_surface" value="3"
summary="the wl_surface was destroyed"/>
</enum>
<request name="set_source">
<description summary="set the source rectangle for cropping">
Set the source rectangle of the associated wl_surface. See
wp_viewport for the description, and relation to the wl_buffer
size.
If all of x, y, width and height are -1.0, the source rectangle is
unset instead. Any other set of values where width or height are zero
or negative, or x or y are negative, raise 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">
<description summary="set the surface size for scaling">
Set the destination size of the associated wl_surface. See
wp_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.
</description>
<arg name="width" type="int" summary="surface width"/>
<arg name="height" type="int" summary="surface height"/>
</request>
</interface>
</protocol>
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Daniel Stone
2016-04-19 14:55:01 UTC
Permalink
Hi,
Post by Yong Bakos
Post by Pekka Paalanen
The final XML file is also verbatim at the end of this email to allow easy
overall review.
Thanks a lot for this, that helps hugely.
Post by Yong Bakos
v2 patches 1 - 4 look good and are
I defer to Daniel/others regarding 5/5.
Post by Pekka Paalanen
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="viewporter">
<copyright>
Copyright © 2013-2014 Collabora, Ltd.
-2016
Post by Yong Bakos
Post by Pekka Paalanen
<interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
'interface extension'? Is that meant to be instance extension, or is
it meaning an interface which extends the wl_surface? No problem
either way.
Post by Yong Bakos
Post by Pekka Paalanen
<interface name="wp_viewport" version="1">
<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 works with two concepts: the source rectangle (src_x,
src_y, src_width, src_height), and the destination size (dst_width,
dst_height). The contents of the source rectangle are scaled to the
destination size, and content outside the source rectangle is culled.
s/culled/ignored/ as culled implies a destructive operation. I know
there's no way anyone particularly familiar with how Wayland works
could read it to be destructive to the wl_buffer content, but might as
well make it as accessible as possible. :)
Post by Yong Bakos
Post by Pekka Paalanen
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.
In a similar spirit, s/pixels to remove from the surface size/pixels
to translate the surface position by/.

Cheers,
Daniel
Pekka Paalanen
2016-04-20 10:38:32 UTC
Permalink
On Tue, 19 Apr 2016 15:55:01 +0100
Post by Daniel Stone
Hi,
Post by Yong Bakos
Post by Pekka Paalanen
The final XML file is also verbatim at the end of this email to allow easy
overall review.
Thanks a lot for this, that helps hugely.
Post by Yong Bakos
v2 patches 1 - 4 look good and are
I defer to Daniel/others regarding 5/5.
Hi,

very cool!
Post by Daniel Stone
Post by Yong Bakos
Post by Pekka Paalanen
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="viewporter">
<copyright>
Copyright © 2013-2014 Collabora, Ltd.
-2016
Yeah, now there are enough changes to update that.
Post by Daniel Stone
Post by Yong Bakos
Post by Pekka Paalanen
<interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
'interface extension'? Is that meant to be instance extension, or is
it meaning an interface which extends the wl_surface? No problem
either way.
Wow, that's an awkward sentence. The same wording is used for
wp_viewporter.get_viewport request.

The interface extension refers to a protocol object whose interface is
extending the interface of a particular wl_surface object.

It's easier to explain things using Weston's implementation as a
reference. A protocol object wl_surface is backed by a weston_surface
with one-to-one relationship. A protocol object wp_viewport is also
backed by the same weston_surface that backs the wl_surface it was
created for. A wp_viewport without the wl_surface (and so without
the weston_surface) is "dead" - it has no use.

This is a case of extending an existing interface wl_surface with
another interface wp_viewport. This happens on an object by object
basis.

Maybe Yong can come up with a nicer wording as a follow-up patch?
Post by Daniel Stone
Post by Yong Bakos
Post by Pekka Paalanen
<interface name="wp_viewport" version="1">
<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 works with two concepts: the source rectangle (src_x,
src_y, src_width, src_height), and the destination size (dst_width,
dst_height). The contents of the source rectangle are scaled to the
destination size, and content outside the source rectangle is culled.
s/culled/ignored/ as culled implies a destructive operation. I know
there's no way anyone particularly familiar with how Wayland works
could read it to be destructive to the wl_buffer content, but might as
well make it as accessible as possible. :)
Yup, that's better.
Post by Daniel Stone
Post by Yong Bakos
Post by Pekka Paalanen
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.
In a similar spirit, s/pixels to remove from the surface size/pixels
to translate the surface position by/.
That was a very deliberate wording to steer away from the notion that
you can move your window by abusing the x,y of wl_surface.attach.
"Removing from size" is probably a strange phrase indeed. I'll leave
that as is for now.

The important thing in this paragraph is explaining the coordinate
system used by the x,y which is not affected by the viewport. In that
sense, we could even remove the whole paragraph. Should we?

I have fixed the year and "culled" in my branch. I will send out the
final series once I have the Weston patches ready.
https://git.collabora.com/cgit/user/pq/wayland-protocols.git/log/?h=viewporter


Thanks,
pq
Pekka Paalanen
2016-04-26 12:50:52 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Hi,

here is the v3 of the stabilization series, which I hope to the final to be
merged.

The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.

The weston patches are v3 too, though v2 was never posted. The changes to v1
are:
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1

Note, that there are now tests for the wp_viewporter API. \o/


Wayland-protocols:

Pekka Paalanen (5):
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases

Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml


Weston:

Pekka Paalanen (12):
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests

Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c


Thanks,
pq
Pekka Paalanen
2016-04-26 12:50:53 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.

The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
Reviewed-by: Daniel Stone <***@collabora.com>
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml

diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+Maintainers:
+Pekka Paalanen <***@collabora.co.uk>
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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>
--
2.7.3
Derek Foreman
2016-04-28 18:26:33 UTC
Permalink
Post by Pekka Paalanen
This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.
The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
diff --git a/stable/viewporter/README b/stable/viewporter/README
new file mode 100644
index 0000000..e09057b
--- /dev/null
+++ b/stable/viewporter/README
@@ -0,0 +1,7 @@
+Viewporter: cropping and scaling extension for surface contents
+
+Previously known as wl_scaler.
+
+
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
new file mode 100644
index 0000000..0e482a6
--- /dev/null
+++ b/stable/viewporter/viewporter.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE 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
+ 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
I'm a little uncomfortable with "applied as normal to". In geometry,
when something is normal to a surface it's perpendicular to it, but I
think here we're trying to say x and y are in surface co-ordinates?
Post by Pekka Paalanen
+ the surface. They indicate how many pixels to remove from the
+ surface size from the left and the top. In other words, they are
I prefer this "in other words" explanation. :)

Otherwise,
Post by Pekka Paalanen
+ 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>
Pekka Paalanen
2016-04-29 11:42:18 UTC
Permalink
On Thu, 28 Apr 2016 13:26:33 -0500
Post by Derek Foreman
Post by Pekka Paalanen
This XML file has been copied verbatim from Weston 1.10.0 release,
protocol/scaler.xml.
The interfaces still need renaming according to wayland-protocols
policy. Also a redundant request needs to be removed. These will be done
in a follow-up patch to clearly show the changes.
---
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 208 +++++++++++++++++++++++++++++++++++++++
2 files changed, 215 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
+ <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
+ 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
I'm a little uncomfortable with "applied as normal to". In geometry,
when something is normal to a surface it's perpendicular to it, but I
think here we're trying to say x and y are in surface co-ordinates?
Yeah, but there might be some confusion whether that is measured before
or after applying the new wl_buffer and/or viewport state. The doc in
wl_surface.attach tries to explain it, and I'd rather not duplicate it
here.

A slightly poor choice of words, yes. Can be fixed later perfectly
well. Anyway, this patch really means to be a verbatim copy from
Weston, so needs to be fixed in a follow-up. That's why I'll take your
R-b as is. :-)
Post by Derek Foreman
Post by Pekka Paalanen
+ the surface. They indicate how many pixels to remove from the
+ surface size from the left and the top. In other words, they are
I prefer this "in other words" explanation. :)
Otherwise,
Thanks,
pq
Post by Derek Foreman
Post by Pekka Paalanen
+ 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>
Pekka Paalanen
2016-04-26 12:50:54 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Remove the old, redundant request. The new way is to call both
wp_viewport.set_source and wp_viewport.set_destination when you want to
set everything.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
Reviewed-by: Daniel Stone <***@collabora.com>
---
stable/viewporter/viewporter.xml | 27 ---------------------------
1 file changed, 27 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 0e482a6..e4322bd 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -133,33 +133,6 @@
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
--
2.7.3
Derek Foreman
2016-04-28 18:28:32 UTC
Permalink
Post by Pekka Paalanen
Remove the old, redundant request. The new way is to call both
wp_viewport.set_source and wp_viewport.set_destination when you want to
set everything.
Makes sense. It's all made atomic by the surface commit anyway...
Post by Pekka Paalanen
---
stable/viewporter/viewporter.xml | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 0e482a6..e4322bd 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -133,33 +133,6 @@
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
Pekka Paalanen
2016-04-26 12:51:00 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Migrate from wl_scaler to wp_viewporter extension. The viewporter.xml
file is provided by wayland-protocols.

This stops Weston from advertising wl_scaler, and advertises
wp_viewporter instead.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 4 ++--
configure.ac | 2 ++
src/compositor.c | 68 +++++++++++---------------------------------------------
src/compositor.h | 5 +++--
4 files changed, 20 insertions(+), 59 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2d72730..9056045 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -126,8 +126,8 @@ nodist_weston_SOURCES = \
protocol/input-method-unstable-v1-server-protocol.h \
protocol/presentation-time-protocol.c \
protocol/presentation-time-server-protocol.h \
- protocol/scaler-protocol.c \
- protocol/scaler-server-protocol.h \
+ protocol/viewporter-protocol.c \
+ protocol/viewporter-server-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-server-protocol.h

diff --git a/configure.ac b/configure.ac
index 4199616..70a97cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,8 @@ m4_define([weston_micro_version], [90])
m4_define([weston_version],
[weston_major_version.weston_minor_version.weston_micro_version])

+# XXX: bump wayland-protocols dependency to include viewporter.xml
+
AC_PREREQ([2.64])
AC_INIT([weston],
[weston_version],
diff --git a/src/compositor.c b/src/compositor.c
index 75c8c78..89e6246 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -54,7 +54,7 @@
#include "timeline.h"

#include "compositor.h"
-#include "scaler-server-protocol.h"
+#include "viewporter-server-protocol.h"
#include "presentation-time-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
@@ -923,7 +923,7 @@ weston_surface_to_buffer_float(struct weston_surface *surface,

/** Transform a rectangle from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param rect The rectangle to transform.
* \return The transformed rectangle.
@@ -963,7 +963,7 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,

/** Transform a region from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param surface_region[in] The region in surface coordinates.
* \param buffer_region[out] The region converted to buffer coordinates.
@@ -2843,7 +2843,8 @@ weston_surface_commit_state(struct weston_surface *surface,

/* wl_surface.set_buffer_transform */
/* wl_surface.set_buffer_scale */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
surface->buffer_viewport = state->buffer_viewport;

/* wl_surface.attach */
@@ -4365,48 +4366,6 @@ viewport_destroy(struct wl_client *client,
}

static void
-viewport_set(struct wl_client *client,
- struct wl_resource *resource,
- wl_fixed_t src_x,
- wl_fixed_t src_y,
- wl_fixed_t src_width,
- wl_fixed_t src_height,
- int32_t dst_width,
- int32_t dst_height)
-{
- struct weston_surface *surface =
- wl_resource_get_user_data(resource);
-
- assert(surface->viewport_resource != NULL);
-
- if (wl_fixed_to_double(src_width) < 0 ||
- wl_fixed_to_double(src_height) < 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "source dimensions must be non-negative (%fx%f)",
- wl_fixed_to_double(src_width),
- wl_fixed_to_double(src_height));
- return;
- }
-
- if (dst_width <= 0 || dst_height <= 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "destination dimensions must be positive (%dx%d)",
- dst_width, dst_height);
- return;
- }
-
- surface->pending.buffer_viewport.buffer.src_x = src_x;
- surface->pending.buffer_viewport.buffer.src_y = src_y;
- surface->pending.buffer_viewport.buffer.src_width = src_width;
- surface->pending.buffer_viewport.buffer.src_height = src_height;
- surface->pending.buffer_viewport.surface.width = dst_width;
- surface->pending.buffer_viewport.surface.height = dst_height;
- surface->pending.buffer_viewport.changed = 1;
-}
-
-static void
viewport_set_source(struct wl_client *client,
struct wl_resource *resource,
wl_fixed_t src_x,
@@ -4430,7 +4389,7 @@ viewport_set_source(struct wl_client *client,

if (src_width <= 0 || src_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"source size must be positive (%fx%f)",
wl_fixed_to_double(src_width),
wl_fixed_to_double(src_height));
@@ -4464,7 +4423,7 @@ viewport_set_destination(struct wl_client *client,

if (dst_width <= 0 || dst_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"destination size must be positive (%dx%d)",
dst_width, dst_height);
return;
@@ -4475,9 +4434,8 @@ viewport_set_destination(struct wl_client *client,
surface->pending.buffer_viewport.changed = 1;
}

-static const struct wl_viewport_interface viewport_interface = {
+static const struct wp_viewport_interface viewport_interface = {
viewport_destroy,
- viewport_set,
viewport_set_source,
viewport_set_destination
};
@@ -4502,12 +4460,12 @@ scaler_get_viewport(struct wl_client *client,

if (surface->viewport_resource) {
wl_resource_post_error(scaler,
- WL_SCALER_ERROR_VIEWPORT_EXISTS,
+ WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
}

- resource = wl_resource_create(client, &wl_viewport_interface,
+ resource = wl_resource_create(client, &wp_viewport_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4520,7 +4478,7 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}

-static const struct wl_scaler_interface scaler_interface = {
+static const struct wp_viewporter_interface scaler_interface = {
scaler_destroy,
scaler_get_viewport
};
@@ -4531,7 +4489,7 @@ bind_scaler(struct wl_client *client,
{
struct wl_resource *resource;

- resource = wl_resource_create(client, &wl_scaler_interface,
+ resource = wl_resource_create(client, &wp_viewporter_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4720,7 +4678,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
ec, bind_subcompositor))
goto fail;

- if (!wl_global_create(ec->wl_display, &wl_scaler_interface, 2,
+ if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
ec, bind_scaler))
goto fail;

diff --git a/src/compositor.h b/src/compositor.h
index cb9df00..33e98f9 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -991,7 +991,8 @@ struct weston_surface_state {

/* wl_surface.set_buffer_transform */
/* wl_surface.set_scaling_factor */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
struct weston_buffer_viewport buffer_viewport;
};

@@ -1039,7 +1040,7 @@ struct weston_surface {
int32_t height_from_buffer;
bool keep_buffer; /* for backends to prevent early release */

- /* wl_viewport resource for this surface */
+ /* wp_viewport resource for this surface */
struct wl_resource *viewport_resource;

/* All the pending state, that wl_surface.commit will apply. */
--
2.7.3
Pekka Paalanen
2016-04-26 12:51:02 UTC
Permalink
From: Pekka Paalanen <***@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 <***@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
Pekka Paalanen
2016-04-26 12:51:01 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Since the interface is now called wp_viewport, rename functions from
"scaler" to "viewporter" as well.

scaler_surface_to_buffer() is renamed to viewport_surface_to_buffer()
because it is more about viewport than viewporter.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
---
src/compositor.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 89e6246..d462409 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -877,8 +877,8 @@ weston_transformed_region(int width, int height,
}

static void
-scaler_surface_to_buffer(struct weston_surface *surface,
- float sx, float sy, float *bx, float *by)
+viewport_surface_to_buffer(struct weston_surface *surface,
+ float sx, float sy, float *bx, float *by)
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
double src_width, src_height;
@@ -912,8 +912,8 @@ weston_surface_to_buffer_float(struct weston_surface *surface,
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;

- /* first transform coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, sx, sy, bx, by);
+ /* first transform coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, sx, sy, bx, by);

weston_transformed_coord(surface->width_from_buffer,
surface->height_from_buffer,
@@ -946,12 +946,12 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
float xf, yf;

- /* first transform box coordinates if the scaler is set */
- scaler_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
+ /* first transform box coordinates if the viewport is set */
+ viewport_surface_to_buffer(surface, rect.x1, rect.y1, &xf, &yf);
rect.x1 = floorf(xf);
rect.y1 = floorf(yf);

- scaler_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
+ viewport_surface_to_buffer(surface, rect.x2, rect.y2, &xf, &yf);
rect.x2 = ceilf(xf);
rect.y2 = ceilf(yf);

@@ -4441,25 +4441,25 @@ static const struct wp_viewport_interface viewport_interface = {
};

static void
-scaler_destroy(struct wl_client *client,
- struct wl_resource *resource)
+viewporter_destroy(struct wl_client *client,
+ struct wl_resource *resource)
{
wl_resource_destroy(resource);
}

static void
-scaler_get_viewport(struct wl_client *client,
- struct wl_resource *scaler,
- uint32_t id,
- struct wl_resource *surface_resource)
+viewporter_get_viewport(struct wl_client *client,
+ struct wl_resource *viewporter,
+ uint32_t id,
+ struct wl_resource *surface_resource)
{
- int version = wl_resource_get_version(scaler);
+ int version = wl_resource_get_version(viewporter);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct wl_resource *resource;

if (surface->viewport_resource) {
- wl_resource_post_error(scaler,
+ wl_resource_post_error(viewporter,
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
@@ -4478,14 +4478,14 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}

-static const struct wp_viewporter_interface scaler_interface = {
- scaler_destroy,
- scaler_get_viewport
+static const struct wp_viewporter_interface viewporter_interface = {
+ viewporter_destroy,
+ viewporter_get_viewport
};

static void
-bind_scaler(struct wl_client *client,
- void *data, uint32_t version, uint32_t id)
+bind_viewporter(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
{
struct wl_resource *resource;

@@ -4496,7 +4496,7 @@ bind_scaler(struct wl_client *client,
return;
}

- wl_resource_set_implementation(resource, &scaler_interface,
+ wl_resource_set_implementation(resource, &viewporter_interface,
NULL, NULL);
}

@@ -4679,7 +4679,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
goto fail;

if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
- ec, bind_scaler))
+ ec, bind_viewporter))
goto fail;

if (!wl_global_create(ec->wl_display, &wp_presentation_interface, 1,
--
2.7.3
Pekka Paalanen
2016-04-26 12:50:56 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Cc: Yong Bakos <***@humanoriented.com>
Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
Reviewed-by: Daniel Stone <***@collabora.com>
[Pekka: s/culled/ignored/]
---
stable/viewporter/viewporter.xml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index 7d299eb..ef9b35c 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -68,11 +68,12 @@
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.
+ This interface works with two concepts: the source rectangle (src_x,
+ src_y, src_width, src_height), and the destination size (dst_width,
+ dst_height). The contents of the source rectangle are scaled to the
+ destination size, and content outside the source rectangle is ignored.
+ 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
--
2.7.3
Pekka Paalanen
2016-04-26 12:50:57 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Rather than silenty doing things, make them explicit and error if
anything is not quite right. Suggested by Daniel Stone.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Daniel Stone <***@collabora.com>
[Pekka: updated copyright years]
---
stable/viewporter/viewporter.xml | 44 +++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index ef9b35c..5d006c0 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -2,7 +2,7 @@
<protocol name="viewporter">

<copyright>
- Copyright © 2013-2014 Collabora, Ltd.
+ Copyright © 2013-2016 Collabora, Ltd.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -88,11 +88,13 @@
has no content and therefore no size. Otherwise, the size is always
at least 1x1 in surface local 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.
+ 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, then src_width and src_height must be integers, and the
+ surface size becomes the source rectangle size. This results in cropping
+ without scaling. If src_width or src_height are not integers and
+ destination size is not set, the bad_size protocol error is raised when
+ the surface state is applied.

The coordinate transformations from buffer pixel coordinates up to
the surface-local coordinates happen in the following order:
@@ -104,9 +106,11 @@
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.
+ If src_x or src_y are negative, the bad_value protocol error is raised.
+ Otherwise, if the source rectangle is partially or completely outside of
+ the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
+ when the surface state is applied. A NULL wl_buffer does not raise the
+ out_of_buffer error.

The x, y arguments of wl_surface.attach are applied as normal to
the surface. They indicate how many pixels to remove from the
@@ -115,7 +119,8 @@
and dst_height are.

If the wl_surface associated with the wp_viewport is destroyed,
- the wp_viewport object becomes inert.
+ all wp_viewport requests except 'destroy' raise the protocol error
+ no_surface.

If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be applied
@@ -131,7 +136,13 @@

<enum name="error">
<entry name="bad_value" value="0"
- summary="negative or zero values in width or height"/>
+ summary="negative or zero values in width or height"/>
+ <entry name="bad_size" value="1"
+ summary="destination size is not integer"/>
+ <entry name="out_of_buffer" value="2"
+ summary="source rectangle extends outside of the content area"/>
+ <entry name="no_surface" value="3"
+ summary="the wl_surface was destroyed"/>
</enum>

<request name="set_source">
@@ -140,9 +151,9 @@
wp_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
+ If all of x, y, width and height are -1.0, the source rectangle is
+ unset instead. Any other set of values where width or height are zero
+ or negative, or x or y are negative, raise the bad_value protocol
error.

The crop and scale state is double-buffered state, and will be
@@ -168,11 +179,6 @@

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"/>
--
2.7.3
Derek Foreman
2016-04-28 18:40:47 UTC
Permalink
Post by Pekka Paalanen
Rather than silenty doing things, make them explicit and error if
anything is not quite right. Suggested by Daniel Stone.
[Pekka: updated copyright years]
---
stable/viewporter/viewporter.xml | 44 +++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index ef9b35c..5d006c0 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -2,7 +2,7 @@
<protocol name="viewporter">
<copyright>
- Copyright © 2013-2014 Collabora, Ltd.
+ Copyright © 2013-2016 Collabora, Ltd.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -88,11 +88,13 @@
has no content and therefore no size. Otherwise, the size is always
at least 1x1 in surface local 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.
+ 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, then src_width and src_height must be integers, and the
+ surface size becomes the source rectangle size. This results in cropping
+ without scaling. If src_width or src_height are not integers and
+ destination size is not set, the bad_size protocol error is raised when
+ the surface state is applied.
I'm actually a little uncomfortable with taking protocol that's been in
weston forever, making some subtle changes, and marking it immediately
as stable.

This seems pretty benign to me though. :)
Post by Pekka Paalanen
The coordinate transformations from buffer pixel coordinates up to
@@ -104,9 +106,11 @@
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.
+ If src_x or src_y are negative, the bad_value protocol error is raised.
+ Otherwise, if the source rectangle is partially or completely outside of
+ the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
+ when the surface state is applied. A NULL wl_buffer does not raise the
+ out_of_buffer error.
Same concern, but I much prefer this to the original implementation. :)

Reviewed-by: Derek Foreman <***@osg.samsung.com>
(same for anything else in this series of 5 I didn't directly comment on)
Post by Pekka Paalanen
The x, y arguments of wl_surface.attach are applied as normal to
the surface. They indicate how many pixels to remove from the
@@ -115,7 +119,8 @@
and dst_height are.
If the wl_surface associated with the wp_viewport is destroyed,
- the wp_viewport object becomes inert.
+ all wp_viewport requests except 'destroy' raise the protocol error
+ no_surface.
If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be applied
@@ -131,7 +136,13 @@
<enum name="error">
<entry name="bad_value" value="0"
- summary="negative or zero values in width or height"/>
+ summary="negative or zero values in width or height"/>
+ <entry name="bad_size" value="1"
+ summary="destination size is not integer"/>
+ <entry name="out_of_buffer" value="2"
+ summary="source rectangle extends outside of the content area"/>
+ <entry name="no_surface" value="3"
+ summary="the wl_surface was destroyed"/>
</enum>
<request name="set_source">
@@ -140,9 +151,9 @@
wp_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
+ If all of x, y, width and height are -1.0, the source rectangle is
+ unset instead. Any other set of values where width or height are zero
+ or negative, or x or y are negative, raise the bad_value protocol
error.
The crop and scale state is double-buffered state, and will be
@@ -168,11 +179,6 @@
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"/>
Pekka Paalanen
2016-04-29 12:41:12 UTC
Permalink
On Thu, 28 Apr 2016 13:40:47 -0500
Post by Derek Foreman
Post by Pekka Paalanen
Rather than silenty doing things, make them explicit and error if
anything is not quite right. Suggested by Daniel Stone.
[Pekka: updated copyright years]
---
stable/viewporter/viewporter.xml | 44 +++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index ef9b35c..5d006c0 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -2,7 +2,7 @@
<protocol name="viewporter">
<copyright>
- Copyright © 2013-2014 Collabora, Ltd.
+ Copyright © 2013-2016 Collabora, Ltd.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -88,11 +88,13 @@
has no content and therefore no size. Otherwise, the size is always
at least 1x1 in surface local 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.
+ 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, then src_width and src_height must be integers, and the
+ surface size becomes the source rectangle size. This results in cropping
+ without scaling. If src_width or src_height are not integers and
+ destination size is not set, the bad_size protocol error is raised when
+ the surface state is applied.
I'm actually a little uncomfortable with taking protocol that's been in
weston forever, making some subtle changes, and marking it immediately
as stable.
This seems pretty benign to me though. :)
Yes, I've been wondering about that. If we push it as unstable instead,
we will have another break-the-world moment when declaring it stable,
even if nothing changed.

Should I make it unstable? Jonas?
Post by Derek Foreman
Post by Pekka Paalanen
The coordinate transformations from buffer pixel coordinates up to
@@ -104,9 +106,11 @@
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.
+ If src_x or src_y are negative, the bad_value protocol error is raised.
+ Otherwise, if the source rectangle is partially or completely outside of
+ the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
+ when the surface state is applied. A NULL wl_buffer does not raise the
+ out_of_buffer error.
Same concern, but I much prefer this to the original implementation. :)
(same for anything else in this series of 5 I didn't directly comment on)
Cool, so that is essentially a R-b Derek for all wayland-protocols
patches. :-)


Thanks,
pq
Post by Derek Foreman
Post by Pekka Paalanen
The x, y arguments of wl_surface.attach are applied as normal to
the surface. They indicate how many pixels to remove from the
@@ -115,7 +119,8 @@
and dst_height are.
If the wl_surface associated with the wp_viewport is destroyed,
- the wp_viewport object becomes inert.
+ all wp_viewport requests except 'destroy' raise the protocol error
+ no_surface.
If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be applied
@@ -131,7 +136,13 @@
<enum name="error">
<entry name="bad_value" value="0"
- summary="negative or zero values in width or height"/>
+ summary="negative or zero values in width or height"/>
+ <entry name="bad_size" value="1"
+ summary="destination size is not integer"/>
+ <entry name="out_of_buffer" value="2"
+ summary="source rectangle extends outside of the content area"/>
+ <entry name="no_surface" value="3"
+ summary="the wl_surface was destroyed"/>
</enum>
<request name="set_source">
@@ -140,9 +151,9 @@
wp_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
+ If all of x, y, width and height are -1.0, the source rectangle is
+ unset instead. Any other set of values where width or height are zero
+ or negative, or x or y are negative, raise the bad_value protocol
error.
The crop and scale state is double-buffered state, and will be
@@ -168,11 +179,6 @@
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"/>
Derek Foreman
2016-04-29 13:58:36 UTC
Permalink
On Thu, 28 Apr 2016 13:40:47 -0500 Derek Foreman
Post by Derek Foreman
Post by Pekka Paalanen
Rather than silenty doing things, make them explicit and error
if anything is not quite right. Suggested by Daniel Stone.
updated copyright years] --- stable/viewporter/viewporter.xml |
44 +++++++++++++++++++++++----------------- 1 file changed, 25
insertions(+), 19 deletions(-)
diff --git a/stable/viewporter/viewporter.xml
b/stable/viewporter/viewporter.xml index ef9b35c..5d006c0
100644 --- a/stable/viewporter/viewporter.xml +++
name="viewporter">
<copyright> - Copyright © 2013-2014 Collabora, Ltd. +
Copyright © 2013-2016 Collabora, Ltd.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
therefore no size. Otherwise, the size is always at least 1x1
in surface local 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. + 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, then src_width and src_height must be integers, and the +
surface size becomes the source rectangle size. This results in
cropping + without scaling. If src_width or src_height are
not integers and + destination size is not set, the
bad_size protocol error is raised when + the surface state
is applied.
I'm actually a little uncomfortable with taking protocol that's
been in weston forever, making some subtle changes, and marking
it immediately as stable.
This seems pretty benign to me though. :)
Yes, I've been wondering about that. If we push it as unstable
instead, we will have another break-the-world moment when declaring
it stable, even if nothing changed.
For myself, I want to see this in Enlightenment sooner or later, so I
have an ulterior motive to see it land as stable (and I prefer it with
your changes) - not that we can't deal with a break, it's just easier
if we don't have to.
Should I make it unstable? Jonas?
Having Jonas cast the deciding vote sounds like a good idea to me. :D
Post by Derek Foreman
Post by Pekka Paalanen
The coordinate transformations from buffer pixel coordinates up
to the surface-local coordinates happen in the following
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. + If src_x or src_y are negative,
the bad_value protocol error is raised. + Otherwise, if
the source rectangle is partially or completely outside of +
the non-NULL wl_buffer, then the out_of_buffer protocol error
is raised + when the surface state is applied. A NULL
wl_buffer does not raise the + out_of_buffer error.
Same concern, but I much prefer this to the original
implementation. :)
anything else in this series of 5 I didn't directly comment on)
Cool, so that is essentially a R-b Derek for all wayland-protocols
patches. :-)
Exactly that, yes.
Thanks,
Derek
Thanks, pq
Post by Derek Foreman
Post by Pekka Paalanen
The x, y arguments of wl_surface.attach are applied as normal
to the surface. They indicate how many pixels to remove from
If the wl_surface associated with the wp_viewport is
destroyed, - the wp_viewport object becomes inert. +
all wp_viewport requests except 'destroy' raise the protocol
error + no_surface.
If the wp_viewport object is destroyed, the crop and scale
state is removed from the wl_surface. The change will be
<enum name="error"> <entry name="bad_value" value="0" -
summary="negative or zero values in width or height"/> +
summary="negative or zero values in width or height"/> +
<entry name="bad_size" value="1" + summary="destination
size is not integer"/> + <entry name="out_of_buffer"
value="2" + summary="source rectangle extends outside of
the content area"/> + <entry name="no_surface" value="3" +
summary="the wl_surface was destroyed"/> </enum>
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 + If all of x, y, width and height are -1.0, the
source rectangle is + unset instead. Any other set of values
where width or height are zero + or negative, or x or y are
negative, raise the bad_value protocol error.
The crop and scale state is double-buffered state, and will be
@@ -168,11 +179,6 @@
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"/>
Pekka Paalanen
2016-04-26 12:51:06 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

wp_viewporter spec requires protocol errors when the viewport is outside
the buffer area.

The viewport is checked in wl_surface.commit handler as the error needs
to be delivered as a reply to the commit, not at state apply time later
(e.g. with synchronized sub-surfaces, or at render time).

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 1d605c7..4dfa7b7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2804,6 +2804,71 @@ weston_surface_build_buffer_matrix(const struct weston_surface *surface,
weston_matrix_scale(matrix, vp->buffer.scale, vp->buffer.scale, 1);
}

+/**
+ * Compute a + b > c while being safe to overflows.
+ */
+static bool
+fixed_sum_gt(wl_fixed_t a, wl_fixed_t b, wl_fixed_t c)
+{
+ return (int64_t)a + (int64_t)b > (int64_t)c;
+}
+
+static bool
+weston_surface_is_pending_viewport_source_valid(
+ const struct weston_surface *surface)
+{
+ const struct weston_surface_state *pend = &surface->pending;
+ const struct weston_buffer_viewport *vp = &pend->buffer_viewport;
+ int width_from_buffer = 0;
+ int height_from_buffer = 0;
+ wl_fixed_t w;
+ wl_fixed_t h;
+
+ /* If viewport source rect is not set, always ok. */
+ if (vp->buffer.src_width == wl_fixed_from_int(-1))
+ return true;
+
+ if (pend->newly_attached) {
+ if (pend->buffer) {
+ convert_size_by_transform_scale(&width_from_buffer,
+ &height_from_buffer,
+ pend->buffer->width,
+ pend->buffer->height,
+ vp->buffer.transform,
+ vp->buffer.scale);
+ } else {
+ /* No buffer, viewport is irrelevant. */
+ return true;
+ }
+ } else {
+ width_from_buffer = surface->width_from_buffer;
+ height_from_buffer = surface->height_from_buffer;
+ }
+
+ assert((width_from_buffer == 0) == (height_from_buffer == 0));
+ assert(width_from_buffer >= 0 && height_from_buffer >= 0);
+
+ /* No buffer, viewport is irrelevant. */
+ if (width_from_buffer == 0 || height_from_buffer == 0)
+ return true;
+
+ /* overflow checks for wl_fixed_from_int() */
+ if (width_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+ if (height_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+
+ w = wl_fixed_from_int(width_from_buffer);
+ h = wl_fixed_from_int(height_from_buffer);
+
+ if (fixed_sum_gt(vp->buffer.src_x, vp->buffer.src_width, w))
+ return false;
+ if (fixed_sum_gt(vp->buffer.src_y, vp->buffer.src_height, h))
+ return false;
+
+ return true;
+}
+
/* Translate pending damage in buffer co-ordinates to surface
* co-ordinates and union it with a pixman_region32_t.
* This should only be called after the buffer is attached.
@@ -2943,6 +3008,16 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
struct weston_surface *surface = wl_resource_get_user_data(resource);
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);

+ if (!weston_surface_is_pending_viewport_source_valid(surface)) {
+ assert(surface->viewport_resource);
+
+ wl_resource_post_error(surface->viewport_resource,
+ WP_VIEWPORT_ERROR_OUT_OF_BUFFER,
+ "wl_surface@%d has viewport source outside buffer",
+ wl_resource_get_id(resource));
+ return;
+ }
+
if (sub) {
weston_subsurface_commit(sub);
return;
--
2.7.3
Bryce Harrington
2016-05-05 01:02:57 UTC
Permalink
Post by Pekka Paalanen
wp_viewporter spec requires protocol errors when the viewport is outside
the buffer area.
The viewport is checked in wl_surface.commit handler as the error needs
to be delivered as a reply to the commit, not at state apply time later
(e.g. with synchronized sub-surfaces, or at render time).
---
src/compositor.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/src/compositor.c b/src/compositor.c
index 1d605c7..4dfa7b7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2804,6 +2804,71 @@ weston_surface_build_buffer_matrix(const struct weston_surface *surface,
weston_matrix_scale(matrix, vp->buffer.scale, vp->buffer.scale, 1);
}
+/**
+ * Compute a + b > c while being safe to overflows.
+ */
+static bool
+fixed_sum_gt(wl_fixed_t a, wl_fixed_t b, wl_fixed_t c)
+{
+ return (int64_t)a + (int64_t)b > (int64_t)c;
+}
+
+static bool
+weston_surface_is_pending_viewport_source_valid(
+ const struct weston_surface *surface)
+{
+ const struct weston_surface_state *pend = &surface->pending;
+ const struct weston_buffer_viewport *vp = &pend->buffer_viewport;
+ int width_from_buffer = 0;
+ int height_from_buffer = 0;
+ wl_fixed_t w;
+ wl_fixed_t h;
+
+ /* If viewport source rect is not set, always ok. */
nitpick: semicolon rather than comma
Post by Pekka Paalanen
+ if (vp->buffer.src_width == wl_fixed_from_int(-1))
+ return true;
+
+ if (pend->newly_attached) {
+ if (pend->buffer) {
+ convert_size_by_transform_scale(&width_from_buffer,
+ &height_from_buffer,
+ pend->buffer->width,
+ pend->buffer->height,
+ vp->buffer.transform,
+ vp->buffer.scale);
+ } else {
+ /* No buffer, viewport is irrelevant. */
nitpick: semicolon rather than comma
Post by Pekka Paalanen
+ return true;
+ }
+ } else {
+ width_from_buffer = surface->width_from_buffer;
+ height_from_buffer = surface->height_from_buffer;
+ }
+
+ assert((width_from_buffer == 0) == (height_from_buffer == 0));
+ assert(width_from_buffer >= 0 && height_from_buffer >= 0);
Clever logic! But maybe too clever to use in asserts?
Post by Pekka Paalanen
+ /* No buffer, viewport is irrelevant. */
nitpick: semicolon rather than comma
Post by Pekka Paalanen
+ if (width_from_buffer == 0 || height_from_buffer == 0)
+ return true;
+
+ /* overflow checks for wl_fixed_from_int() */
+ if (width_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+ if (height_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+
+ w = wl_fixed_from_int(width_from_buffer);
+ h = wl_fixed_from_int(height_from_buffer);
+
+ if (fixed_sum_gt(vp->buffer.src_x, vp->buffer.src_width, w))
+ return false;
+ if (fixed_sum_gt(vp->buffer.src_y, vp->buffer.src_height, h))
+ return false;
+
+ return true;
+}
+
/* Translate pending damage in buffer co-ordinates to surface
* co-ordinates and union it with a pixman_region32_t.
* This should only be called after the buffer is attached.
@@ -2943,6 +3008,16 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
struct weston_surface *surface = wl_resource_get_user_data(resource);
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);
+ if (!weston_surface_is_pending_viewport_source_valid(surface)) {
+ assert(surface->viewport_resource);
+
+ wl_resource_post_error(surface->viewport_resource,
+ WP_VIEWPORT_ERROR_OUT_OF_BUFFER,
+ wl_resource_get_id(resource));
+ return;
+ }
+
if (sub) {
weston_subsurface_commit(sub);
return;
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-05-06 12:00:21 UTC
Permalink
On Wed, 4 May 2016 18:02:57 -0700
Post by Bryce Harrington
Post by Pekka Paalanen
wp_viewporter spec requires protocol errors when the viewport is outside
the buffer area.
The viewport is checked in wl_surface.commit handler as the error needs
to be delivered as a reply to the commit, not at state apply time later
(e.g. with synchronized sub-surfaces, or at render time).
---
src/compositor.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/src/compositor.c b/src/compositor.c
index 1d605c7..4dfa7b7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2804,6 +2804,71 @@ weston_surface_build_buffer_matrix(const struct weston_surface *surface,
weston_matrix_scale(matrix, vp->buffer.scale, vp->buffer.scale, 1);
}
+/**
+ * Compute a + b > c while being safe to overflows.
+ */
+static bool
+fixed_sum_gt(wl_fixed_t a, wl_fixed_t b, wl_fixed_t c)
+{
+ return (int64_t)a + (int64_t)b > (int64_t)c;
+}
+
+static bool
+weston_surface_is_pending_viewport_source_valid(
+ const struct weston_surface *surface)
+{
+ const struct weston_surface_state *pend = &surface->pending;
+ const struct weston_buffer_viewport *vp = &pend->buffer_viewport;
+ int width_from_buffer = 0;
+ int height_from_buffer = 0;
+ wl_fixed_t w;
+ wl_fixed_t h;
+
+ /* If viewport source rect is not set, always ok. */
nitpick: semicolon rather than comma
No, I don't think "If viewport source rect is not set" is meaningful on
its own. The latter clause is missing a verb.
Post by Bryce Harrington
Post by Pekka Paalanen
+ if (vp->buffer.src_width == wl_fixed_from_int(-1))
+ return true;
+
+ if (pend->newly_attached) {
+ if (pend->buffer) {
+ convert_size_by_transform_scale(&width_from_buffer,
+ &height_from_buffer,
+ pend->buffer->width,
+ pend->buffer->height,
+ vp->buffer.transform,
+ vp->buffer.scale);
+ } else {
+ /* No buffer, viewport is irrelevant. */
nitpick: semicolon rather than comma
Right.
Post by Bryce Harrington
Post by Pekka Paalanen
+ return true;
+ }
+ } else {
+ width_from_buffer = surface->width_from_buffer;
+ height_from_buffer = surface->height_from_buffer;
+ }
+
+ assert((width_from_buffer == 0) == (height_from_buffer == 0));
+ assert(width_from_buffer >= 0 && height_from_buffer >= 0);
Clever logic! But maybe too clever to use in asserts?
Is it? Either they both are or are not.
Post by Bryce Harrington
Post by Pekka Paalanen
+ /* No buffer, viewport is irrelevant. */
nitpick: semicolon rather than comma
Sure. More like a colon than a semicolon in both cases.


Thanks,
pq
Post by Bryce Harrington
Post by Pekka Paalanen
+ if (width_from_buffer == 0 || height_from_buffer == 0)
+ return true;
+
+ /* overflow checks for wl_fixed_from_int() */
+ if (width_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+ if (height_from_buffer > wl_fixed_to_int(INT32_MAX))
+ return false;
+
+ w = wl_fixed_from_int(width_from_buffer);
+ h = wl_fixed_from_int(height_from_buffer);
+
+ if (fixed_sum_gt(vp->buffer.src_x, vp->buffer.src_width, w))
+ return false;
+ if (fixed_sum_gt(vp->buffer.src_y, vp->buffer.src_height, h))
+ return false;
+
+ return true;
+}
+
/* Translate pending damage in buffer co-ordinates to surface
* co-ordinates and union it with a pixman_region32_t.
* This should only be called after the buffer is attached.
@@ -2943,6 +3008,16 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
struct weston_surface *surface = wl_resource_get_user_data(resource);
struct weston_subsurface *sub = weston_surface_to_subsurface(surface);
+ if (!weston_surface_is_pending_viewport_source_valid(surface)) {
+ assert(surface->viewport_resource);
+
+ wl_resource_post_error(surface->viewport_resource,
+ WP_VIEWPORT_ERROR_OUT_OF_BUFFER,
+ wl_resource_get_id(resource));
+ return;
+ }
+
if (sub) {
weston_subsurface_commit(sub);
return;
--
2.7.3
Pekka Paalanen
2016-04-26 12:51:04 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

The stable version of the scaling and cropping extension is found in
wayland-protocols as viewporter.xml.

Remove scaler.xml as nothing uses it.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 5 --
protocol/scaler.xml | 208 ----------------------------------------------------
2 files changed, 213 deletions(-)
delete mode 100644 protocol/scaler.xml

diff --git a/Makefile.am b/Makefile.am
index eed2c0a..5c16b8f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -571,8 +571,6 @@ libtoytoolkit_la_SOURCES = \
nodist_libtoytoolkit_la_SOURCES = \
protocol/text-cursor-position-protocol.c \
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 \
@@ -778,8 +776,6 @@ BUILT_SOURCES += \
protocol/input-method-unstable-v1-client-protocol.h \
protocol/weston-desktop-shell-client-protocol.h \
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 \
@@ -1369,7 +1365,6 @@ EXTRA_DIST += \
protocol/weston-screenshooter.xml \
protocol/text-cursor-position.xml \
protocol/weston-test.xml \
- protocol/scaler.xml \
protocol/ivi-application.xml \
protocol/ivi-hmi-controller.xml

diff --git a/protocol/scaler.xml b/protocol/scaler.xml
deleted file mode 100644
index 0e482a6..0000000
--- a/protocol/scaler.xml
+++ /dev/null
@@ -1,208 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
-
- <copyright>
- Copyright © 2013-2014 Collabora, Ltd.
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice (including the next
- paragraph) shall be included in all copies or substantial portions of the
- Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE 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>
--
2.7.3
Pekka Paalanen
2016-04-26 12:51:03 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Use wp_viewporter instead of wl_scaler and rename things as appropriate.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 4 ++--
clients/simple-damage.c | 32 ++++++++++++++++----------------
2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 22647ba..eed2c0a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -490,8 +490,8 @@ weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) libshared.la

weston_simple_damage_SOURCES = clients/simple-damage.c
nodist_weston_simple_damage_SOURCES = \
- 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/fullscreen-shell-unstable-v1-protocol.c \
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index 321b90f..82091d5 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -40,7 +40,7 @@
#include "shared/zalloc.h"
#include "xdg-shell-unstable-v5-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
-#include "scaler-client-protocol.h"
+#include "viewporter-client-protocol.h"

int print_debug = 0;

@@ -49,7 +49,7 @@ struct display {
struct wl_registry *registry;
int compositor_version;
struct wl_compositor *compositor;
- struct wl_scaler *scaler;
+ struct wp_viewporter *viewporter;
struct xdg_shell *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
@@ -72,7 +72,7 @@ struct window {
struct display *display;
int width, height, border;
struct wl_surface *surface;
- struct wl_viewport *viewport;
+ struct wp_viewport *viewport;
struct xdg_surface *xdg_surface;
struct wl_callback *callback;
struct buffer buffers[2];
@@ -258,8 +258,8 @@ create_window(struct display *display, int width, int height,
exit(1);
}

- if (display->scaler == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) {
- fprintf(stderr, "Compositor does not support wl_viewport");
+ if (display->viewporter == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) {
+ fprintf(stderr, "Compositor does not support wp_viewport");
exit(1);
}

@@ -290,8 +290,8 @@ create_window(struct display *display, int width, int height,
window->surface = wl_compositor_create_surface(display->compositor);

if (window->flags & WINDOW_FLAG_USE_VIEWPORT)
- window->viewport = wl_scaler_get_viewport(display->scaler,
- window->surface);
+ window->viewport = wp_viewporter_get_viewport(display->viewporter,
+ window->surface);

if (display->shell) {
window->xdg_surface =
@@ -337,7 +337,7 @@ destroy_window(struct window *window)
if (window->xdg_surface)
xdg_surface_destroy(window->xdg_surface);
if (window->viewport)
- wl_viewport_destroy(window->viewport);
+ wp_viewport_destroy(window->viewport);
wl_surface_destroy(window->surface);
free(window);
}
@@ -560,7 +560,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
off_x = ty;
break;
}
- wl_viewport_set_source(window->viewport,
+ wp_viewport_set_source(window->viewport,
wl_fixed_from_int(window->width / 3),
wl_fixed_from_int(window->height / 5),
wl_fixed_from_int(window->width / 2),
@@ -640,7 +640,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
window->transform);

if (window->viewport)
- wl_viewport_set_destination(window->viewport,
+ wp_viewport_set_destination(window->viewport,
window->width,
window->height);

@@ -709,9 +709,9 @@ registry_handle_global(void *data, struct wl_registry *registry,
wl_registry_bind(registry,
id, &wl_compositor_interface,
d->compositor_version);
- } else if (strcmp(interface, "wl_scaler") == 0 && version >= 2) {
- d->scaler = wl_registry_bind(registry,
- id, &wl_scaler_interface, 2);
+ } else if (strcmp(interface, "wp_viewporter") == 0) {
+ d->viewporter = wl_registry_bind(registry, id,
+ &wp_viewporter_interface, 1);
} else if (strcmp(interface, "xdg_shell") == 0) {
d->shell = wl_registry_bind(registry,
id, &xdg_shell_interface, 1);
@@ -784,8 +784,8 @@ destroy_display(struct display *display)
if (display->fshell)
zwp_fullscreen_shell_v1_release(display->fshell);

- if (display->scaler)
- wl_scaler_destroy(display->scaler);
+ if (display->viewporter)
+ wp_viewporter_destroy(display->viewporter);

if (display->compositor)
wl_compositor_destroy(display->compositor);
@@ -816,7 +816,7 @@ print_usage(int retval)
" --scale=SCALE\t\tScale factor for the surface\n"
" --transform=TRANSFORM\tTransform for the surface\n"
" --rotating-transform\tUse a different buffer_transform for each frame\n"
- " --use-viewport\tUse wl_viewport\n"
+ " --use-viewport\tUse wp_viewport\n"
" --use-damage-buffer\tUse damage_buffer to post damage\n"
);
--
2.7.3
Pekka Paalanen
2016-04-26 12:50:55 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Rename interfaces and the protocol to follow the policy.

Reset interface versions.

Replace "surface coordinates" with "surface local coordinates".

Hook up to build and install.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
Reviewed-by: Yong Bakos <***@humanoriented.com>
Reviewed-by: Daniel Stone <***@collabora.com>
---
Makefile.am | 1 +
stable/viewporter/viewporter.xml | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 033789f..71d2632 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ unstable_protocols = \

stable_protocols = \
stable/presentation-time/presentation-time.xml \
+ stable/viewporter/viewporter.xml \
$(NULL)

nobase_dist_pkgdata_DATA = \
diff --git a/stable/viewporter/viewporter.xml b/stable/viewporter/viewporter.xml
index e4322bd..7d299eb 100644
--- a/stable/viewporter/viewporter.xml
+++ b/stable/viewporter/viewporter.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="scaler">
+<protocol name="viewporter">

<copyright>
Copyright © 2013-2014 Collabora, Ltd.
@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>

- <interface name="wl_scaler" version="2">
+ <interface name="wp_viewporter" version="1">
<description summary="surface cropping and scaling">
The global interface exposing surface cropping and scaling
capabilities is used to instantiate an interface extension for a
@@ -38,7 +38,7 @@
<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.
+ wp_viewport objects included.
</description>
</request>

@@ -51,18 +51,18 @@
<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
+ a wp_viewport object associated, the viewport_exists
protocol error is raised.
</description>

- <arg name="id" type="new_id" interface="wl_viewport"
+ <arg name="id" type="new_id" interface="wp_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">
+ <interface name="wp_viewport" version="1">
<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
@@ -85,7 +85,7 @@
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.
+ at least 1x1 in surface local 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
@@ -97,7 +97,7 @@
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*)
+ 3. crop and scale (wp_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
@@ -113,10 +113,10 @@
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_surface associated with the wp_viewport is destroyed,
+ the wp_viewport object becomes inert.

- If the wl_viewport object is destroyed, the crop and scale
+ If the wp_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>
@@ -133,10 +133,10 @@
summary="negative or zero values in width or height"/>
</enum>

- <request name="set_source" since="2">
+ <request name="set_source">
<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
+ wp_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
@@ -154,10 +154,10 @@
<arg name="height" type="fixed" summary="source rectangle height"/>
</request>

- <request name="set_destination" since="2">
+ <request name="set_destination">
<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
+ wp_viewport for the description, and relation to the wl_buffer
size.

If width is -1 and height is -1, the destination size is unset
@@ -178,4 +178,5 @@
<arg name="height" type="int" summary="surface height"/>
</request>
</interface>
+
</protocol>
--
2.7.3
Pekka Paalanen
2016-04-26 12:51:08 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

The revised wp_viewport spec requires that unset has to have all of x, y,
width and height -1 to be recognized.

Check for negative x and y and raise the required error. The error event
now mentions the wl_surface, too.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 0c2de04..8349113 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4498,22 +4498,29 @@ viewport_set_source(struct wl_client *client,
}

assert(surface->viewport_resource == resource);
+ assert(surface->resource);

if (src_width == wl_fixed_from_int(-1) &&
- src_height == wl_fixed_from_int(-1)) {
- /* unset source size */
+ src_height == wl_fixed_from_int(-1) &&
+ src_x == wl_fixed_from_int(-1) &&
+ src_y == wl_fixed_from_int(-1)) {
+ /* unset source rect */
surface->pending.buffer_viewport.buffer.src_width =
wl_fixed_from_int(-1);
surface->pending.buffer_viewport.changed = 1;
return;
}

- if (src_width <= 0 || src_height <= 0) {
+ if (src_width <= 0 || src_height <= 0 || src_x < 0 || src_y < 0) {
wl_resource_post_error(resource,
WP_VIEWPORT_ERROR_BAD_VALUE,
- "source size must be positive (%fx%f)",
+ "wl_surface@%d viewport source "
+ "w=%f <= 0, h=%f <= 0, x=%f < 0, or y=%f < 0",
+ wl_resource_get_id(surface->resource),
wl_fixed_to_double(src_width),
- wl_fixed_to_double(src_height));
+ wl_fixed_to_double(src_height),
+ wl_fixed_to_double(src_x),
+ wl_fixed_to_double(src_y));
return;
}
--
2.7.3
Pekka Paalanen
2016-04-26 12:50:58 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

Makes it easier to see that it does not change weston_surface state
implicitly.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 5500197..491b333 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2708,10 +2708,10 @@ weston_surface_commit_subsurface_order(struct weston_surface *surface)
}

static void
-weston_surface_build_buffer_matrix(struct weston_surface *surface,
+weston_surface_build_buffer_matrix(const struct weston_surface *surface,
struct weston_matrix *matrix)
{
- struct weston_buffer_viewport *vp = &surface->buffer_viewport;
+ const struct weston_buffer_viewport *vp = &surface->buffer_viewport;
double src_width, src_height, dest_width, dest_height;

weston_matrix_init(matrix);
--
2.7.3
Bryce Harrington
2016-05-05 00:34:22 UTC
Permalink
Post by Pekka Paalanen
Makes it easier to see that it does not change weston_surface state
implicitly.
---
src/compositor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 5500197..491b333 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2708,10 +2708,10 @@ weston_surface_commit_subsurface_order(struct weston_surface *surface)
}
static void
-weston_surface_build_buffer_matrix(struct weston_surface *surface,
+weston_surface_build_buffer_matrix(const struct weston_surface *surface,
struct weston_matrix *matrix)
{
- struct weston_buffer_viewport *vp = &surface->buffer_viewport;
+ const struct weston_buffer_viewport *vp = &surface->buffer_viewport;
double src_width, src_height, dest_width, dest_height;
weston_matrix_init(matrix);
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-04-26 12:50:59 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

There were two copies of code applying transform and scale to size.
Refactor the code to use just one copy in a new function.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 80 ++++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 491b333..75c8c78 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1725,33 +1725,50 @@ fixed_round_up_to_int(wl_fixed_t f)
}

static void
-weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
+convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out,
+ int32_t width, int32_t height,
+ uint32_t transform,
+ int32_t scale)
{
- struct weston_buffer_viewport *vp = &surface->buffer_viewport;
- int32_t width, height;
-
- if (!surface->buffer_ref.buffer) {
- surface->width_from_buffer = 0;
- surface->height_from_buffer = 0;
- return;
- }
+ assert(scale > 0);

- switch (vp->buffer.transform) {
+ switch (transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ case WL_OUTPUT_TRANSFORM_180:
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ *width_out = width / scale;
+ *height_out = height / scale;
+ break;
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- width = surface->buffer_ref.buffer->height / vp->buffer.scale;
- height = surface->buffer_ref.buffer->width / vp->buffer.scale;
+ *width_out = height / scale;
+ *height_out = width / scale;
break;
default:
- width = surface->buffer_ref.buffer->width / vp->buffer.scale;
- height = surface->buffer_ref.buffer->height / vp->buffer.scale;
- break;
+ assert(0 && "invalid transform");
+ }
+}
+
+static void
+weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
+{
+ struct weston_buffer_viewport *vp = &surface->buffer_viewport;
+
+ if (!surface->buffer_ref.buffer) {
+ surface->width_from_buffer = 0;
+ surface->height_from_buffer = 0;
+ return;
}

- surface->width_from_buffer = width;
- surface->height_from_buffer = height;
+ convert_size_by_transform_scale(&surface->width_from_buffer,
+ &surface->height_from_buffer,
+ surface->buffer_ref.buffer->width,
+ surface->buffer_ref.buffer->height,
+ vp->buffer.transform,
+ vp->buffer.scale);
}

static void
@@ -4168,30 +4185,13 @@ static void
weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
{
output->transform = transform;
+ output->native_scale = scale;
+ output->current_scale = scale;

- switch (transform) {
- case WL_OUTPUT_TRANSFORM_90:
- case WL_OUTPUT_TRANSFORM_270:
- case WL_OUTPUT_TRANSFORM_FLIPPED_90:
- case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- /* Swap width and height */
- output->width = output->current_mode->height;
- output->height = output->current_mode->width;
- break;
- case WL_OUTPUT_TRANSFORM_NORMAL:
- case WL_OUTPUT_TRANSFORM_180:
- case WL_OUTPUT_TRANSFORM_FLIPPED:
- case WL_OUTPUT_TRANSFORM_FLIPPED_180:
- output->width = output->current_mode->width;
- output->height = output->current_mode->height;
- break;
- default:
- break;
- }
-
- output->native_scale = output->current_scale = scale;
- output->width /= scale;
- output->height /= scale;
+ convert_size_by_transform_scale(&output->width, &output->height,
+ output->current_mode->width,
+ output->current_mode->height,
+ transform, scale);
}

static void
--
2.7.3
Bryce Harrington
2016-05-05 00:45:33 UTC
Permalink
Post by Pekka Paalanen
There were two copies of code applying transform and scale to size.
Refactor the code to use just one copy in a new function.
Nice refactoring. I would probably use error returns rather than
asserts, but that's probably down to personal preference and anyway I'm
not sure how the error situation should be handled better than
termination. Presumably invalid scale and transforms never happen in
practice anyway, so assert may be the better choice.

Reviewed-by: Bryce Harrington <***@osg.samsung.com>

Weston patches 6 and 7 would be fine to land now pre-beta; they don't
depend on the protocol changes and are straightforward refactors.

Bryce
Post by Pekka Paalanen
---
src/compositor.c | 80 ++++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 491b333..75c8c78 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1725,33 +1725,50 @@ fixed_round_up_to_int(wl_fixed_t f)
}
static void
-weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
+convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out,
+ int32_t width, int32_t height,
+ uint32_t transform,
+ int32_t scale)
{
- struct weston_buffer_viewport *vp = &surface->buffer_viewport;
- int32_t width, height;
-
- if (!surface->buffer_ref.buffer) {
- surface->width_from_buffer = 0;
- surface->height_from_buffer = 0;
- return;
- }
+ assert(scale > 0);
- switch (vp->buffer.transform) {
+ switch (transform) {
+ *width_out = width / scale;
+ *height_out = height / scale;
+ break;
- width = surface->buffer_ref.buffer->height / vp->buffer.scale;
- height = surface->buffer_ref.buffer->width / vp->buffer.scale;
+ *width_out = height / scale;
+ *height_out = width / scale;
break;
- width = surface->buffer_ref.buffer->width / vp->buffer.scale;
- height = surface->buffer_ref.buffer->height / vp->buffer.scale;
- break;
+ assert(0 && "invalid transform");
+ }
+}
+
+static void
+weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
+{
+ struct weston_buffer_viewport *vp = &surface->buffer_viewport;
+
+ if (!surface->buffer_ref.buffer) {
+ surface->width_from_buffer = 0;
+ surface->height_from_buffer = 0;
+ return;
}
- surface->width_from_buffer = width;
- surface->height_from_buffer = height;
+ convert_size_by_transform_scale(&surface->width_from_buffer,
+ &surface->height_from_buffer,
+ surface->buffer_ref.buffer->width,
+ surface->buffer_ref.buffer->height,
+ vp->buffer.transform,
+ vp->buffer.scale);
}
static void
@@ -4168,30 +4185,13 @@ static void
weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
{
output->transform = transform;
+ output->native_scale = scale;
+ output->current_scale = scale;
- switch (transform) {
- /* Swap width and height */
- output->width = output->current_mode->height;
- output->height = output->current_mode->width;
- break;
- output->width = output->current_mode->width;
- output->height = output->current_mode->height;
- break;
- break;
- }
-
- output->native_scale = output->current_scale = scale;
- output->width /= scale;
- output->height /= scale;
+ convert_size_by_transform_scale(&output->width, &output->height,
+ output->current_mode->width,
+ output->current_mode->height,
+ transform, scale);
}
static void
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-05-06 11:43:40 UTC
Permalink
On Wed, 4 May 2016 17:45:33 -0700
Post by Bryce Harrington
Post by Pekka Paalanen
There were two copies of code applying transform and scale to size.
Refactor the code to use just one copy in a new function.
Nice refactoring. I would probably use error returns rather than
asserts, but that's probably down to personal preference and anyway I'm
not sure how the error situation should be handled better than
termination. Presumably invalid scale and transforms never happen in
practice anyway, so assert may be the better choice.
Yes, at this point in code, if scale or transform are invalid, it is an
internal bug in weston. Old code would have gladly divided by zero.
Post by Bryce Harrington
Weston patches 6 and 7 would be fine to land now pre-beta; they don't
depend on the protocol changes and are straightforward refactors.
Both pushed:
2f78301..59987fa master -> master


Thanks,
pq
Pekka Paalanen
2016-04-26 12:51:05 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

If a client destroyed the wl_surface before the wp_viewport, Weston core
would access freed memory, because the weston_surface pointer stored in
the wp_viewport wl_resource's user data was stale.

Fix this by setting the user data to NULL on wl_surface destruction. It
specifically wl_surface and not weston_surface destruction, because this
is about client-visible behaviour. Something internal might keep
weston_surface alive past the wl_surface.

Add checks to all wp_viewport request handlers.

At the same time, implement the new error conditions in wp_viewport:
calling any request except destroy must result in a protocol error.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index d462409..1d605c7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1986,6 +1986,10 @@ destroy_surface(struct wl_resource *resource)
* dangling pointer if the surface was refcounted and survives
* the weston_surface_destroy() call. */
surface->resource = NULL;
+
+ if (surface->viewport_resource)
+ wl_resource_set_user_data(surface->viewport_resource, NULL);
+
weston_surface_destroy(surface);
}

@@ -4351,6 +4355,9 @@ destroy_viewport(struct wl_resource *resource)
struct weston_surface *surface =
wl_resource_get_user_data(resource);

+ if (!surface)
+ return;
+
surface->viewport_resource = NULL;
surface->pending.buffer_viewport.buffer.src_width =
wl_fixed_from_int(-1);
@@ -4376,7 +4383,14 @@ viewport_set_source(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);

- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);

if (src_width == wl_fixed_from_int(-1) &&
src_height == wl_fixed_from_int(-1)) {
@@ -4412,7 +4426,14 @@ viewport_set_destination(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);

- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);

if (dst_width == -1 && dst_height == -1) {
/* unset destination size */
--
2.7.3
Bryce Harrington
2016-05-05 00:57:59 UTC
Permalink
Post by Pekka Paalanen
If a client destroyed the wl_surface before the wp_viewport, Weston core
would access freed memory, because the weston_surface pointer stored in
the wp_viewport wl_resource's user data was stale.
Fix this by setting the user data to NULL on wl_surface destruction. It
specifically wl_surface and not weston_surface destruction, because this
Think we're missing a word or two somewhere in the beginning of that
sentence.
Post by Pekka Paalanen
is about client-visible behaviour. Something internal might keep
weston_surface alive past the wl_surface.
Add checks to all wp_viewport request handlers.
calling any request except destroy must result in a protocol error.
---
src/compositor.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index d462409..1d605c7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1986,6 +1986,10 @@ destroy_surface(struct wl_resource *resource)
* dangling pointer if the surface was refcounted and survives
* the weston_surface_destroy() call. */
surface->resource = NULL;
+
+ if (surface->viewport_resource)
+ wl_resource_set_user_data(surface->viewport_resource, NULL);
+
weston_surface_destroy(surface);
}
@@ -4351,6 +4355,9 @@ destroy_viewport(struct wl_resource *resource)
struct weston_surface *surface =
wl_resource_get_user_data(resource);
+ if (!surface)
+ return;
+
surface->viewport_resource = NULL;
surface->pending.buffer_viewport.buffer.src_width =
wl_fixed_from_int(-1);
@@ -4376,7 +4383,14 @@ viewport_set_source(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);
- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
"gone" seems a bit informal. Perhaps it should say "is no longer valid"?
Post by Pekka Paalanen
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);
if (src_width == wl_fixed_from_int(-1) &&
src_height == wl_fixed_from_int(-1)) {
@@ -4412,7 +4426,14 @@ viewport_set_destination(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);
- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
ditto here
Post by Pekka Paalanen
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);
if (dst_width == -1 && dst_height == -1) {
/* unset destination size */
With those bits fixed,
Post by Pekka Paalanen
--
2.7.3
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-05-06 11:51:32 UTC
Permalink
On Wed, 4 May 2016 17:57:59 -0700
Post by Bryce Harrington
Post by Pekka Paalanen
If a client destroyed the wl_surface before the wp_viewport, Weston core
would access freed memory, because the weston_surface pointer stored in
the wp_viewport wl_resource's user data was stale.
Fix this by setting the user data to NULL on wl_surface destruction. It
specifically wl_surface and not weston_surface destruction, because this
Think we're missing a word or two somewhere in the beginning of that
sentence.
Woops, yeah.
Post by Bryce Harrington
Post by Pekka Paalanen
is about client-visible behaviour. Something internal might keep
weston_surface alive past the wl_surface.
Add checks to all wp_viewport request handlers.
calling any request except destroy must result in a protocol error.
---
src/compositor.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index d462409..1d605c7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1986,6 +1986,10 @@ destroy_surface(struct wl_resource *resource)
* dangling pointer if the surface was refcounted and survives
* the weston_surface_destroy() call. */
surface->resource = NULL;
+
+ if (surface->viewport_resource)
+ wl_resource_set_user_data(surface->viewport_resource, NULL);
+
weston_surface_destroy(surface);
}
@@ -4351,6 +4355,9 @@ destroy_viewport(struct wl_resource *resource)
struct weston_surface *surface =
wl_resource_get_user_data(resource);
+ if (!surface)
+ return;
+
surface->viewport_resource = NULL;
surface->pending.buffer_viewport.buffer.src_width =
wl_fixed_from_int(-1);
@@ -4376,7 +4383,14 @@ viewport_set_source(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);
- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
"gone" seems a bit informal. Perhaps it should say "is no longer valid"?
I tried to keep it short for the line length. I'll go with "no longer
exists".
Post by Bryce Harrington
Post by Pekka Paalanen
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);
if (src_width == wl_fixed_from_int(-1) &&
src_height == wl_fixed_from_int(-1)) {
@@ -4412,7 +4426,14 @@ viewport_set_destination(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(resource);
- assert(surface->viewport_resource != NULL);
+ if (!surface) {
+ wl_resource_post_error(resource,
+ WP_VIEWPORT_ERROR_NO_SURFACE,
+ "wl_surface for this viewport is gone");
ditto here
Post by Pekka Paalanen
+ return;
+ }
+
+ assert(surface->viewport_resource == resource);
if (dst_width == -1 && dst_height == -1) {
/* unset destination size */
With those bits fixed,
Done, will be re-sent when it's time.


Thanks,
pq
Pekka Paalanen
2016-04-26 12:51:07 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

wp_viewpoerter requires the destination size to be always in integers,
even then it is implicit from source rectangle. Emit appropriate
protocol errors.

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
src/compositor.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 4dfa7b7..0c2de04 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2869,6 +2869,28 @@ weston_surface_is_pending_viewport_source_valid(
return true;
}

+static bool
+fixed_is_integer(wl_fixed_t v)
+{
+ return (v & 0xff) == 0;
+}
+
+static bool
+weston_surface_is_pending_viewport_dst_size_int(
+ const struct weston_surface *surface)
+{
+ const struct weston_buffer_viewport *vp =
+ &surface->pending.buffer_viewport;
+
+ if (vp->surface.width != -1) {
+ assert(vp->surface.width > 0 && vp->surface.height > 0);
+ return true;
+ }
+
+ return fixed_is_integer(vp->buffer.src_width) &&
+ fixed_is_integer(vp->buffer.src_height);
+}
+
/* Translate pending damage in buffer co-ordinates to surface
* co-ordinates and union it with a pixman_region32_t.
* This should only be called after the buffer is attached.
@@ -3018,6 +3040,16 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
return;
}

+ if (!weston_surface_is_pending_viewport_dst_size_int(surface)) {
+ assert(surface->viewport_resource);
+
+ wl_resource_post_error(surface->viewport_resource,
+ WP_VIEWPORT_ERROR_BAD_SIZE,
+ "wl_surface@%d viewport dst size not integer",
+ wl_resource_get_id(resource));
+ return;
+ }
+
if (sub) {
weston_subsurface_commit(sub);
return;
--
2.7.3
Pekka Paalanen
2016-04-26 12:51:09 UTC
Permalink
From: Pekka Paalanen <***@collabora.co.uk>

These tests poke the viewporter interface to ensure proper behaviour
from client perspective, without testing the rendering result.

These cases are covered:
- create viewport twice
- source rectangle invalid value errors, and unset
- destination size invalid value errors, and unset
- source causing non-integer destination size
- source inside/outside of buffer with transform, scale
- source outside NULL buffer, then getting real buffer
- source outside NULL buffer with inherited NULL
- set_source, set_destination, and destroy after the wl_surface is
destroyed

Signed-off-by: Pekka Paalanen <***@collabora.co.uk>
---
Makefile.am | 10 +
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 563 insertions(+)
create mode 100644 tests/viewporter-test.c

diff --git a/Makefile.am b/Makefile.am
index 5c16b8f..c0862f6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1103,6 +1103,7 @@ weston_tests = \
button.weston \
text.weston \
presentation.weston \
+ viewporter.weston \
roles.weston \
subsurface.weston \
devices.weston
@@ -1255,6 +1256,15 @@ roles_weston_SOURCES = tests/roles-test.c
roles_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
roles_weston_LDADD = libtest-client.la

+viewporter_weston_SOURCES = \
+ tests/viewporter-test.c \
+ shared/helpers.h
+nodist_viewporter_weston_SOURCES = \
+ protocol/viewporter-protocol.c \
+ protocol/viewporter-client-protocol.h
+viewporter_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
+viewporter_weston_LDADD = libtest-client.la
+
if ENABLE_EGL
weston_tests += buffer-count.weston
buffer_count_weston_SOURCES = tests/buffer-count-test.c
diff --git a/tests/viewporter-test.c b/tests/viewporter-test.c
new file mode 100644
index 0000000..b24276f
--- /dev/null
+++ b/tests/viewporter-test.c
@@ -0,0 +1,553 @@
+/*
+ * Copyright © 2014, 2016 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+
+#include "shared/helpers.h"
+#include "shared/xalloc.h"
+#include "weston-test-client-helper.h"
+#include "viewporter-client-protocol.h"
+
+static struct wp_viewporter *
+get_viewporter(struct client *client)
+{
+ struct global *g;
+ struct global *global_wpr = NULL;
+ static struct wp_viewporter *wpr;
+
+ if (wpr)
+ return wpr;
+
+ wl_list_for_each(g, &client->global_list, link) {
+ if (strcmp(g->interface, wp_viewporter_interface.name))
+ continue;
+
+ if (global_wpr)
+ assert(0 && "multiple wp_viewporter objects");
+
+ global_wpr = g;
+ }
+
+ assert(global_wpr && "no wp_viewporter found");
+
+ assert(global_wpr->version == 1);
+
+ wpr = wl_registry_bind(client->wl_registry, global_wpr->name,
+ &wp_viewporter_interface, 1);
+ assert(wpr);
+
+ return wpr;
+}
+
+static struct wp_viewport *
+create_viewport(struct client *client)
+{
+ struct wp_viewporter *viewporter;
+ struct wp_viewport *viewport;
+
+ viewporter = get_viewporter(client);
+ viewport = wp_viewporter_get_viewport(viewporter,
+ client->surface->wl_surface);
+ assert(viewport);
+
+ return viewport;
+}
+
+static void
+set_source(struct wp_viewport *vp, int x, int y, int w, int h)
+{
+ wp_viewport_set_source(vp, wl_fixed_from_int(x), wl_fixed_from_int(y),
+ wl_fixed_from_int(w), wl_fixed_from_int(h));
+}
+
+TEST(test_viewporter_double_create)
+{
+ struct wp_viewporter *viewporter;
+ struct client *client;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ viewporter = get_viewporter(client);
+ wp_viewporter_get_viewport(viewporter, client->surface->wl_surface);
+ wp_viewporter_get_viewport(viewporter, client->surface->wl_surface);
+
+ expect_protocol_error(client, &wp_viewporter_interface,
+ WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS);
+}
+
+struct bad_source_rect_args {
+ int x, y, w, h;
+};
+
+static const struct bad_source_rect_args bad_source_rect_args[] = {
+ { -5, 0, 20, 10 },
+ { 0, -5, 20, 10 },
+ { 5, 6, 0, 10 },
+ { 5, 6, 20, 0 },
+ { 5, 6, -20, 10 },
+ { 5, 6, 20, -10 },
+ { -1, -1, 20, 10 },
+ { 5, 6, -1, -1 },
+};
+
+TEST_P(test_viewporter_bad_source_rect, bad_source_rect_args)
+{
+ const struct bad_source_rect_args *args = data;
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ vp = create_viewport(client);
+
+ fprintf(stderr, "wp_viewport.set_source x=%d, y=%d, w=%d, h=%d\n",
+ args->x, args->y, args->w, args->h);
+ set_source(vp, args->x, args->y, args->w, args->h);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_BAD_VALUE);
+}
+
+TEST(test_viewporter_unset_source_rect)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ vp = create_viewport(client);
+ set_source(vp, -1, -1, -1, -1);
+ wl_surface_commit(client->surface->wl_surface);
+
+ client_roundtrip(client);
+}
+
+struct bad_destination_args {
+ int w, h;
+};
+
+static const struct bad_destination_args bad_destination_args[] = {
+ { 0, 10 },
+ { 20, 0 },
+ { -20, 10 },
+ { -1, 10 },
+ { 20, -10 },
+ { 20, -1 },
+};
+
+TEST_P(test_viewporter_bad_destination_size, bad_destination_args)
+{
+ const struct bad_destination_args *args = data;
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ vp = create_viewport(client);
+
+ fprintf(stderr, "wp_viewport.set_destination w=%d, h=%d\n",
+ args->w, args->h);
+ wp_viewport_set_destination(vp, args->w, args->h);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_BAD_VALUE);
+}
+
+TEST(test_viewporter_unset_destination_size)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ vp = create_viewport(client);
+ wp_viewport_set_destination(vp, -1, -1);
+ wl_surface_commit(client->surface->wl_surface);
+
+ client_roundtrip(client);
+}
+
+struct nonint_destination_args {
+ wl_fixed_t w, h;
+};
+
+static const struct nonint_destination_args nonint_destination_args[] = {
+#define F(i,f) ((i) * 256 + (f))
+ { F(20, 0), F(10, 1) },
+ { F(20, 0), F(10, -1) },
+ { F(20, 1), F(10, 0) },
+ { F(20, -1), F(10, 0) },
+ { F(20, 128), F(10, 128) },
+#undef F
+};
+
+TEST_P(test_viewporter_non_integer_destination_size, nonint_destination_args)
+{
+ const struct nonint_destination_args *args = data;
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+
+ vp = create_viewport(client);
+
+ fprintf(stderr, "non-integer size w=%f, h=%f\n",
+ wl_fixed_to_double(args->w), wl_fixed_to_double(args->h));
+ wp_viewport_set_source(vp, 5, 6, args->w, args->h);
+ wp_viewport_set_destination(vp, -1, -1);
+ wl_surface_commit(client->surface->wl_surface);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_BAD_SIZE);
+}
+
+struct source_buffer_args {
+ wl_fixed_t x, y;
+ wl_fixed_t w, h;
+ int buffer_scale;
+ enum wl_output_transform buffer_transform;
+};
+
+static int
+get_surface_width(struct surface *surface,
+ int buffer_scale,
+ enum wl_output_transform buffer_transform)
+{
+ switch (buffer_transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ case WL_OUTPUT_TRANSFORM_180:
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ return surface->width / buffer_scale;
+ case WL_OUTPUT_TRANSFORM_90:
+ case WL_OUTPUT_TRANSFORM_270:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ return surface->height / buffer_scale;
+ }
+
+ return -1;
+}
+
+static int
+get_surface_height(struct surface *surface,
+ int buffer_scale,
+ enum wl_output_transform buffer_transform)
+{
+ switch (buffer_transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ case WL_OUTPUT_TRANSFORM_180:
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ return surface->height / buffer_scale;
+ case WL_OUTPUT_TRANSFORM_90:
+ case WL_OUTPUT_TRANSFORM_270:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ return surface->width / buffer_scale;
+ }
+
+ return -1;
+}
+
+static void
+setup_source_vs_buffer(struct client *client,
+ const struct source_buffer_args *args)
+{
+ struct wl_surface *surf;
+ struct wp_viewport *vp;
+
+ surf = client->surface->wl_surface;
+ vp = create_viewport(client);
+
+ fprintf(stderr, "surface %dx%d\n",
+ get_surface_width(client->surface,
+ args->buffer_scale, args->buffer_transform),
+ get_surface_height(client->surface,
+ args->buffer_scale, args->buffer_transform));
+ fprintf(stderr, "source x=%f, y=%f, w=%f, h=%f; "
+ "buffer scale=%d, transform=%d\n",
+ wl_fixed_to_double(args->x), wl_fixed_to_double(args->y),
+ wl_fixed_to_double(args->w), wl_fixed_to_double(args->h),
+ args->buffer_scale, args->buffer_transform);
+
+ wl_surface_set_buffer_scale(surf, args->buffer_scale);
+ wl_surface_set_buffer_transform(surf, args->buffer_transform);
+ wl_surface_attach(surf, client->surface->wl_buffer, 0, 0);
+ wp_viewport_set_source(vp, args->x, args->y, args->w, args->h);
+ wp_viewport_set_destination(vp, 99, 99);
+ wl_surface_commit(surf);
+}
+
+/* buffer dimensions */
+#define WIN_W 124
+#define WIN_H 78
+
+/* source rect base size */
+#define SRC_W 20
+#define SRC_H 10
+
+/* margin */
+#define MRG 10
+/* epsilon of wl_fixed_t */
+#define EPS 1
+
+TEST(test_viewporter_source_buffer_params)
+{
+ const int max_scale = 2;
+
+ /* buffer_scale requirement */
+ assert(WIN_W % max_scale == 0);
+ assert(WIN_H % max_scale == 0);
+
+ /* source rect must fit inside regardless of scale and transform */
+ assert(SRC_W < WIN_W / max_scale);
+ assert(SRC_H < WIN_H / max_scale);
+ assert(SRC_W < WIN_H / max_scale);
+ assert(SRC_H < WIN_W / max_scale);
+
+ /* If buffer scale was ignored, source rect should be inside instead */
+ assert(WIN_W / max_scale + SRC_W + MRG < WIN_W);
+ assert(WIN_H / max_scale + SRC_H + MRG < WIN_H);
+ assert(WIN_W / max_scale + SRC_H + MRG < WIN_W);
+ assert(WIN_H / max_scale + SRC_W + MRG < WIN_H);
+}
+
+static const struct source_buffer_args bad_source_buffer_args[] = {
+#define F(i) ((i) * 256)
+
+/* Flush right-top, but epsilon too far right. */
+ { F(WIN_W - SRC_W) + EPS, F(0), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W - SRC_W), F(0), F(SRC_W) + EPS, F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+/* Flush left-bottom, but epsilon too far down. */
+ { F(0), F(WIN_H - SRC_H) + EPS, F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(0), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H) + EPS, 1, WL_OUTPUT_TRANSFORM_NORMAL },
+/* Completely outside on the right. */
+ { F(WIN_W + MRG), F(0), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+/* Competely outside on the bottom. */
+ { F(0), F(WIN_H + MRG), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+
+/*
+ * buffer_scale=2, so the surface size will be halved.
+ * If buffer_scale was not taken into account, these would all be inside.
+ * These are the same as above, but adapted to buffer_scale=2.
+ */
+ { F(WIN_W / 2 - SRC_W) + EPS, F(0), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W / 2 - SRC_W), F(0), F(SRC_W) + EPS, F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+ { F(0), F(WIN_H / 2 - SRC_H) + EPS, F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(0), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H) + EPS, 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+ { F(WIN_W / 2 + MRG), F(0), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+ { F(0), F(WIN_H / 2 + MRG), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+/* Exceeding bottom-right corner by epsilon: */
+/* non-dimension-swapping transforms */
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H) + EPS, 1, WL_OUTPUT_TRANSFORM_FLIPPED_180 },
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H) + EPS, F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED },
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W) + EPS, F(SRC_H), 1, WL_OUTPUT_TRANSFORM_180 },
+
+/* dimension-swapping transforms */
+ { F(WIN_H - SRC_W) + EPS, F(WIN_W - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_90 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H) + EPS, F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_270 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W) + EPS, F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED_90 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W), F(SRC_H) + EPS, 1, WL_OUTPUT_TRANSFORM_FLIPPED_270 },
+
+/* non-dimension-swapping transforms, buffer_scale=2 */
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H) + EPS, F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED_180 },
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W) + EPS, F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED },
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H) + EPS, 2, WL_OUTPUT_TRANSFORM_180 },
+
+/* dimension-swapping transforms, buffer_scale=2 */
+ { F(WIN_H / 2 - SRC_W) + EPS, F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_90 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H) + EPS, F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_270 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W) + EPS, F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED_90 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H) + EPS, 2, WL_OUTPUT_TRANSFORM_FLIPPED_270 },
+
+#undef F
+};
+
+TEST_P(test_viewporter_source_outside_buffer, bad_source_buffer_args)
+{
+ const struct source_buffer_args *args = data;
+ struct client *client;
+
+ client = create_client_and_test_surface(100, 50, WIN_W, WIN_H);
+ setup_source_vs_buffer(client, args);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_OUT_OF_BUFFER);
+}
+
+static const struct source_buffer_args good_source_buffer_args[] = {
+#define F(i) ((i) * 256)
+
+/* top-left, top-right, bottom-left, and bottom-right corner */
+ { F(0), F(0), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W - SRC_W), F(0), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(0), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_NORMAL },
+
+/* buffer_scale=2, so the surface size will be halved */
+ { F(0), F(0), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W / 2 - SRC_W), F(0), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(0), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+/* with half pixel offset */
+ { F(WIN_W / 2 - SRC_W) + 128, F(WIN_H / 2 - SRC_H) + 128, F(SRC_W) - 128, F(SRC_H) - 128, 2, WL_OUTPUT_TRANSFORM_NORMAL },
+
+/* Flushed to bottom-right corner: */
+/* non-dimension-swapping transforms */
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED_180 },
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED },
+ { F(WIN_W - SRC_W), F(WIN_H - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_180 },
+
+/* dimension-swapping transforms */
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_90 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_270 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED_90 },
+ { F(WIN_H - SRC_W), F(WIN_W - SRC_H), F(SRC_W), F(SRC_H), 1, WL_OUTPUT_TRANSFORM_FLIPPED_270 },
+
+/* non-dimension-swapping transforms, buffer_scale=2 */
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED_180 },
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED },
+ { F(WIN_W / 2 - SRC_W), F(WIN_H / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_180 },
+
+/* dimension-swapping transforms, buffer_scale=2 */
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_90 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_270 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED_90 },
+ { F(WIN_H / 2 - SRC_W), F(WIN_W / 2 - SRC_H), F(SRC_W), F(SRC_H), 2, WL_OUTPUT_TRANSFORM_FLIPPED_270 },
+
+#undef F
+};
+
+TEST_P(test_viewporter_source_inside_buffer, good_source_buffer_args)
+{
+ const struct source_buffer_args *args = data;
+ struct client *client;
+
+ client = create_client_and_test_surface(100, 50, WIN_W, WIN_H);
+ setup_source_vs_buffer(client, args);
+ client_roundtrip(client);
+}
+
+#undef WIN_W
+#undef WIN_H
+#undef SRC_W
+#undef SRC_H
+#undef MRG
+#undef EPS
+
+TEST(test_viewporter_outside_null_buffer)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+ struct wl_surface *surf;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ surf = client->surface->wl_surface;
+
+ /* If buffer is NULL, does not matter what the source rect is. */
+ vp = create_viewport(client);
+ wl_surface_attach(surf, NULL, 0, 0);
+ set_source(vp, 1000, 1000, 20, 10);
+ wp_viewport_set_destination(vp, 99, 99);
+ wl_surface_commit(surf);
+ client_roundtrip(client);
+
+ /* Try again, with all old values. */
+ wl_surface_commit(surf);
+ client_roundtrip(client);
+
+ /* Try once more with old NULL buffer. */
+ set_source(vp, 1200, 1200, 20, 10);
+ wl_surface_commit(surf);
+ client_roundtrip(client);
+
+ /* When buffer comes back, source rect matters again. */
+ wl_surface_attach(surf, client->surface->wl_buffer, 0, 0);
+ wl_surface_commit(surf);
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_OUT_OF_BUFFER);
+}
+
+TEST(test_viewporter_no_surface_set_source)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ vp = create_viewport(client);
+ wl_surface_destroy(client->surface->wl_surface);
+ client->surface->wl_surface = NULL;
+
+ /* But the wl_surface does not exist anymore. */
+ set_source(vp, 1000, 1000, 20, 10);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_NO_SURFACE);
+}
+
+TEST(test_viewporter_no_surface_set_destination)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ vp = create_viewport(client);
+ wl_surface_destroy(client->surface->wl_surface);
+ client->surface->wl_surface = NULL;
+
+ /* But the wl_surface does not exist anymore. */
+ wp_viewport_set_destination(vp, 99, 99);
+
+ expect_protocol_error(client, &wp_viewport_interface,
+ WP_VIEWPORT_ERROR_NO_SURFACE);
+}
+
+TEST(test_viewporter_no_surface_destroy)
+{
+ struct client *client;
+ struct wp_viewport *vp;
+
+ client = create_client_and_test_surface(100, 50, 123, 77);
+ vp = create_viewport(client);
+ wl_surface_destroy(client->surface->wl_surface);
+ client->surface->wl_surface = NULL;
+
+ /* But the wl_surface does not exist anymore. */
+ wp_viewport_destroy(vp);
+
+ client_roundtrip(client);
+}
--
2.7.3
Yong Bakos
2016-04-26 16:23:25 UTC
Permalink
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
1-5 look good and v3 is Reviewed-by Yong Bakos <***@humanoriented.com>.

yong
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c
Thanks,
pq
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Bryce Harrington
2016-05-05 00:33:10 UTC
Permalink
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c
Thanks,
pq
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Bryce Harrington
2016-05-05 22:46:46 UTC
Permalink
Post by Bryce Harrington
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
The first two patches in this set don't depend on the protocol and look
fine to land during beta. The rest I'm not sure about, they're a bit
more than a mere rename of the protocol and add functionality. I don't
have anything against them but wouldn't want to land them on my R-b
alone, and unless they're particularly urgent it would be much more
comfortable to land them post-release. I reviewed all the patches and
aside from the nitpicks already mentioned, for purposes of landing post
Post by Bryce Harrington
Post by Pekka Paalanen
Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c
Thanks,
pq
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
_______________________________________________
wayland-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/wayland-devel
Pekka Paalanen
2016-05-06 12:07:19 UTC
Permalink
On Thu, 5 May 2016 15:46:46 -0700
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Recorded.
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
The first two patches in this set don't depend on the protocol and look
fine to land during beta. The rest I'm not sure about, they're a bit
more than a mere rename of the protocol and add functionality. I don't
have anything against them but wouldn't want to land them on my R-b
alone, and unless they're particularly urgent it would be much more
comfortable to land them post-release. I reviewed all the patches and
aside from the nitpicks already mentioned, for purposes of landing post
Recorded.

Yes, they missed 1.11 now, will be for 1.12, expect the first two I
already pushed with your reviews.


Thanks,
pq
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c
Pekka Paalanen
2016-05-10 09:56:41 UTC
Permalink
On Fri, 6 May 2016 15:07:19 +0300
Post by Pekka Paalanen
On Thu, 5 May 2016 15:46:46 -0700
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Recorded.
Hi,

the wayland-protocols patches are now pushed:
cc276df..83bdaa5 master -> master

Now we just need a wayland-protocols release. We should have a couple
of days for the last minute "oops" just in case.
Post by Pekka Paalanen
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
The first two patches in this set don't depend on the protocol and look
fine to land during beta. The rest I'm not sure about, they're a bit
more than a mere rename of the protocol and add functionality. I don't
have anything against them but wouldn't want to land them on my R-b
alone, and unless they're particularly urgent it would be much more
comfortable to land them post-release. I reviewed all the patches and
aside from the nitpicks already mentioned, for purposes of landing post
Recorded.
Yes, they missed 1.11 now, will be for 1.12, expect the first two I
already pushed with your reviews.
This still holds, weston patches won't land until 1.11 is out.


Thanks,
pq
Post by Pekka Paalanen
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Makefile.am | 27 ++-
clients/scaler.c | 43 ++--
clients/simple-damage.c | 32 +--
configure.ac | 2 +
protocol/scaler.xml | 208 ------------------
src/compositor.c | 343 +++++++++++++++++++-----------
src/compositor.h | 5 +-
tests/viewporter-test.c | 553 ++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 823 insertions(+), 390 deletions(-)
delete mode 100644 protocol/scaler.xml
create mode 100644 tests/viewporter-test.c
Pekka Paalanen
2016-06-07 12:20:51 UTC
Permalink
On Tue, 10 May 2016 12:56:41 +0300
Post by Pekka Paalanen
On Fri, 6 May 2016 15:07:19 +0300
Post by Pekka Paalanen
On Thu, 5 May 2016 15:46:46 -0700
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Recorded.
Hi,
cc276df..83bdaa5 master -> master
Now we just need a wayland-protocols release. We should have a couple
of days for the last minute "oops" just in case.
Post by Pekka Paalanen
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
The first two patches in this set don't depend on the protocol and look
fine to land during beta. The rest I'm not sure about, they're a bit
more than a mere rename of the protocol and add functionality. I don't
have anything against them but wouldn't want to land them on my R-b
alone, and unless they're particularly urgent it would be much more
comfortable to land them post-release. I reviewed all the patches and
aside from the nitpicks already mentioned, for purposes of landing post
Recorded.
Yes, they missed 1.11 now, will be for 1.12, expect the first two I
already pushed with your reviews.
This still holds, weston patches won't land until 1.11 is out.
Hi all,

patches 8 - 17 are still in the queue. They apply to master today as
is, the only thing I think that needs fixing is to update the
wayland-protocols dependency, IIRC.

If I understood right, they already have:
Reviewed-by: Bryce Harrington <***@osg.samsung.com>
Reviewed-by: Yong Bakos <***@humanoriented.com>

Hmm, Yong, did you give R-b for pathes 8-17? I'm not quite sure if "v3
is Reviewed-by" means that.

Anyone else want to ack/nack?

If no-one replies, I'll push these patches on, say, Thursday with both
Yong and Bryce R-b.


Thanks,
pq
Pekka Paalanen
2016-06-09 08:19:55 UTC
Permalink
On Tue, 7 Jun 2016 15:20:51 +0300
Post by Pekka Paalanen
On Tue, 10 May 2016 12:56:41 +0300
Post by Pekka Paalanen
On Fri, 6 May 2016 15:07:19 +0300
Post by Pekka Paalanen
On Thu, 5 May 2016 15:46:46 -0700
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
Hi,
here is the v3 of the stabilization series, which I hope to the final to be
merged.
The wayland-protocols patches are essentially the same as v2, except few
cosmetic changes as suggested by review comments. There are mentioned in the
review log in each patch, if there were any.
The weston patches are v3 too, though v2 was never posted. The changes to v1
- patches 6-7 are new (simple preparation)
- patches 8-12 are the same as v1
- patches 13-17 are new, accounting for the spec changes from
wayland-protocols v1
Note, that there are now tests for the wp_viewporter API. \o/
stable: add viewporter draft
stable/viewporter: remove wp_viewport.set request
stable/viewporter: rename and build
stable/viewporter: rephrase a wp_viewport paragraph
stable/viewporter: add more error cases
Makefile.am | 1 +
stable/viewporter/README | 7 ++
stable/viewporter/viewporter.xml | 189 +++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 stable/viewporter/README
create mode 100644 stable/viewporter/viewporter.xml
For landing these 5 wayland-protocol patches, either as stable or
Recorded.
Hi,
cc276df..83bdaa5 master -> master
Now we just need a wayland-protocols release. We should have a couple
of days for the last minute "oops" just in case.
Post by Pekka Paalanen
Post by Bryce Harrington
Post by Bryce Harrington
Post by Pekka Paalanen
compositor: constify weston_surface_build_buffer_matrix()
compositor: refactor into convert_size_by_transform_scale()
compositor: migrate to stable viewporter.xml
compositor: rename scaler to viewport(er)
clients/scaler: migrate to wp_viewporter
clients/simple-damage: migrate to wp_viewporter
protocol: remove scaler.xml
compositor: fix wp_viewport use after free
compositor: check viewport source rect validity
compositor: check viewport dst size validity
compositor: fix wp_viewport.set_source errors
tests: add wp_viewporter tests
The first two patches in this set don't depend on the protocol and look
fine to land during beta. The rest I'm not sure about, they're a bit
more than a mere rename of the protocol and add functionality. I don't
have anything against them but wouldn't want to land them on my R-b
alone, and unless they're particularly urgent it would be much more
comfortable to land them post-release. I reviewed all the patches and
aside from the nitpicks already mentioned, for purposes of landing post
Recorded.
Yes, they missed 1.11 now, will be for 1.12, expect the first two I
already pushed with your reviews.
This still holds, weston patches won't land until 1.11 is out.
Hi all,
patches 8 - 17 are still in the queue. They apply to master today as
is, the only thing I think that needs fixing is to update the
wayland-protocols dependency, IIRC.
Hmm, Yong, did you give R-b for pathes 8-17? I'm not quite sure if "v3
is Reviewed-by" means that.
Anyone else want to ack/nack?
If no-one replies, I'll push these patches on, say, Thursday with both
Yong and Bryce R-b.
Hi,

hmm, Yong didn't reply yet, so I didn't add his R-b to all patches,
since I wasn't sure.

All the remaining patches of the viewporter work so far are pushed:
0de859e..82d95a6 master -> master


Thanks,
pq

Loading...