wayland_server_viewport_t - Man Page

crop and scale interface to a wl_surface

Synopsis

#include <wayland-server-protocol-extra.hpp>

Inherits wayland::server::resource_t.

Public Member Functions

std::function< void()> & on_destroy ()
remove scaling and cropping from the surface
std::function< void(double, double, double, double)> & on_set_source ()
set the source rectangle for cropping
std::function< void(int32_t, int32_t)> & on_set_destination ()
set the surface size for scaling
void post_bad_value (std::string const &msg)
Post error: negative or zero values in width or height.
void post_bad_size (std::string const &msg)
Post error: destination size is not integer.
void post_out_of_buffer (std::string const &msg)
Post error: source rectangle extends outside of the content area.
void post_no_surface (std::string const &msg)
Post error: the wl_surface was destroyed.
bool proxy_has_object () const
Check whether this wrapper actually wraps an object.
void post_no_memory () const
uint32_t get_id () const
client_t get_client () const
unsigned int get_version () const
std::string get_class ()

Detailed Description

crop and scale interface to a wl_surface

An additional interface to a wl_surface object, which allows the client to specify the cropping and scaling of the surface contents.

This interface works with two concepts: the source rectangle (src_x, src_y, src_width, src_height), and the destination size (dst_width, dst_height). The contents of the source rectangle are scaled to the destination size, and content outside the source rectangle is ignored. This state is double-buffered, and is applied on the next wl_surface.commit.

The two parts of crop and scale state are independent: the source rectangle, and the destination size. Initially both are unset, that is, no scaling is applied. The whole of the current wl_buffer is used as the source, and the surface size is as defined in wl_surface.attach.

If the destination size is set, it causes the surface size to become dst_width, dst_height. The source (rectangle) is scaled to exactly this size. This overrides whatever the attached wl_buffer size is, unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface has no content and therefore no size. Otherwise, the size is always at least 1x1 in surface local coordinates.

If the source rectangle is set, it defines what area of the wl_buffer is taken as the source. If the source rectangle is set and the destination size is not set, then src_width and src_height must be integers, and the surface size becomes the source rectangle size. This results in cropping without scaling. If src_width or src_height are not integers and destination size is not set, the bad_size protocol error is raised when the surface state is applied.

The coordinate transformations from buffer pixel coordinates up to the surface-local coordinates happen in the following order:

  1. buffer_transform (wl_surface.set_buffer_transform)
  2. buffer_scale (wl_surface.set_buffer_scale)
  3. crop and scale (wp_viewport.set*) This means, that the source rectangle coordinates of crop and scale are given in the coordinates after the buffer transform and scale, i.e. in the coordinates that would be the surface-local coordinates if the crop and scale was not applied.

If src_x or src_y are negative, the bad_value protocol error is raised. Otherwise, if the source rectangle is partially or completely outside of the non-NULL wl_buffer, then the out_of_buffer protocol error is raised when the surface state is applied. A NULL wl_buffer does not raise the out_of_buffer error.

The x, y arguments of wl_surface.attach are applied as normal to the surface. They indicate how many pixels to remove from the surface size from the left and the top. In other words, they are still in the surface-local coordinate system, just like dst_width and dst_height are.

If the wl_surface associated with the wp_viewport is destroyed, all wp_viewport requests except 'destroy' raise the protocol error no_surface.

If the wp_viewport object is destroyed, the crop and scale state is removed from the wl_surface. The change will be applied on the next wl_surface.commit.

Definition at line 493 of file wayland-server-protocol-extra.hpp.

Member Function Documentation

std::string wayland::server::resource_t::get_class () [inherited]

Retrieve the interface name (class) of a resource object.

Returns

Interface name of the resource object.

client_t wayland::server::resource_t::get_client () const [inherited]

Get the associated client

Returns

the client that owns the resource.

uint32_t wayland::server::resource_t::get_id () const [inherited]

Get the internal ID of the resource

Returns

the internal ID of the resource

unsigned int wayland::server::resource_t::get_version () const [inherited]

Get interface version

Returns

Interface version this resource has been constructed with.

std::function< void()> & viewport_t::on_destroy ()

remove scaling and cropping from the surface The associated wl_surface's crop and scale state is removed. The change is applied on the next wl_surface.commit.

Definition at line 848 of file wayland-server-protocol-extra.cpp.

std::function< void(int32_t, int32_t)> & viewport_t::on_set_destination ()

set the surface size for scaling

Parameters

width surface width
height surface height

Set the destination size of the associated wl_surface. See wp_viewport for the description, and relation to the wl_buffer size.

If width is -1 and height is -1, the destination size is unset instead. Any other pair of values for width and height that contains zero or negative values raises the bad_value protocol error.

The crop and scale state is double-buffered state, and will be applied on the next wl_surface.commit.

Definition at line 860 of file wayland-server-protocol-extra.cpp.

std::function< void(double, double, double, double)> & viewport_t::on_set_source ()

set the source rectangle for cropping

Parameters

x source rectangle x
y source rectangle y
width source rectangle width
height source rectangle height

Set the source rectangle of the associated wl_surface. See wp_viewport for the description, and relation to the wl_buffer size.

If all of x, y, width and height are -1.0, the source rectangle is unset instead. Any other set of values where width or height are zero or negative, or x or y are negative, raise the bad_value protocol error.

The crop and scale state is double-buffered state, and will be applied on the next wl_surface.commit.

Definition at line 854 of file wayland-server-protocol-extra.cpp.

void viewport_t::post_bad_size (std::string const & msg)

Post error: destination size is not integer.

Definition at line 871 of file wayland-server-protocol-extra.cpp.

void viewport_t::post_bad_value (std::string const & msg)

Post error: negative or zero values in width or height.

Definition at line 866 of file wayland-server-protocol-extra.cpp.

void wayland::server::resource_t::post_no_memory () const [inherited]

Post 'not enough memory' error to the client

If the compositor has not enough memory to fulfill a certail request of the client, this function can be called to notify the client of this circumstance.

void viewport_t::post_no_surface (std::string const & msg)

Post error: the wl_surface was destroyed.

Definition at line 881 of file wayland-server-protocol-extra.cpp.

void viewport_t::post_out_of_buffer (std::string const & msg)

Post error: source rectangle extends outside of the content area.

Definition at line 876 of file wayland-server-protocol-extra.cpp.

bool wayland::server::resource_t::proxy_has_object () const [inherited]

Check whether this wrapper actually wraps an object.

Returns

true if there is an underlying object, false if this wrapper is empty

Author

Generated automatically by Doxygen for Wayland++ from the source code.

Info

Sat Jan 27 2024 00:00:00 Version 1.0.0 Wayland++