[PATCH weston 3/7] compositor: migrate to stable viewporter.xml
Pekka Paalanen
ppaalanen at gmail.com
Fri Apr 15 14:53:17 UTC 2016
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Migrate from wl_scaler to wp_viewporter extension. The viewporter.xml
file is provided by wayland-protocols.
This stops Weston from advertising wl_scaler, and advertises
wp_viewporter instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
Makefile.am | 4 ++--
configure.ac | 2 ++
src/compositor.c | 68 +++++++++++---------------------------------------------
src/compositor.h | 5 +++--
4 files changed, 20 insertions(+), 59 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 9bed32c..9cb0dac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,8 +124,8 @@ nodist_weston_SOURCES = \
protocol/input-method-unstable-v1-server-protocol.h \
protocol/presentation-time-protocol.c \
protocol/presentation-time-server-protocol.h \
- protocol/scaler-protocol.c \
- protocol/scaler-server-protocol.h \
+ protocol/viewporter-protocol.c \
+ protocol/viewporter-server-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-server-protocol.h
diff --git a/configure.ac b/configure.ac
index 447cf6b..6f7b349 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,8 @@ m4_define([weston_micro_version], [90])
m4_define([weston_version],
[weston_major_version.weston_minor_version.weston_micro_version])
+# XXX: bump wayland-protocols dependency to include viewporter.xml
+
AC_PREREQ([2.64])
AC_INIT([weston],
[weston_version],
diff --git a/src/compositor.c b/src/compositor.c
index 5500197..551d4ed 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -54,7 +54,7 @@
#include "timeline.h"
#include "compositor.h"
-#include "scaler-server-protocol.h"
+#include "viewporter-server-protocol.h"
#include "presentation-time-server-protocol.h"
#include "shared/helpers.h"
#include "shared/os-compatibility.h"
@@ -923,7 +923,7 @@ weston_surface_to_buffer_float(struct weston_surface *surface,
/** Transform a rectangle from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param rect The rectangle to transform.
* \return The transformed rectangle.
@@ -963,7 +963,7 @@ weston_surface_to_buffer_rect(struct weston_surface *surface,
/** Transform a region from surface coordinates to buffer coordinates
*
- * \param surface The surface to fetch wl_viewport and buffer transformation
+ * \param surface The surface to fetch wp_viewport and buffer transformation
* from.
* \param surface_region[in] The region in surface coordinates.
* \param buffer_region[out] The region converted to buffer coordinates.
@@ -2826,7 +2826,8 @@ weston_surface_commit_state(struct weston_surface *surface,
/* wl_surface.set_buffer_transform */
/* wl_surface.set_buffer_scale */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
surface->buffer_viewport = state->buffer_viewport;
/* wl_surface.attach */
@@ -4365,48 +4366,6 @@ viewport_destroy(struct wl_client *client,
}
static void
-viewport_set(struct wl_client *client,
- struct wl_resource *resource,
- wl_fixed_t src_x,
- wl_fixed_t src_y,
- wl_fixed_t src_width,
- wl_fixed_t src_height,
- int32_t dst_width,
- int32_t dst_height)
-{
- struct weston_surface *surface =
- wl_resource_get_user_data(resource);
-
- assert(surface->viewport_resource != NULL);
-
- if (wl_fixed_to_double(src_width) < 0 ||
- wl_fixed_to_double(src_height) < 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "source dimensions must be non-negative (%fx%f)",
- wl_fixed_to_double(src_width),
- wl_fixed_to_double(src_height));
- return;
- }
-
- if (dst_width <= 0 || dst_height <= 0) {
- wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
- "destination dimensions must be positive (%dx%d)",
- dst_width, dst_height);
- return;
- }
-
- surface->pending.buffer_viewport.buffer.src_x = src_x;
- surface->pending.buffer_viewport.buffer.src_y = src_y;
- surface->pending.buffer_viewport.buffer.src_width = src_width;
- surface->pending.buffer_viewport.buffer.src_height = src_height;
- surface->pending.buffer_viewport.surface.width = dst_width;
- surface->pending.buffer_viewport.surface.height = dst_height;
- surface->pending.buffer_viewport.changed = 1;
-}
-
-static void
viewport_set_source(struct wl_client *client,
struct wl_resource *resource,
wl_fixed_t src_x,
@@ -4430,7 +4389,7 @@ viewport_set_source(struct wl_client *client,
if (src_width <= 0 || src_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"source size must be positive (%fx%f)",
wl_fixed_to_double(src_width),
wl_fixed_to_double(src_height));
@@ -4464,7 +4423,7 @@ viewport_set_destination(struct wl_client *client,
if (dst_width <= 0 || dst_height <= 0) {
wl_resource_post_error(resource,
- WL_VIEWPORT_ERROR_BAD_VALUE,
+ WP_VIEWPORT_ERROR_BAD_VALUE,
"destination size must be positive (%dx%d)",
dst_width, dst_height);
return;
@@ -4475,9 +4434,8 @@ viewport_set_destination(struct wl_client *client,
surface->pending.buffer_viewport.changed = 1;
}
-static const struct wl_viewport_interface viewport_interface = {
+static const struct wp_viewport_interface viewport_interface = {
viewport_destroy,
- viewport_set,
viewport_set_source,
viewport_set_destination
};
@@ -4502,12 +4460,12 @@ scaler_get_viewport(struct wl_client *client,
if (surface->viewport_resource) {
wl_resource_post_error(scaler,
- WL_SCALER_ERROR_VIEWPORT_EXISTS,
+ WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
"a viewport for that surface already exists");
return;
}
- resource = wl_resource_create(client, &wl_viewport_interface,
+ resource = wl_resource_create(client, &wp_viewport_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4520,7 +4478,7 @@ scaler_get_viewport(struct wl_client *client,
surface->viewport_resource = resource;
}
-static const struct wl_scaler_interface scaler_interface = {
+static const struct wp_viewporter_interface scaler_interface = {
scaler_destroy,
scaler_get_viewport
};
@@ -4531,7 +4489,7 @@ bind_scaler(struct wl_client *client,
{
struct wl_resource *resource;
- resource = wl_resource_create(client, &wl_scaler_interface,
+ resource = wl_resource_create(client, &wp_viewporter_interface,
version, id);
if (resource == NULL) {
wl_client_post_no_memory(client);
@@ -4720,7 +4678,7 @@ weston_compositor_create(struct wl_display *display, void *user_data)
ec, bind_subcompositor))
goto fail;
- if (!wl_global_create(ec->wl_display, &wl_scaler_interface, 2,
+ if (!wl_global_create(ec->wl_display, &wp_viewporter_interface, 1,
ec, bind_scaler))
goto fail;
diff --git a/src/compositor.h b/src/compositor.h
index 0ba00be..bc4000b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -973,7 +973,8 @@ struct weston_surface_state {
/* wl_surface.set_buffer_transform */
/* wl_surface.set_scaling_factor */
- /* wl_viewport.set */
+ /* wp_viewport.set_source */
+ /* wp_viewport.set_destination */
struct weston_buffer_viewport buffer_viewport;
};
@@ -1021,7 +1022,7 @@ struct weston_surface {
int32_t height_from_buffer;
bool keep_buffer; /* for backends to prevent early release */
- /* wl_viewport resource for this surface */
+ /* wp_viewport resource for this surface */
struct wl_resource *viewport_resource;
/* All the pending state, that wl_surface.commit will apply. */
--
2.7.3
More information about the wayland-devel
mailing list