| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright © 2013-2014 Collabora, Ltd. | |
| 3 * | |
| 4 * Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 * copy of this software and associated documentation files (the "Software"), | |
| 6 * to deal in the Software without restriction, including without limitation | |
| 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| 8 * and/or sell copies of the Software, and to permit persons to whom the | |
| 9 * Software is furnished to do so, subject to the following conditions: | |
| 10 * | |
| 11 * The above copyright notice and this permission notice (including the next | |
| 12 * paragraph) shall be included in all copies or substantial portions of the | |
| 13 * Software. | |
| 14 * | |
| 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
| 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 21 * DEALINGS IN THE SOFTWARE. | |
| 22 */ | |
| 23 | |
| 24 #ifndef SCALER_SERVER_PROTOCOL_H | |
| 25 #define SCALER_SERVER_PROTOCOL_H | |
| 26 | |
| 27 #ifdef __cplusplus | |
| 28 extern "C" { | |
| 29 #endif | |
| 30 | |
| 31 #include <stdint.h> | |
| 32 #include <stddef.h> | |
| 33 #include "wayland-server.h" | |
| 34 | |
| 35 struct wl_client; | |
| 36 struct wl_resource; | |
| 37 | |
| 38 struct wl_scaler; | |
| 39 struct wl_surface; | |
| 40 struct wl_viewport; | |
| 41 | |
| 42 extern const struct wl_interface wl_scaler_interface; | |
| 43 extern const struct wl_interface wl_viewport_interface; | |
| 44 | |
| 45 #ifndef WL_SCALER_ERROR_ENUM | |
| 46 #define WL_SCALER_ERROR_ENUM | |
| 47 enum wl_scaler_error { | |
| 48 WL_SCALER_ERROR_VIEWPORT_EXISTS = 0, | |
| 49 }; | |
| 50 #endif /* WL_SCALER_ERROR_ENUM */ | |
| 51 | |
| 52 /** | |
| 53 * wl_scaler - surface cropping and scaling | |
| 54 * @destroy: unbind from the cropping and scaling interface | |
| 55 * @get_viewport: extend surface interface for crop and scale | |
| 56 * | |
| 57 * The global interface exposing surface cropping and scaling | |
| 58 * capabilities is used to instantiate an interface extension for a | |
| 59 * wl_surface object. This extended interface will then allow cropping and | |
| 60 * scaling the surface contents, effectively disconnecting the direct | |
| 61 * relationship between the buffer and the surface size. | |
| 62 */ | |
| 63 struct wl_scaler_interface { | |
| 64 /** | |
| 65 * destroy - unbind from the cropping and scaling interface | |
| 66 * | |
| 67 * Informs the server that the client will not be using this | |
| 68 * protocol object anymore. This does not affect any other objects, | |
| 69 * wl_viewport objects included. | |
| 70 */ | |
| 71 void (*destroy)(struct wl_client *client, | |
| 72 struct wl_resource *resource); | |
| 73 /** | |
| 74 * get_viewport - extend surface interface for crop and scale | |
| 75 * @id: the new viewport interface id | |
| 76 * @surface: the surface | |
| 77 * | |
| 78 * Instantiate an interface extension for the given wl_surface to | |
| 79 * crop and scale its content. If the given wl_surface already has | |
| 80 * a wl_viewport object associated, the viewport_exists protocol | |
| 81 * error is raised. | |
| 82 */ | |
| 83 void (*get_viewport)(struct wl_client *client, | |
| 84 struct wl_resource *resource, | |
| 85 uint32_t id, | |
| 86 struct wl_resource *surface); | |
| 87 }; | |
| 88 | |
| 89 | |
| 90 #ifndef WL_VIEWPORT_ERROR_ENUM | |
| 91 #define WL_VIEWPORT_ERROR_ENUM | |
| 92 enum wl_viewport_error { | |
| 93 WL_VIEWPORT_ERROR_BAD_VALUE = 0, | |
| 94 }; | |
| 95 #endif /* WL_VIEWPORT_ERROR_ENUM */ | |
| 96 | |
| 97 /** | |
| 98 * wl_viewport - crop and scale interface to a wl_surface | |
| 99 * @destroy: remove scaling and cropping from the surface | |
| 100 * @set: set the crop and scale state | |
| 101 * @set_source: set the source rectangle for cropping | |
| 102 * @set_destination: set the surface size for scaling | |
| 103 * | |
| 104 * An additional interface to a wl_surface object, which allows the | |
| 105 * client to specify the cropping and scaling of the surface contents. | |
| 106 * | |
| 107 * This interface allows to define the source rectangle (src_x, src_y, | |
| 108 * src_width, src_height) from where to take the wl_buffer contents, and | |
| 109 * scale that to destination size (dst_width, dst_height). This state is | |
| 110 * double-buffered, and is applied on the next wl_surface.commit. | |
| 111 * | |
| 112 * The two parts of crop and scale state are independent: the source | |
| 113 * rectangle, and the destination size. Initially both are unset, that is, | |
| 114 * no scaling is applied. The whole of the current wl_buffer is used as the | |
| 115 * source, and the surface size is as defined in wl_surface.attach. | |
| 116 * | |
| 117 * If the destination size is set, it causes the surface size to become | |
| 118 * dst_width, dst_height. The source (rectangle) is scaled to exactly this | |
| 119 * size. This overrides whatever the attached wl_buffer size is, unless the | |
| 120 * wl_buffer is NULL. If the wl_buffer is NULL, the surface has no content | |
| 121 * and therefore no size. Otherwise, the size is always at least 1x1 in | |
| 122 * surface coordinates. | |
| 123 * | |
| 124 * If the source rectangle is set, it defines what area of the wl_buffer is | |
| 125 * taken as the source. If the source rectangle is set and the destination | |
| 126 * size is not set, the surface size becomes the source rectangle size | |
| 127 * rounded up to the nearest integer. If the source size is already exactly | |
| 128 * integers, this results in cropping without scaling. | |
| 129 * | |
| 130 * The coordinate transformations from buffer pixel coordinates up to the | |
| 131 * surface-local coordinates happen in the following order: 1. | |
| 132 * buffer_transform (wl_surface.set_buffer_transform) 2. buffer_scale | |
| 133 * (wl_surface.set_buffer_scale) 3. crop and scale (wl_viewport.set*) This | |
| 134 * means, that the source rectangle coordinates of crop and scale are given | |
| 135 * in the coordinates after the buffer transform and scale, i.e. in the | |
| 136 * coordinates that would be the surface-local coordinates if the crop and | |
| 137 * scale was not applied. | |
| 138 * | |
| 139 * If the source rectangle is partially or completely outside of the | |
| 140 * wl_buffer, then the surface contents are undefined (not void), and the | |
| 141 * surface size is still dst_width, dst_height. | |
| 142 * | |
| 143 * The x, y arguments of wl_surface.attach are applied as normal to the | |
| 144 * surface. They indicate how many pixels to remove from the surface size | |
| 145 * from the left and the top. In other words, they are still in the | |
| 146 * surface-local coordinate system, just like dst_width and dst_height are. | |
| 147 * | |
| 148 * If the wl_surface associated with the wl_viewport is destroyed, the | |
| 149 * wl_viewport object becomes inert. | |
| 150 * | |
| 151 * If the wl_viewport object is destroyed, the crop and scale state is | |
| 152 * removed from the wl_surface. The change will be applied on the next | |
| 153 * wl_surface.commit. | |
| 154 */ | |
| 155 struct wl_viewport_interface { | |
| 156 /** | |
| 157 * destroy - remove scaling and cropping from the surface | |
| 158 * | |
| 159 * The associated wl_surface's crop and scale state is removed. | |
| 160 * The change is applied on the next wl_surface.commit. | |
| 161 */ | |
| 162 void (*destroy)(struct wl_client *client, | |
| 163 struct wl_resource *resource); | |
| 164 /** | |
| 165 * set - set the crop and scale state | |
| 166 * @src_x: source rectangle x | |
| 167 * @src_y: source rectangle y | |
| 168 * @src_width: source rectangle width | |
| 169 * @src_height: source rectangle height | |
| 170 * @dst_width: surface width | |
| 171 * @dst_height: surface height | |
| 172 * | |
| 173 * Set both source rectangle and destination size of the | |
| 174 * associated wl_surface. See wl_viewport for the description, and | |
| 175 * relation to the wl_buffer size. | |
| 176 * | |
| 177 * The bad_value protocol error is raised if src_width or | |
| 178 * src_height is negative, or if dst_width or dst_height is not | |
| 179 * positive. | |
| 180 * | |
| 181 * The crop and scale state is double-buffered state, and will be | |
| 182 * applied on the next wl_surface.commit. | |
| 183 * | |
| 184 * Arguments dst_x and dst_y do not exist here, use the x and y | |
| 185 * arguments to wl_surface.attach. The x, y, dst_width, and | |
| 186 * dst_height define the surface-local coordinate system | |
| 187 * irrespective of the attached wl_buffer size. | |
| 188 */ | |
| 189 void (*set)(struct wl_client *client, | |
| 190 struct wl_resource *resource, | |
| 191 wl_fixed_t src_x, | |
| 192 wl_fixed_t src_y, | |
| 193 wl_fixed_t src_width, | |
| 194 wl_fixed_t src_height, | |
| 195 int32_t dst_width, | |
| 196 int32_t dst_height); | |
| 197 /** | |
| 198 * set_source - set the source rectangle for cropping | |
| 199 * @x: source rectangle x | |
| 200 * @y: source rectangle y | |
| 201 * @width: source rectangle width | |
| 202 * @height: source rectangle height | |
| 203 * | |
| 204 * Set the source rectangle of the associated wl_surface. See | |
| 205 * wl_viewport for the description, and relation to the wl_buffer | |
| 206 * size. | |
| 207 * | |
| 208 * If width is -1.0 and height is -1.0, the source rectangle is | |
| 209 * unset instead. Any other pair of values for width and height | |
| 210 * that contains zero or negative values raises the bad_value | |
| 211 * protocol error. | |
| 212 * | |
| 213 * The crop and scale state is double-buffered state, and will be | |
| 214 * applied on the next wl_surface.commit. | |
| 215 * @since: 2 | |
| 216 */ | |
| 217 void (*set_source)(struct wl_client *client, | |
| 218 struct wl_resource *resource, | |
| 219 wl_fixed_t x, | |
| 220 wl_fixed_t y, | |
| 221 wl_fixed_t width, | |
| 222 wl_fixed_t height); | |
| 223 /** | |
| 224 * set_destination - set the surface size for scaling | |
| 225 * @width: surface width | |
| 226 * @height: surface height | |
| 227 * | |
| 228 * Set the destination size of the associated wl_surface. See | |
| 229 * wl_viewport for the description, and relation to the wl_buffer | |
| 230 * size. | |
| 231 * | |
| 232 * If width is -1 and height is -1, the destination size is unset | |
| 233 * instead. Any other pair of values for width and height that | |
| 234 * contains zero or negative values raises the bad_value protocol | |
| 235 * error. | |
| 236 * | |
| 237 * The crop and scale state is double-buffered state, and will be | |
| 238 * applied on the next wl_surface.commit. | |
| 239 * | |
| 240 * Arguments x and y do not exist here, use the x and y arguments | |
| 241 * to wl_surface.attach. The x, y, width, and height define the | |
| 242 * surface-local coordinate system irrespective of the attached | |
| 243 * wl_buffer size. | |
| 244 * @since: 2 | |
| 245 */ | |
| 246 void (*set_destination)(struct wl_client *client, | |
| 247 struct wl_resource *resource, | |
| 248 int32_t width, | |
| 249 int32_t height); | |
| 250 }; | |
| 251 | |
| 252 | |
| 253 #ifdef __cplusplus | |
| 254 } | |
| 255 #endif | |
| 256 | |
| 257 #endif | |
| OLD | NEW |