summaryrefslogtreecommitdiff
path: root/src/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/render.c')
-rw-r--r--src/render.c106
1 files changed, 16 insertions, 90 deletions
diff --git a/src/render.c b/src/render.c
index de30ccd..b5ad557 100644
--- a/src/render.c
+++ b/src/render.c
@@ -210,7 +210,7 @@ static void clear_buffer (cairo_t *cairo)
cairo_restore(cairo);
}
-static void render_background_frame (struct Wlclock_surface *surface)
+void render_background_frame (struct Wlclock_surface *surface)
{
struct Wlclock_output *output = surface->output;
struct Wlclock *clock = output->clock;
@@ -219,19 +219,25 @@ static void render_background_frame (struct Wlclock_surface *surface)
clocklog(clock, 2, "[render] Render background frame: global_name=%d\n",
output->global_name);
+ if (! next_buffer(&surface->current_background_buffer, clock->shm,
+ surface->background_buffers,
+ surface->dimensions.w * scale,
+ surface->dimensions.h * scale))
+ return;
+ surface->current_background_buffer->busy = true;
+
cairo_t *cairo = surface->current_background_buffer->cairo;
clear_buffer(cairo);
draw_background(cairo, &surface->dimensions, scale, clock);
draw_clock_face(cairo, &surface->dimensions, scale, clock);
+ wl_surface_set_buffer_scale(surface->background_surface, scale);
wl_surface_damage_buffer(surface->background_surface, 0, 0, INT32_MAX, INT32_MAX);
wl_surface_attach(surface->background_surface, surface->current_background_buffer->buffer, 0, 0);
-
- surface->background_dirty = false;
}
-static void render_hands_frame (struct Wlclock_surface *surface)
+void render_hands_frame (struct Wlclock_surface *surface)
{
struct Wlclock_output *output = surface->output;
struct Wlclock *clock = output->clock;
@@ -240,100 +246,20 @@ static void render_hands_frame (struct Wlclock_surface *surface)
clocklog(clock, 2, "[render] Render hands frame: global_name=%d\n",
output->global_name);
- cairo_t *cairo = surface->current_hands_buffer->cairo;
- clear_buffer(cairo);
-
- draw_clock_hands(cairo, surface->dimensions.center_size, scale, clock);
-
- wl_surface_damage_buffer(surface->hands_surface, 0, 0, INT32_MAX, INT32_MAX);
- wl_surface_attach(surface->hands_surface, surface->current_hands_buffer->buffer, 0, 0);
-
- surface->hands_dirty = false;
-}
-
-void make_background_dirty (struct Wlclock_surface *surface)
-{
- if (surface->background_dirty)
- return;
-
- struct Wlclock_output *output = surface->output;
- struct Wlclock *clock = output->clock;
- uint32_t scale = output->scale;
-
- clocklog(clock, 2, "[render] Making background dirty: global_name=%d\n",
- output->global_name);
-
- if (! next_buffer(&surface->current_background_buffer, clock->shm,
- surface->background_buffers,
- surface->dimensions.w * scale,
- surface->dimensions.h * scale))
- return;
- surface->current_background_buffer->busy = true;
- wl_surface_set_buffer_scale(surface->background_surface, scale);
- wl_surface_attach(surface->background_surface, surface->current_background_buffer->buffer, 0, 0);
-
- surface->background_dirty = true;
-}
-
-void make_hands_dirty (struct Wlclock_surface *surface)
-{
- if (surface->hands_dirty)
- return;
-
- struct Wlclock_output *output = surface->output;
- struct Wlclock *clock = output->clock;
- uint32_t scale = output->scale;
-
- clocklog(clock, 2, "[render] Making hands dirty: global_name=%d\n",
- output->global_name);
-
if (! next_buffer(&surface->current_hands_buffer, clock->shm,
surface->hands_buffers,
surface->dimensions.center_size * scale,
surface->dimensions.center_size * scale))
return;
surface->current_hands_buffer->busy = true;
- wl_surface_set_buffer_scale(surface->hands_surface, scale);
- wl_surface_attach(surface->hands_surface, surface->current_hands_buffer->buffer, 0, 0);
-
- surface->hands_dirty = true;
-}
-static void frame_handle_done (void *data, struct wl_callback *callback, uint32_t time)
-{
- struct Wlclock_surface *surface = (struct Wlclock_surface *)data;
- wl_callback_destroy(surface->frame_callback);
- surface->frame_callback = NULL;
- clocklog(surface->output->clock, 2, "[render] Frame callback: "
- "global-name=%d background=%d hands=%d.\n",
- surface->output->global_name,
- surface->background_dirty, surface->hands_dirty);
- if (surface->background_dirty)
- render_background_frame(surface);
- if (surface->hands_dirty)
- render_hands_frame(surface);
- wl_surface_commit(surface->hands_surface);
- wl_surface_commit(surface->background_surface);
-}
+ cairo_t *cairo = surface->current_hands_buffer->cairo;
+ clear_buffer(cairo);
-static const struct wl_callback_listener frame_callback_listener = {
- .done = frame_handle_done
-};
+ draw_clock_hands(cairo, surface->dimensions.center_size, scale, clock);
-void schedule_frame (struct Wlclock_surface *surface, bool background, bool hands)
-{
- if (! surface->configured)
- return;
- clocklog(surface->output->clock, 2, "[render] Scheduling frame: "
- "global-name=%d background=%d hands=%d\n",
- surface->output->global_name, background, hands);
- if (background)
- make_background_dirty(surface);
- if (hands)
- make_hands_dirty(surface);
- if ( surface->frame_callback != NULL )
- return;
- surface->frame_callback = wl_surface_frame(surface->background_surface);
- wl_callback_add_listener(surface->frame_callback, &frame_callback_listener, surface);
+ wl_surface_set_buffer_scale(surface->hands_surface, scale);
+ wl_surface_damage_buffer(surface->hands_surface, 0, 0, INT32_MAX, INT32_MAX);
+ wl_surface_attach(surface->hands_surface, surface->current_hands_buffer->buffer, 0, 0);
}