Wayland++
0.2.6
C++ Bindings for Wayland
|
crop and scale interface to a wl_surface More...
#include <wayland-client-protocol-extra.hpp>
Public Types | |
enum | wrapper_type { wrapper_type::standard, wrapper_type::display, wrapper_type::foreign, wrapper_type::proxy_wrapper } |
Public Member Functions | |
void | set_source (double x, double y, double width, double height) |
set the source rectangle for cropping More... | |
void | set_destination (int32_t width, int32_t height) |
set the surface size for scaling More... | |
uint32_t | get_id () const |
Get the id of a proxy object. More... | |
std::string | get_class () const |
Get the interface name (class) of a proxy object. More... | |
uint32_t | get_version () const |
Get the protocol object version of a proxy object. More... | |
wrapper_type | get_wrapper_type () const |
Get the type of a proxy object. More... | |
void | set_queue (event_queue_t queue) |
Assign a proxy to an event queue. More... | |
wl_proxy * | c_ptr () const |
Get a pointer to the underlying C struct. More... | |
bool | proxy_has_object () const |
Check whether this wrapper actually wraps an object. More... | |
operator bool () const | |
Check whether this wrapper actually wraps an object. More... | |
bool | operator== (const proxy_t &right) const |
Check whether two wrappers refer to the same object. More... | |
bool | operator!= (const proxy_t &right) const |
Check whether two wrappers refer to different objects. More... | |
void | proxy_release () |
Release the wrapped object (if any), making this an empty wrapper. More... | |
Static Public Attributes | |
static constexpr std::uint32_t | set_source_since_version = 1 |
Minimum protocol version required for the set_source function. More... | |
static constexpr std::uint32_t | set_destination_since_version = 1 |
Minimum protocol version required for the set_destination function. More... | |
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:
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 467 of file wayland-client-protocol-extra.hpp.
|
stronginherited |
Underlying wl_proxy type and properties of a proxy_t that affect construction, destruction, and event handling
Enumerator | |
---|---|
standard | C pointer is a standard type compatible with wl_proxy*. Events are dispatched and it is destructed when the proxy_t is destructed. User data is set. |
display | C pointer is a wl_display*. No events are dispatched, wl_display_disconnect is called when the proxy_t is destructed. User data is set. |
foreign | C pointer is a standard type compatible with wl_proxy*, but another library owns it and it should not be touched in a way that could affect the operation of the other library. No events are dispatched, wl_proxy_destroy is not called when the proxy_t is destructed, user data is not touched. Consequently, there is no reference counting for the proxy_t. Lifetime of such wrappers should preferably be short to minimize the chance that the owning library decides to destroy the wl_proxy. |
proxy_wrapper | C pointer is a wl_proxy* that was constructed with wl_proxy_create_wrapper. No events are dispatched, wl_proxy_wrapper_destroy is called when the proxy_t is destroyed. Reference counting is active. A reference to the proxy_t creating this proxy wrapper is held to extend its lifetime until after the proxy wrapper is destroyed. |
Definition at line 105 of file wayland-client.hpp.
|
inherited |
Get a pointer to the underlying C struct.
|
inherited |
Get the interface name (class) of a proxy object.
|
inherited |
|
inherited |
Get the protocol object version of a proxy object.
Gets the protocol object version of a proxy object, or 0 if the proxy was created with unversioned API.
A returned value of 0 means that no version information is available, so the caller must make safe assumptions about the object's real version.
display_t will always return version 0.
|
inlineinherited |
Get the type of a proxy object.
Definition at line 288 of file wayland-client.hpp.
|
inherited |
Check whether this wrapper actually wraps an object.
|
inherited |
Check whether two wrappers refer to different objects.
|
inherited |
Check whether two wrappers refer to the same object.
|
inherited |
Check whether this wrapper actually wraps an object.
|
inherited |
Release the wrapped object (if any), making this an empty wrapper.
Note that display_t instances cannot be released this way. Attempts to do so are ignored.
void viewport_t::set_destination | ( | int32_t | width, |
int32_t | height | ||
) |
set the surface size for scaling
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 894 of file wayland-client-protocol-extra.cpp.
|
inherited |
Assign a proxy to an event queue.
queue | The event queue that will handle this proxy |
Assign proxy to event queue. Events coming from proxy will be queued in queue instead of the display's main queue.
See also: display_t::dispatch_queue().
void viewport_t::set_source | ( | double | x, |
double | y, | ||
double | width, | ||
double | height | ||
) |
set the source rectangle for cropping
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 889 of file wayland-client-protocol-extra.cpp.
|
staticconstexpr |
Minimum protocol version required for the set_destination function.
Definition at line 535 of file wayland-client-protocol-extra.hpp.
|
staticconstexpr |
Minimum protocol version required for the set_source function.
Definition at line 512 of file wayland-client-protocol-extra.hpp.