summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de>2020-09-26 19:16:58 +0200
committerLeon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de>2020-09-28 02:36:04 +0200
commite7adc6269c8a054d5a4e1139ccc6b667407b108e (patch)
tree49312549dce2f551ec5bd00cb6788cb733624b0b /src
parent646f6545b9405aae65812470ba518a9701295751 (diff)
downloadwlclock-e7adc6269c8a054d5a4e1139ccc6b667407b108e.tar.gz
wlclock-e7adc6269c8a054d5a4e1139ccc6b667407b108e.tar.bz2
Rip out frame callback
Apparently, requesting a callback is asking "when can I render the /next/ frame?", not asking "when can I render /this/ frame?". Huh...
Diffstat (limited to 'src')
-rw-r--r--src/render.c106
-rw-r--r--src/render.h3
-rw-r--r--src/surface.c10
-rw-r--r--src/surface.h3
4 files changed, 21 insertions, 101 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);
}
diff --git a/src/render.h b/src/render.h
index c942a7d..d4a180b 100644
--- a/src/render.h
+++ b/src/render.h
@@ -5,6 +5,7 @@
struct Wlclock_surface;
-void schedule_frame (struct Wlclock_surface *surface, bool background, bool hands);
+void render_background_frame (struct Wlclock_surface *surface);
+void render_hands_frame (struct Wlclock_surface *surface);
#endif
diff --git a/src/surface.c b/src/surface.c
index 63b56b3..ea4387d 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -133,9 +133,6 @@ bool create_surface (struct Wlclock_output *output)
surface->hands_surface = NULL;
surface->layer_surface = NULL;
surface->configured = false;
- surface->frame_callback = NULL;
- surface->background_dirty = false;
- surface->hands_dirty = false;
if ( NULL == (surface->background_surface = wl_compositor_create_surface(clock->compositor)) )
{
@@ -188,8 +185,6 @@ void destroy_surface (struct Wlclock_surface *surface)
wl_surface_destroy(surface->background_surface);
if ( surface->hands_surface != NULL )
wl_surface_destroy(surface->hands_surface);
- if ( surface->frame_callback != NULL )
- wl_callback_destroy(surface->frame_callback);
finish_buffer(&surface->background_buffers[0]);
finish_buffer(&surface->background_buffers[1]);
finish_buffer(&surface->hands_buffers[0]);
@@ -212,7 +207,8 @@ void update_surface (struct Wlclock_surface *surface)
return;
configure_layer_surface(surface);
configure_subsurface(surface);
- schedule_frame(surface, true, true);
+ render_background_frame(surface);
+ render_hands_frame(surface);
wl_surface_commit(surface->hands_surface);
wl_surface_commit(surface->background_surface);
}
@@ -233,7 +229,7 @@ void update_all_hands (struct Wlclock *clock)
wl_list_for_each_safe(op, tmp, &clock->outputs, link)
if ( op->surface != NULL )
{
- schedule_frame(op->surface, false, true);
+ render_hands_frame(op->surface);
wl_surface_commit(op->surface->hands_surface);
wl_surface_commit(op->surface->background_surface);
}
diff --git a/src/surface.h b/src/surface.h
index 7262a42..d2dcb25 100644
--- a/src/surface.h
+++ b/src/surface.h
@@ -26,9 +26,6 @@ struct Wlclock_surface
struct Wlclock_buffer hands_buffers[2];
struct Wlclock_buffer *current_hands_buffer;
bool configured;
-
- struct wl_callback *frame_callback;
- bool background_dirty, hands_dirty;
};
bool create_surface (struct Wlclock_output *output);