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