Skip to content

Commit

Permalink
redirect wlroots render implementation
Browse files Browse the repository at this point in the history
issues: zzxyb#5
  • Loading branch information
lychee-yycy committed Aug 4, 2024
1 parent 51006ac commit f7ab326
Show file tree
Hide file tree
Showing 7 changed files with 895 additions and 1,061 deletions.
9 changes: 9 additions & 0 deletions common/wsm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ THE SOFTWARE.
#include <string.h>

static const char whitespace[] = " \f\n\r\t\v";
static const long NSEC_PER_SEC = 1000000000;

void strip_whitespace(char *str) {
size_t len = strlen(str);
Expand Down Expand Up @@ -122,3 +123,11 @@ char* int_to_string(int num) {
snprintf(str, length + 1, "%d", num);
return str;
}

int64_t timespec_to_msec(const struct timespec *a) {
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
}

int64_t timespec_to_nsec(const struct timespec *a) {
return (int64_t)a->tv_sec * NSEC_PER_SEC + a->tv_nsec;
}
4 changes: 4 additions & 0 deletions common/wsm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ THE SOFTWARE.

#include <wayland-client-protocol.h>

struct timespec;

#ifndef ARRAY_LENGTH
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#endif
Expand Down Expand Up @@ -136,5 +138,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len);
int lenient_strcmp(const char *a, const char *b);
void color_to_rgba(float dest[static 4], uint32_t color);
char* int_to_string(int num);
int64_t timespec_to_msec(const struct timespec *a);
int64_t timespec_to_nsec(const struct timespec *a);

#endif
4 changes: 2 additions & 2 deletions common/wsm_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ THE SOFTWARE.
#include <unistd.h>

static terminate_callback_t log_terminate = exit;
static const long NSEC_PER_SEC = 1000000000;

void _wsm_abort(const char *format, ...) {
va_list args;
Expand Down Expand Up @@ -76,9 +77,8 @@ static const char *verbosity_headers[] = {
[WSM_DEBUG] = "[DEBUG]",
};

static void timespec_sub(struct timespec *r, const struct timespec *a,
void timespec_sub(struct timespec *r, const struct timespec *a,
const struct timespec *b) {
const long NSEC_PER_SEC = 1000000000;
r->tv_sec = a->tv_sec - b->tv_sec;
r->tv_nsec = a->tv_nsec - b->tv_nsec;
if (r->tv_nsec < 0) {
Expand Down
5 changes: 5 additions & 0 deletions common/wsm_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ THE SOFTWARE.
#include <string.h>
#include <errno.h>

struct timespec;

typedef enum {
WSM_SILENT = 0,
WSM_ERROR = 1,
Expand All @@ -52,6 +54,9 @@ typedef void (*terminate_callback_t)(int exit_code);
// The `terminate` callback is called by `wsm_abort`
void wsm_log_init(wsm_log_importance_t verbosity, terminate_callback_t terminate);

void timespec_sub(struct timespec *r, const struct timespec *a,
const struct timespec *b);

void _wsm_log(wsm_log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
void _wsm_vlog(wsm_log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
void _wsm_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
Expand Down
4 changes: 2 additions & 2 deletions output/wsm_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static int output_repaint_timer_handler(void *data) {
if (output->gamma_lut_changed) {
struct wlr_output_state pending;
wlr_output_state_init(&pending);
if (!wlr_scene_output_build_state(output->scene_output, &pending, NULL)) {
if (!wsm_scene_output_build_state(output->scene_output, &pending, NULL)) {
return 0;
}

Expand All @@ -312,7 +312,7 @@ static int output_repaint_timer_handler(void *data) {
}

// TODO: Need to refactor for post effect
wlr_scene_output_commit(output->scene_output, NULL);
wsm_scene_output_commit(output->scene_output, NULL);
return 0;
}

Expand Down
Loading

0 comments on commit f7ab326

Please sign in to comment.