[PATCH weston 3/5] window: Let clients set buffer transformations
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Fri Nov 30 07:34:24 PST 2012
When a window's buffer transformation is set, its buffers are
reallocated with the appropriate size (i.e., with width and height
swapped in case of 90 or 270 degree rotation).
---
clients/window.c | 36 ++++++++++++++++++++++++++++++++----
clients/window.h | 7 +++++++
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index e96a4dd..1f34c4c 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -209,6 +209,7 @@ struct window {
int focus_count;
enum window_buffer_type buffer_type;
+ enum wl_output_transform buffer_transform;
struct toysurface *toysurface;
cairo_surface_t *cairo_surface;
@@ -1181,34 +1182,61 @@ window_get_display(struct window *window)
static void
window_create_surface(struct window *window)
{
+ struct rectangle allocation = window->allocation;
uint32_t flags = 0;
int dx, dy;
if (!window->transparent)
flags = SURFACE_OPAQUE;
+ switch (window->buffer_transform) {
+ case WL_OUTPUT_TRANSFORM_90:
+ case WL_OUTPUT_TRANSFORM_270:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ allocation.width = window->allocation.height;
+ allocation.height = window->allocation.width;
+ break;
+ default:
+ break;
+ }
+
if (!window->toysurface &&
window->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW &&
window->display->dpy) {
window->toysurface =
egl_window_surface_create(window->display,
window->surface, flags,
- &window->allocation);
+ &allocation);
}
if (!window->toysurface)
window->toysurface = shm_surface_create(window->display,
window->surface, flags,
- &window->allocation);
+ &allocation);
window_get_resize_dx_dy(window, &dx, &dy);
window->cairo_surface =
window->toysurface->prepare(window->toysurface, dx, dy,
- window->allocation.width,
- window->allocation.height,
+ allocation.width,
+ allocation.height,
window->resizing);
}
+int
+window_get_buffer_transform(struct window *window)
+{
+ return window->buffer_transform;
+}
+
+void
+window_set_buffer_transform(struct window *window,
+ enum wl_output_transform transform)
+{
+ window->buffer_transform = transform;
+ wl_surface_set_buffer_transform(window->surface, transform);
+}
+
static void frame_destroy(struct frame *frame);
void
diff --git a/clients/window.h b/clients/window.h
index 9b820a0..68ac29c 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -237,6 +237,13 @@ void
window_show_frame_menu(struct window *window,
struct input *input, uint32_t time);
+int
+window_get_buffer_transform(struct window *window);
+
+void
+window_set_buffer_transform(struct window *window,
+ enum wl_output_transform transform);
+
void
window_destroy(struct window *window);
--
1.7.10.4
More information about the wayland-devel
mailing list