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