render: make wlr_renderer_clear take a float[4] for the color

This commit is contained in:
emersion 2018-02-03 09:32:02 +01:00
parent 402587ed65
commit ddb1779f9f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
9 changed files with 13 additions and 17 deletions

View File

@ -102,7 +102,7 @@ static void handle_output_frame(struct output_state *output,
wlr_output_make_current(wlr_output, NULL); wlr_output_make_current(wlr_output, NULL);
wlr_renderer_begin(sample->renderer, wlr_output); wlr_renderer_begin(sample->renderer, wlr_output);
wlr_renderer_clear(sample->renderer, 0.25f, 0.25f, 0.25f, 1); wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
animate_cat(sample, output->output); animate_cat(sample, output->output);

View File

@ -44,7 +44,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_make_current(wlr_output, NULL); wlr_output_make_current(wlr_output, NULL);
wlr_renderer_begin(sample->renderer, wlr_output); wlr_renderer_begin(sample->renderer, wlr_output);
wlr_renderer_clear(sample->renderer, 0.25f, 0.25f, 0.25f, 1); wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
float matrix[16]; float matrix[16];
for (int y = -128 + (int)odata->y_offs; y < height; y += 128) { for (int y = -128 + (int)odata->y_offs; y < height; y += 128) {

View File

@ -44,7 +44,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_make_current(wlr_output, NULL); wlr_output_make_current(wlr_output, NULL);
wlr_renderer_begin(sample->renderer, wlr_output); wlr_renderer_begin(sample->renderer, wlr_output);
wlr_renderer_clear(sample->renderer, 0.25f, 0.25f, 0.25f, 1); wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
float matrix[16], view[16]; float matrix[16], view[16];
float distance = 0.8f * (1 - sample->distance); float distance = 0.8f * (1 - sample->distance);

View File

@ -43,7 +43,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
wlr_output_make_current(wlr_output, NULL); wlr_output_make_current(wlr_output, NULL);
wlr_renderer_begin(sample->renderer, wlr_output); wlr_renderer_begin(sample->renderer, wlr_output);
wlr_renderer_clear(sample->renderer, 0.25f, 0.25f, 0.25f, 1); wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1});
float matrix[16]; float matrix[16];
struct touch_point *p; struct touch_point *p;

View File

@ -13,8 +13,7 @@ struct wlr_renderer;
void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output); void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output);
void wlr_renderer_end(struct wlr_renderer *r); void wlr_renderer_end(struct wlr_renderer *r);
void wlr_renderer_clear(struct wlr_renderer *r, float red, float green, void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]);
float blue, float alpha);
/** /**
* Defines a scissor box. Only pixels that lie within the scissor box can be * Defines a scissor box. Only pixels that lie within the scissor box can be
* modified by drawing functions. Providing a NULL `box` disables the scissor * modified by drawing functions. Providing a NULL `box` disables the scissor

View File

@ -18,8 +18,7 @@ struct wlr_renderer {
struct wlr_renderer_impl { struct wlr_renderer_impl {
void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output); void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output);
void (*end)(struct wlr_renderer *renderer); void (*end)(struct wlr_renderer *renderer);
void (*clear)(struct wlr_renderer *renderer, float red, float green, void (*clear)(struct wlr_renderer *renderer, const float (*color)[4]);
float blue, float alpha);
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box); void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer); struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
bool (*render_with_matrix)(struct wlr_renderer *renderer, bool (*render_with_matrix)(struct wlr_renderer *renderer,

View File

@ -121,9 +121,9 @@ static void wlr_gles2_end(struct wlr_renderer *wlr_renderer) {
// no-op // no-op
} }
static void wlr_gles2_clear(struct wlr_renderer *wlr_renderer, float red, static void wlr_gles2_clear(struct wlr_renderer *wlr_renderer,
float green, float blue, float alpha) { const float (*color)[4]) {
glClearColor(red, green, blue, alpha); glClearColor((*color)[0], (*color)[1], (*color)[2], (*color)[3]);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }

View File

@ -23,9 +23,8 @@ void wlr_renderer_end(struct wlr_renderer *r) {
r->impl->end(r); r->impl->end(r);
} }
void wlr_renderer_clear(struct wlr_renderer *r, float red, float green, void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]) {
float blue, float alpha) { r->impl->clear(r, color);
r->impl->clear(r, red, green, blue, alpha);
} }
void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) { void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) {

View File

@ -361,7 +361,7 @@ static void render_output(struct roots_output *output) {
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
float clear_color[] = {0.25f, 0.25f, 0.25f}; float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
// Check if we can delegate the fullscreen surface to the output // Check if we can delegate the fullscreen surface to the output
if (output->fullscreen_view != NULL) { if (output->fullscreen_view != NULL) {
@ -438,8 +438,7 @@ static void render_output(struct roots_output *output) {
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects); pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) { for (int i = 0; i < nrects; ++i) {
scissor_output(output, &rects[i]); scissor_output(output, &rects[i]);
wlr_renderer_clear(renderer, clear_color[0], clear_color[1], wlr_renderer_clear(renderer, &clear_color);
clear_color[2], 1);
} }
// If a view is fullscreen on this output, render it // If a view is fullscreen on this output, render it