diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-29 21:13:22 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-29 21:13:22 +1000 |
commit | 3a6ed5110c76ef5bed8cc4c26a97759f6201eaac (patch) | |
tree | a24798e2e0954daef195806b01938ec8a8bbcaed | |
parent | Merge remote-tracking branch 'upstream/master' into atomic (diff) | |
download | sway-3a6ed5110c76ef5bed8cc4c26a97759f6201eaac.tar.gz sway-3a6ed5110c76ef5bed8cc4c26a97759f6201eaac.tar.zst sway-3a6ed5110c76ef5bed8cc4c26a97759f6201eaac.zip |
Render saved buffers with the surface's dimensions
-rw-r--r-- | include/sway/desktop/transaction.h | 13 | ||||
-rw-r--r-- | sway/desktop/output.c | 8 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 17 |
3 files changed, 25 insertions, 13 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index fcfed297..7ab80eb8 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h | |||
@@ -52,11 +52,16 @@ void transaction_notify_view_ready_by_size(struct sway_view *view, | |||
52 | int width, int height); | 52 | int width, int height); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Get the texture that should be rendered for a view. | 55 | * Get the saved texture that should be rendered for a view. |
56 | * | 56 | * |
57 | * In most cases this will return the normal live texture for a view, but if the | 57 | * The addresses pointed at by the width and height pointers will be populated |
58 | * view is in a transaction then it'll return a saved texture. | 58 | * with the surface's dimensions, which may be different to the texture's |
59 | * dimensions if output scaling is used. | ||
60 | * | ||
61 | * This function should only be called if it is known that the view has | ||
62 | * instructions. | ||
59 | */ | 63 | */ |
60 | struct wlr_texture *transaction_get_texture(struct sway_view *view); | 64 | struct wlr_texture *transaction_get_saved_texture(struct sway_view *view, |
65 | int *width, int *height); | ||
61 | 66 | ||
62 | #endif | 67 | #endif |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 69d0bdd4..b55a3962 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -354,15 +354,17 @@ static void render_saved_view(struct sway_view *view, | |||
354 | struct sway_output *output, pixman_region32_t *damage, float alpha) { | 354 | struct sway_output *output, pixman_region32_t *damage, float alpha) { |
355 | struct wlr_output *wlr_output = output->wlr_output; | 355 | struct wlr_output *wlr_output = output->wlr_output; |
356 | 356 | ||
357 | struct wlr_texture *texture = transaction_get_texture(view); | 357 | int width, height; |
358 | struct wlr_texture *texture = | ||
359 | transaction_get_saved_texture(view, &width, &height); | ||
358 | if (!texture) { | 360 | if (!texture) { |
359 | return; | 361 | return; |
360 | } | 362 | } |
361 | struct wlr_box box = { | 363 | struct wlr_box box = { |
362 | .x = view->swayc->current.view_x - output->swayc->current.swayc_x, | 364 | .x = view->swayc->current.view_x - output->swayc->current.swayc_x, |
363 | .y = view->swayc->current.view_y - output->swayc->current.swayc_y, | 365 | .y = view->swayc->current.view_y - output->swayc->current.swayc_y, |
364 | .width = view->swayc->current.view_width, | 366 | .width = width, |
365 | .height = view->swayc->current.view_height, | 367 | .height = height, |
366 | }; | 368 | }; |
367 | 369 | ||
368 | struct wlr_box output_box = { | 370 | struct wlr_box output_box = { |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index fc23ef35..7c5a9b8f 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -41,6 +41,7 @@ struct sway_transaction_instruction { | |||
41 | struct sway_container *container; | 41 | struct sway_container *container; |
42 | struct sway_container_state state; | 42 | struct sway_container_state state; |
43 | struct wlr_buffer *saved_buffer; | 43 | struct wlr_buffer *saved_buffer; |
44 | int saved_buffer_width, saved_buffer_height; | ||
44 | uint32_t serial; | 45 | uint32_t serial; |
45 | bool ready; | 46 | bool ready; |
46 | }; | 47 | }; |
@@ -71,6 +72,8 @@ static void save_view_buffer(struct sway_view *view, | |||
71 | } | 72 | } |
72 | if (view->surface && wlr_surface_has_buffer(view->surface)) { | 73 | if (view->surface && wlr_surface_has_buffer(view->surface)) { |
73 | instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer); | 74 | instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer); |
75 | instruction->saved_buffer_width = view->surface->current->width; | ||
76 | instruction->saved_buffer_height = view->surface->current->height; | ||
74 | } | 77 | } |
75 | } | 78 | } |
76 | 79 | ||
@@ -392,12 +395,14 @@ void transaction_notify_view_ready_by_size(struct sway_view *view, | |||
392 | } | 395 | } |
393 | } | 396 | } |
394 | 397 | ||
395 | struct wlr_texture *transaction_get_texture(struct sway_view *view) { | 398 | struct wlr_texture *transaction_get_saved_texture(struct sway_view *view, |
396 | if (!view->swayc || !view->swayc->instructions->length) { | 399 | int *width, int *height) { |
397 | return view->surface->buffer->texture; | ||
398 | } | ||
399 | struct sway_transaction_instruction *instruction = | 400 | struct sway_transaction_instruction *instruction = |
400 | view->swayc->instructions->items[0]; | 401 | view->swayc->instructions->items[0]; |
401 | return instruction->saved_buffer ? | 402 | if (!instruction->saved_buffer) { |
402 | instruction->saved_buffer->texture : NULL; | 403 | return NULL; |
404 | } | ||
405 | *width = instruction->saved_buffer_width; | ||
406 | *height = instruction->saved_buffer_height; | ||
407 | return instruction->saved_buffer->texture; | ||
403 | } | 408 | } |