[PATCH 2/2] protocol: Add buffer_scale to wl_surface and wl_output

alexl at redhat.com alexl at redhat.com
Wed May 8 03:51:07 PDT 2013


From: Alexander Larsson <alexl at redhat.com>

This adds wl_surface_set_buffer_scale() to set the buffer
scale of a surface.

It is similar to set_buffer_transform in that it says that the buffer
is stored in a way that has been transformed (in this case
scaled). This means that if an output is naturally scaled (i.e. has
sub-pixel precision) we can directly use the pre-scaled buffer with
additional data, rather than having to scale it.

It also adds a scale member to the wl_output geometry event
that specifies the natural scaling of an output.

This is meant to be used for outputs with a very high DPI to tell
the client that this particular output has subpixel precision.
The coordinates for e.g. input and the positioning in the compositor
wrt other outputs (which may be non-subpixel-precision) are in
"logical" pixel coordinates, and need to be multiplied by the
scaling factor to convert to the physical pixels of the output.

This setup means global properties like mouse acceleration/speed, pointer
size, monitor geometry, etc can be specified in a "mostly similar" resolution
even on a multimonitor setup where some monitors are low dpi and some are
e.g. retina-class outputs.

It also adds a scale_priority to the geometry event. This can
be used by clients to know what scale factor to use for buffers
on mirrored displays. If a window surface is equally much on two
outputs, such as the case of a mirrored output, the app doesn't
know what scale factor to pick to match the native output. In
this case it can pick the one with the highest priority, giving
the compositor (and thus the user) the possibility of selecting
which output should look "best".
---
 protocol/wayland.xml | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 3bce022..941952a 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -876,7 +876,7 @@
     </event>
   </interface>
 
-  <interface name="wl_surface" version="2">
+  <interface name="wl_surface" version="3">
     <description summary="an onscreen surface">
       A surface is a rectangular area that is displayed on the screen.
       It has a location, size and pixel contents.
@@ -1110,7 +1110,32 @@
       </description>
       <arg name="transform" type="int"/>
     </request>
-   </interface>
+
+    <!-- Version 3 additions -->
+
+    <request name="set_buffer_scale" since="3">
+      <description summary="sets the buffer scale">
+	This request sets an optional scaling factor on how the compositor
+	interprets the contents of the buffer attached to the surface. A
+	value larger than 1, like e.g. 2 means that the buffer is 2 times the
+	size of the surface.
+
+	Buffer scale is double-buffered state, see wl_surface.commit.
+
+	A newly created surface has its buffer scale set to 1.
+
+	The purpose of this request is to allow clients to supply higher resolution
+	buffer data for use on high-resolution outputs where the output itself
+	has a scaling factor set. For instance, a laptop with a high DPI
+	internal screen and an low DPI external screen would have two outputs
+	with different scaling, and a wl_surface rendered on the scaled output
+	would normally be scaled up. To avoid this upscaling the app can supply
+	a pre-scaled version with more detail by using set_buffer_scale.
+      </description>
+      <arg name="scale" type="int"/>
+    </request>
+
+  </interface>
 
   <interface name="wl_seat" version="1">
     <description summary="group of input devices">
@@ -1467,7 +1492,7 @@
     </event>
   </interface>
 
-  <interface name="wl_output" version="1">
+  <interface name="wl_output" version="2">
     <description summary="compositor output region">
       An output describes part of the compositor geometry.  The
       compositor works in the 'compositor coordinate system' and an
@@ -1537,6 +1562,10 @@
 	   summary="textual description of the model"/>
       <arg name="transform" type="int"
 	   summary="transform that maps framebuffer to output"/>
+      <arg name="scale" type="int"
+	   summary="scaling of framebuffer to output" value="1" since="2"/>
+      <arg name="scale_priority" type="int"
+	   summary="priority of scale" since="2"/>
     </event>
 
     <enum name="mode">
-- 
1.8.1.4



More information about the wayland-devel mailing list