Struct wayland_protocols::wp::viewporter::server::wp_viewport::WpViewport
source · [−]pub struct WpViewport { /* private fields */ }
server
only.Expand 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:
- buffer_transform (wl_surface.set_buffer_transform)
- buffer_scale (wl_surface.set_buffer_scale)
- 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.
See also the Request enum for this interface.
Trait Implementations
sourceimpl Clone for WpViewport
impl Clone for WpViewport
sourcefn clone(&self) -> WpViewport
fn clone(&self) -> WpViewport
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for WpViewport
impl Debug for WpViewport
sourceimpl PartialEq<WpViewport> for WpViewport
impl PartialEq<WpViewport> for WpViewport
sourceimpl Resource for WpViewport
impl Resource for WpViewport
type Request = Request
type Event = Event
fn interface() -> &'static Interface
fn id(&self) -> ObjectId
fn version(&self) -> u32
fn data<U: 'static>(&self) -> Option<&U>
fn object_data(&self) -> Option<&Arc<dyn Any + Send + Sync>>
fn handle(&self) -> &WeakHandle
fn from_id(conn: &DisplayHandle, id: ObjectId) -> Result<Self, InvalidId>
fn send_event(&self, evt: Self::Event) -> Result<(), InvalidId>
fn parse_request(
conn: &DisplayHandle,
msg: Message<ObjectId>
) -> Result<(Self, Self::Request), DispatchError>
fn write_event(
&self,
conn: &DisplayHandle,
msg: Self::Event
) -> Result<Message<ObjectId>, InvalidId>
fn client_id(&self) -> Option<ClientId>
fn post_error(&self, code: impl Into<u32>, error: impl Into<String>)
impl Eq for WpViewport
Auto Trait Implementations
impl !RefUnwindSafe for WpViewport
impl Send for WpViewport
impl Sync for WpViewport
impl Unpin for WpViewport
impl !UnwindSafe for WpViewport
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more