| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<protocol name="viewporter"> |
| 3 |
|
| 4 |
<copyright> |
| 5 |
Copyright © 2013-2016 Collabora, Ltd. |
| 6 |
|
| 7 |
Permission is hereby granted, free of charge, to any person obtaining a |
| 8 |
copy of this software and associated documentation files (the "Software"), |
| 9 |
to deal in the Software without restriction, including without limitation |
| 10 |
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 |
and/or sell copies of the Software, and to permit persons to whom the |
| 12 |
Software is furnished to do so, subject to the following conditions: |
| 13 |
|
| 14 |
The above copyright notice and this permission notice (including the next |
| 15 |
paragraph) shall be included in all copies or substantial portions of the |
| 16 |
Software. |
| 17 |
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 |
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 24 |
DEALINGS IN THE SOFTWARE. |
| 25 |
</copyright> |
| 26 |
|
| 27 |
<interface name="wp_viewporter" version="1"> |
| 28 |
<description summary="surface cropping and scaling"> |
| 29 |
The global interface exposing surface cropping and scaling |
| 30 |
capabilities is used to instantiate an interface extension for a |
| 31 |
wl_surface object. This extended interface will then allow |
| 32 |
cropping and scaling the surface contents, effectively |
| 33 |
disconnecting the direct relationship between the buffer and the |
| 34 |
surface size. |
| 35 |
</description> |
| 36 |
|
| 37 |
<request name="destroy" type="destructor"> |
| 38 |
<description summary="unbind from the cropping and scaling interface"> |
| 39 |
Informs the server that the client will not be using this |
| 40 |
protocol object anymore. This does not affect any other objects, |
| 41 |
wp_viewport objects included. |
| 42 |
</description> |
| 43 |
</request> |
| 44 |
|
| 45 |
<enum name="error"> |
| 46 |
<entry name="viewport_exists" value="0" |
| 47 |
summary="the surface already has a viewport object associated"/> |
| 48 |
</enum> |
| 49 |
|
| 50 |
<request name="get_viewport"> |
| 51 |
<description summary="extend surface interface for crop and scale"> |
| 52 |
Instantiate an interface extension for the given wl_surface to |
| 53 |
crop and scale its content. If the given wl_surface already has |
| 54 |
a wp_viewport object associated, the viewport_exists |
| 55 |
protocol error is raised. |
| 56 |
</description> |
| 57 |
<arg name="id" type="new_id" interface="wp_viewport" |
| 58 |
summary="the new viewport interface id"/> |
| 59 |
<arg name="surface" type="object" interface="wl_surface" |
| 60 |
summary="the surface"/> |
| 61 |
</request> |
| 62 |
</interface> |
| 63 |
|
| 64 |
<interface name="wp_viewport" version="1"> |
| 65 |
<description summary="crop and scale interface to a wl_surface"> |
| 66 |
An additional interface to a wl_surface object, which allows the |
| 67 |
client to specify the cropping and scaling of the surface |
| 68 |
contents. |
| 69 |
|
| 70 |
This interface works with two concepts: the source rectangle (src_x, |
| 71 |
src_y, src_width, src_height), and the destination size (dst_width, |
| 72 |
dst_height). The contents of the source rectangle are scaled to the |
| 73 |
destination size, and content outside the source rectangle is ignored. |
| 74 |
This state is double-buffered, and is applied on the next |
| 75 |
wl_surface.commit. |
| 76 |
|
| 77 |
The two parts of crop and scale state are independent: the source |
| 78 |
rectangle, and the destination size. Initially both are unset, that |
| 79 |
is, no scaling is applied. The whole of the current wl_buffer is |
| 80 |
used as the source, and the surface size is as defined in |
| 81 |
wl_surface.attach. |
| 82 |
|
| 83 |
If the destination size is set, it causes the surface size to become |
| 84 |
dst_width, dst_height. The source (rectangle) is scaled to exactly |
| 85 |
this size. This overrides whatever the attached wl_buffer size is, |
| 86 |
unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface |
| 87 |
has no content and therefore no size. Otherwise, the size is always |
| 88 |
at least 1x1 in surface local coordinates. |
| 89 |
|
| 90 |
If the source rectangle is set, it defines what area of the wl_buffer is |
| 91 |
taken as the source. If the source rectangle is set and the destination |
| 92 |
size is not set, then src_width and src_height must be integers, and the |
| 93 |
surface size becomes the source rectangle size. This results in cropping |
| 94 |
without scaling. If src_width or src_height are not integers and |
| 95 |
destination size is not set, the bad_size protocol error is raised when |
| 96 |
the surface state is applied. |
| 97 |
|
| 98 |
The coordinate transformations from buffer pixel coordinates up to |
| 99 |
the surface-local coordinates happen in the following order: |
| 100 |
1. buffer_transform (wl_surface.set_buffer_transform) |
| 101 |
2. buffer_scale (wl_surface.set_buffer_scale) |
| 102 |
3. crop and scale (wp_viewport.set*) |
| 103 |
This means, that the source rectangle coordinates of crop and scale |
| 104 |
are given in the coordinates after the buffer transform and scale, |
| 105 |
i.e. in the coordinates that would be the surface-local coordinates |
| 106 |
if the crop and scale was not applied. |
| 107 |
|
| 108 |
If src_x or src_y are negative, the bad_value protocol error is raised. |
| 109 |
Otherwise, if the source rectangle is partially or completely outside of |
| 110 |
the non-NULL wl_buffer, then the out_of_buffer protocol error is raised |
| 111 |
when the surface state is applied. A NULL wl_buffer does not raise the |
| 112 |
out_of_buffer error. |
| 113 |
|
| 114 |
If the wl_surface associated with the wp_viewport is destroyed, |
| 115 |
all wp_viewport requests except 'destroy' raise the protocol error |
| 116 |
no_surface. |
| 117 |
|
| 118 |
If the wp_viewport object is destroyed, the crop and scale |
| 119 |
state is removed from the wl_surface. The change will be applied |
| 120 |
on the next wl_surface.commit. |
| 121 |
</description> |
| 122 |
|
| 123 |
<request name="destroy" type="destructor"> |
| 124 |
<description summary="remove scaling and cropping from the surface"> |
| 125 |
The associated wl_surface's crop and scale state is removed. |
| 126 |
The change is applied on the next wl_surface.commit. |
| 127 |
</description> |
| 128 |
</request> |
| 129 |
|
| 130 |
<enum name="error"> |
| 131 |
<entry name="bad_value" value="0" |
| 132 |
summary="negative or zero values in width or height"/> |
| 133 |
<entry name="bad_size" value="1" |
| 134 |
summary="destination size is not integer"/> |
| 135 |
<entry name="out_of_buffer" value="2" |
| 136 |
summary="source rectangle extends outside of the content area"/> |
| 137 |
<entry name="no_surface" value="3" |
| 138 |
summary="the wl_surface was destroyed"/> |
| 139 |
</enum> |
| 140 |
|
| 141 |
<request name="set_source"> |
| 142 |
<description summary="set the source rectangle for cropping"> |
| 143 |
Set the source rectangle of the associated wl_surface. See |
| 144 |
wp_viewport for the description, and relation to the wl_buffer |
| 145 |
size. |
| 146 |
|
| 147 |
If all of x, y, width and height are -1.0, the source rectangle is |
| 148 |
unset instead. Any other set of values where width or height are zero |
| 149 |
or negative, or x or y are negative, raise the bad_value protocol |
| 150 |
error. |
| 151 |
|
| 152 |
The crop and scale state is double-buffered state, and will be |
| 153 |
applied on the next wl_surface.commit. |
| 154 |
</description> |
| 155 |
<arg name="x" type="fixed" summary="source rectangle x"/> |
| 156 |
<arg name="y" type="fixed" summary="source rectangle y"/> |
| 157 |
<arg name="width" type="fixed" summary="source rectangle width"/> |
| 158 |
<arg name="height" type="fixed" summary="source rectangle height"/> |
| 159 |
</request> |
| 160 |
|
| 161 |
<request name="set_destination"> |
| 162 |
<description summary="set the surface size for scaling"> |
| 163 |
Set the destination size of the associated wl_surface. See |
| 164 |
wp_viewport for the description, and relation to the wl_buffer |
| 165 |
size. |
| 166 |
|
| 167 |
If width is -1 and height is -1, the destination size is unset |
| 168 |
instead. Any other pair of values for width and height that |
| 169 |
contains zero or negative values raises the bad_value protocol |
| 170 |
error. |
| 171 |
|
| 172 |
The crop and scale state is double-buffered state, and will be |
| 173 |
applied on the next wl_surface.commit. |
| 174 |
</description> |
| 175 |
<arg name="width" type="int" summary="surface width"/> |
| 176 |
<arg name="height" type="int" summary="surface height"/> |
| 177 |
</request> |
| 178 |
</interface> |
| 179 |
|
| 180 |
</protocol> |