| 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, see wl_surface.commit. |
| 75 | |
| 76 | The two parts of crop and scale state are independent: the source |
| 77 | rectangle, and the destination size. Initially both are unset, that |
| 78 | is, no scaling is applied. The whole of the current wl_buffer is |
| 79 | used as the source, and the surface size is as defined in |
| 80 | wl_surface.attach. |
| 81 | |
| 82 | If the destination size is set, it causes the surface size to become |
| 83 | dst_width, dst_height. The source (rectangle) is scaled to exactly |
| 84 | this size. This overrides whatever the attached wl_buffer size is, |
| 85 | unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface |
| 86 | has no content and therefore no size. Otherwise, the size is always |
| 87 | at least 1x1 in surface local coordinates. |
| 88 | |
| 89 | If the source rectangle is set, it defines what area of the wl_buffer is |
| 90 | taken as the source. If the source rectangle is set and the destination |
| 91 | size is not set, then src_width and src_height must be integers, and the |
| 92 | surface size becomes the source rectangle size. This results in cropping |
| 93 | without scaling. If src_width or src_height are not integers and |
| 94 | destination size is not set, the bad_size protocol error is raised when |
| 95 | the surface state is applied. |
| 96 | |
| 97 | The coordinate transformations from buffer pixel coordinates up to |
| 98 | the surface-local coordinates happen in the following order: |
| 99 | 1. buffer_transform (wl_surface.set_buffer_transform) |
| 100 | 2. buffer_scale (wl_surface.set_buffer_scale) |
| 101 | 3. crop and scale (wp_viewport.set*) |
| 102 | This means, that the source rectangle coordinates of crop and scale |
| 103 | are given in the coordinates after the buffer transform and scale, |
| 104 | i.e. in the coordinates that would be the surface-local coordinates |
| 105 | if the crop and scale was not applied. |
| 106 | |
| 107 | If src_x or src_y are negative, the bad_value protocol error is raised. |
| 108 | Otherwise, if the source rectangle is partially or completely outside of |
| 109 | the non-NULL wl_buffer, then the out_of_buffer protocol error is raised |
| 110 | when the surface state is applied. A NULL wl_buffer does not raise the |
| 111 | out_of_buffer error. |
| 112 | |
| 113 | If the wl_surface associated with the wp_viewport is destroyed, |
| 114 | all wp_viewport requests except 'destroy' raise the protocol error |
| 115 | no_surface. |
| 116 | |
| 117 | If the wp_viewport object is destroyed, the crop and scale |
| 118 | state is removed from the wl_surface. The change will be applied |
| 119 | on the next wl_surface.commit. |
| 120 | </description> |
| 121 | |
| 122 | <request name="destroy" type="destructor"> |
| 123 | <description summary="remove scaling and cropping from the surface"> |
| 124 | The associated wl_surface's crop and scale state is removed. |
| 125 | The change is applied on the next wl_surface.commit. |
| 126 | </description> |
| 127 | </request> |
| 128 | |
| 129 | <enum name="error"> |
| 130 | <entry name="bad_value" value="0" |
| 131 | summary="negative or zero values in width or height"/> |
| 132 | <entry name="bad_size" value="1" |
| 133 | summary="destination size is not integer"/> |
| 134 | <entry name="out_of_buffer" value="2" |
| 135 | summary="source rectangle extends outside of the content area"/> |
| 136 | <entry name="no_surface" value="3" |
| 137 | summary="the wl_surface was destroyed"/> |
| 138 | </enum> |
| 139 | |
| 140 | <request name="set_source"> |
| 141 | <description summary="set the source rectangle for cropping"> |
| 142 | Set the source rectangle of the associated wl_surface. See |
| 143 | wp_viewport for the description, and relation to the wl_buffer |
| 144 | size. |
| 145 | |
| 146 | If all of x, y, width and height are -1.0, the source rectangle is |
| 147 | unset instead. Any other set of values where width or height are zero |
| 148 | or negative, or x or y are negative, raise the bad_value protocol |
| 149 | error. |
| 150 | |
| 151 | The crop and scale state is double-buffered, see wl_surface.commit. |
| 152 | </description> |
| 153 | <arg name="x" type="fixed" summary="source rectangle x"/> |
| 154 | <arg name="y" type="fixed" summary="source rectangle y"/> |
| 155 | <arg name="width" type="fixed" summary="source rectangle width"/> |
| 156 | <arg name="height" type="fixed" summary="source rectangle height"/> |
| 157 | </request> |
| 158 | |
| 159 | <request name="set_destination"> |
| 160 | <description summary="set the surface size for scaling"> |
| 161 | Set the destination size of the associated wl_surface. See |
| 162 | wp_viewport for the description, and relation to the wl_buffer |
| 163 | size. |
| 164 | |
| 165 | If width is -1 and height is -1, the destination size is unset |
| 166 | instead. Any other pair of values for width and height that |
| 167 | contains zero or negative values raises the bad_value protocol |
| 168 | error. |
| 169 | |
| 170 | The crop and scale state is double-buffered, see wl_surface.commit. |
| 171 | </description> |
| 172 | <arg name="width" type="int" summary="surface width"/> |
| 173 | <arg name="height" type="int" summary="surface height"/> |
| 174 | </request> |
| 175 | </interface> |
| 176 | |
| 177 | </protocol> |