1 <?xml version="1.0" encoding="UTF-8"?>
2 <protocol name="scaler">
5 Copyright © 2013-2014 Collabora, Ltd.
7 Permission to use, copy, modify, distribute, and sell this
8 software and its documentation for any purpose is hereby granted
9 without fee, provided that the above copyright notice appear in
10 all copies and that both that copyright notice and this permission
11 notice appear in supporting documentation, and that the name of
12 the copyright holders not be used in advertising or publicity
13 pertaining to distribution of the software without specific,
14 written prior permission. The copyright holders make no
15 representations about the suitability of this software for any
16 purpose. It is provided "as is" without express or implied
19 THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
29 <interface name="wl_scaler" version="2">
30 <description summary="surface cropping and scaling">
31 The global interface exposing surface cropping and scaling
32 capabilities is used to instantiate an interface extension for a
33 wl_surface object. This extended interface will then allow
34 cropping and scaling the surface contents, effectively
35 disconnecting the direct relationship between the buffer and the
39 <request name="destroy" type="destructor">
40 <description summary="unbind from the cropping and scaling interface">
41 Informs the server that the client will not be using this
42 protocol object anymore. This does not affect any other objects,
43 wl_viewport objects included.
48 <entry name="viewport_exists" value="0"
49 summary="the surface already has a viewport object associated"/>
52 <request name="get_viewport">
53 <description summary="extend surface interface for crop and scale">
54 Instantiate an interface extension for the given wl_surface to
55 crop and scale its content. If the given wl_surface already has
56 a wl_viewport object associated, the viewport_exists
57 protocol error is raised.
60 <arg name="id" type="new_id" interface="wl_viewport"
61 summary="the new viewport interface id"/>
62 <arg name="surface" type="object" interface="wl_surface"
63 summary="the surface"/>
67 <interface name="wl_viewport" version="2">
68 <description summary="crop and scale interface to a wl_surface">
69 An additional interface to a wl_surface object, which allows the
70 client to specify the cropping and scaling of the surface
73 This interface allows to define the source rectangle (src_x,
74 src_y, src_width, src_height) from where to take the wl_buffer
75 contents, and scale that to destination size (dst_width,
76 dst_height). This state is double-buffered, and is applied on the
77 next wl_surface.commit.
79 The two parts of crop and scale state are independent: the source
80 rectangle, and the destination size. Initially both are unset, that
81 is, no scaling is applied. The whole of the current wl_buffer is
82 used as the source, and the surface size is as defined in
85 If the destination size is set, it causes the surface size to become
86 dst_width, dst_height. The source (rectangle) is scaled to exactly
87 this size. This overrides whatever the attached wl_buffer size is,
88 unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
89 has no content and therefore no size. Otherwise, the size is always
90 at least 1x1 in surface coordinates.
92 If the source rectangle is set, it defines what area of the
93 wl_buffer is taken as the source. If the source rectangle is set and
94 the destination size is not set, the surface size becomes the source
95 rectangle size rounded up to the nearest integer. If the source size
96 is already exactly integers, this results in cropping without scaling.
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 (wl_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.
108 If the source rectangle is partially or completely outside of the
109 wl_buffer, then the surface contents are undefined (not void), and
110 the surface size is still dst_width, dst_height.
112 The x, y arguments of wl_surface.attach are applied as normal to
113 the surface. They indicate how many pixels to remove from the
114 surface size from the left and the top. In other words, they are
115 still in the surface-local coordinate system, just like dst_width
118 If the wl_surface associated with the wl_viewport is destroyed,
119 the wl_viewport object becomes inert.
121 If the wl_viewport object is destroyed, the crop and scale
122 state is removed from the wl_surface. The change will be applied
123 on the next wl_surface.commit.
126 <request name="destroy" type="destructor">
127 <description summary="remove scaling and cropping from the surface">
128 The associated wl_surface's crop and scale state is removed.
129 The change is applied on the next wl_surface.commit.
134 <entry name="bad_value" value="0"
135 summary="negative or zero values in width or height"/>
139 <description summary="set the crop and scale state">
140 Set both source rectangle and destination size of the associated
141 wl_surface. See wl_viewport for the description, and relation to
144 The bad_value protocol error is raised if src_width or
145 src_height is negative, or if dst_width or dst_height is not
148 The crop and scale state is double-buffered state, and will be
149 applied on the next wl_surface.commit.
151 Arguments dst_x and dst_y do not exist here, use the x and y
152 arguments to wl_surface.attach. The x, y, dst_width, and dst_height
153 define the surface-local coordinate system irrespective of the
154 attached wl_buffer size.
157 <arg name="src_x" type="fixed" summary="source rectangle x"/>
158 <arg name="src_y" type="fixed" summary="source rectangle y"/>
159 <arg name="src_width" type="fixed" summary="source rectangle width"/>
160 <arg name="src_height" type="fixed" summary="source rectangle height"/>
161 <arg name="dst_width" type="int" summary="surface width"/>
162 <arg name="dst_height" type="int" summary="surface height"/>
165 <request name="set_source" since="2">
166 <description summary="set the source rectangle for cropping">
167 Set the source rectangle of the associated wl_surface. See
168 wl_viewport for the description, and relation to the wl_buffer
171 If width is -1.0 and height is -1.0, the source rectangle is unset
172 instead. Any other pair of values for width and height that
173 contains zero or negative values raises the bad_value protocol
176 The crop and scale state is double-buffered state, and will be
177 applied on the next wl_surface.commit.
180 <arg name="x" type="fixed" summary="source rectangle x"/>
181 <arg name="y" type="fixed" summary="source rectangle y"/>
182 <arg name="width" type="fixed" summary="source rectangle width"/>
183 <arg name="height" type="fixed" summary="source rectangle height"/>
186 <request name="set_destination" since="2">
187 <description summary="set the surface size for scaling">
188 Set the destination size of the associated wl_surface. See
189 wl_viewport for the description, and relation to the wl_buffer
192 If width is -1 and height is -1, the destination size is unset
193 instead. Any other pair of values for width and height that
194 contains zero or negative values raises the bad_value protocol
197 The crop and scale state is double-buffered state, and will be
198 applied on the next wl_surface.commit.
200 Arguments x and y do not exist here, use the x and y arguments to
201 wl_surface.attach. The x, y, width, and height define the
202 surface-local coordinate system irrespective of the attached
206 <arg name="width" type="int" summary="surface width"/>
207 <arg name="height" type="int" summary="surface height"/>