<div dir="ltr"><div>I'd say we should split the cropping and scaling request into two.<br></div><div><br></div><div>Specifying a scaling with a NULL buffer should still set the surface size, so we can have surfaces with only an input region.</div>
<div><br></div><div>I don't see a way to disable scaling and cropping, could passing 0 as width and height do that?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 30, 2013 at 2:33 PM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
below is my first draft for a wl_surface scaling and cropping<br>
extension. I called it wl_scaler in the lack of a better name. It is<br>
designed similarly to the other wl_surface extensions wl_shell_surface<br>
and wl_subsurface.<br>
<br>
There probably isn't any interesting details to debate, right? ;-)<br>
<br>
I'd like to have a better name for it, and you might want the set<br>
request split into two or three, or not, but otherwise I'm quite<br>
satisfied with it. I tried to take into account all existing protocol<br>
that interacts with this.<br>
<br>
Comments? Is the language clear?<br>
<br>
<br>
Thanks,<br>
pq<br>
<br>
<br>
<?xml version="1.0" encoding="UTF-8"?><br>
<protocol name="scaler"><br>
<br>
<copyright><br>
Copyright © 2013 Collabora, Ltd.<br>
<br>
Permission to use, copy, modify, distribute, and sell this<br>
software and its documentation for any purpose is hereby granted<br>
without fee, provided that the above copyright notice appear in<br>
all copies and that both that copyright notice and this permission<br>
notice appear in supporting documentation, and that the name of<br>
the copyright holders not be used in advertising or publicity<br>
pertaining to distribution of the software without specific,<br>
written prior permission. The copyright holders make no<br>
representations about the suitability of this software for any<br>
purpose. It is provided "as is" without express or implied<br>
warranty.<br>
<br>
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS<br>
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES<br>
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN<br>
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,<br>
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF<br>
THIS SOFTWARE.<br>
</copyright><br>
<br>
<interface name="wl_scaler" version="1"><br>
<description summary="surface cropping and scaling"><br>
The global interface exposing surface cropping and scaling<br>
capabilities is used to instantiate an interface extension for a<br>
wl_surface object. This extended interface will then allow<br>
cropping and scaling the surface contents, effectively<br>
disconnecting the 1:1 relationship between the buffer and the<br>
surface size.<br>
</description><br>
<br>
<request name="destroy" type="destructor"><br>
<description summary="unbind from the cropping and scaling interface"><br>
Informs the server that the client will not be using this<br>
protocol object anymore. This does not affect any other objects,<br>
wl_surface_scaler objects included.<br>
</description><br>
</request><br>
<br>
<enum name="error"><br>
<entry name="scaler_exists" value="0"<br>
summary="the surface already has a scaler object associated"/><br>
</enum><br>
<br>
<request name="get_surface_scaler"><br>
<description summary="extend surface interface for crop and scale"><br>
Instantiate an interface extension for the given wl_surface to<br>
crop and scale its content. If the given wl_surface already has<br>
a wl_surface_scaler object associated, the scaler_exists<br>
protocol error is raised.<br>
</description><br>
<br>
<arg name="id" type="new_id" interface="wl_surface_scaler"<br>
summary="the new scaler interface id"/><br>
<arg name="surface" type="object" interface="wl_surface"<br>
summary="the surface"/><br>
</request><br>
</interface><br>
<br>
<interface name="wl_surface_scaler" version="1"><br>
<description summary="crop and scale interface to a wl_surface"><br>
An additional interface to a wl_surface object, allowing cropping<br>
and scaling of the surface contents.<br>
<br>
This interface allows to define the source rectangle (src_x,<br>
src_y, src_width, src_height) from where to take the wl_buffer<br>
contents, and scale that to destination size (dst_width,<br>
dst_height). This state is double-buffered, and is applied on the<br>
next wl_surface.commit.<br>
<br>
Before the first set request, the wl_surface still behaves as if<br>
there was no crop and scale state. That is, no scaling is applied,<br>
and the surface size is the buffer size.<br>
<br>
On compositing, source rectangle coordinates are evaluated after<br>
wl_surface.set_buffer_transform is evaluated. This means that<br>
changing the buffer transform and correspondingly the client<br>
rendering does not require sending new source rectangle<br>
coordinates to keep the exact same image source rectangle. In<br>
other words, the source rectangle is given in the<br>
not-scaled-and-cropped surface coordinates, not buffer data<br>
coordinates.<br>
<br>
The crop and scale state causes the surface size to become<br>
dst_width, dst_height. This overrides whatever the attached<br>
wl_buffer size is, unless the wl_buffer is NULL.<br>
<br>
The surface-local coordinate system is tied to the space of<br>
dst_width and dst_height. That is, surface-local coordinates are<br>
relative to the scaled and cropped surface, not the wl_buffer<br>
providing the content.<br>
<br>
If the source rectangle is partially or completely outside of the<br>
wl_buffer, then the surface contents are undefined, and the<br>
surface size is still dst_width, dst_height.<br>
<br>
The x, y arguments of wl_surface.attach are applied as normal to<br>
the surface. They indicate how many pixels to remove from the<br>
surface size from the left and the top. In other words, they are<br>
still in the surface-local coordinate system, just like dst_width<br>
and dst_height are.<br>
<br>
If the wl_surface associated with the wl_surface_scaler is<br>
destroyed, the wl_surface_scaler object becomes inert.<br>
<br>
If the wl_surface_scaler object is destroyed, the crop and scale<br>
state is removed from the wl_surface. The change will be applied<br>
on the next wl_surface.commit.<br>
</description><br>
<br>
<request name="destroy" type="destructor"><br>
<description summary="remove scaling and cropping from the surface"><br>
The associated wl_surface's crop and scale state is removed.<br>
The change is applied on the next wl_surface.commit.<br>
</description><br>
</request><br>
<br>
<enum name="error"><br>
<entry name="bad_value" value="0"<br>
summary="negative values in width or height"/><br>
</enum><br>
<br>
<request name="set"><br>
<description summary="set the crop and scale state"><br>
Set the crop and scale state of the associated wl_surface. See<br>
wl_surface_scaler for the description, and relation to the<br>
wl_buffer size.<br>
<br>
If any of src_width, src_height, dst_width, and dst_height is<br>
negative, the bad_value protocol error is raised.<br>
</description><br>
<br>
<arg name="src_x" type="fixed" summary="source rectangle x"/><br>
<arg name="src_y" type="fixed" summary="source rectangle y"/><br>
<arg name="src_width" type="fixed" summary="source rectangle width"/><br>
<arg name="src_height" type="fixed" summary="source rectangle height"/><br>
<arg name="dst_width" type="int" summary="surface width"/><br>
<arg name="dst_height" type="int" summary="surface height"/><br>
</request><br>
<br>
</interface><br>
</protocol><br>
<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div><br></div>