examples: init wlr_output with allocator and renderer
This commit is contained in:
parent
142d10e591
commit
6d6e70b9e0
|
@ -7,6 +7,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_fullscreen_shell_v1.h>
|
||||
|
@ -25,6 +26,7 @@ struct fullscreen_server {
|
|||
struct wl_display *wl_display;
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
|
||||
struct wlr_fullscreen_shell_v1 *fullscreen_shell;
|
||||
struct wl_listener present_surface;
|
||||
|
@ -146,6 +148,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
|||
wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
||||
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
|
||||
|
||||
struct fullscreen_output *output =
|
||||
calloc(1, sizeof(struct fullscreen_output));
|
||||
output->wlr_output = wlr_output;
|
||||
|
@ -203,8 +207,10 @@ int main(int argc, char *argv[]) {
|
|||
struct fullscreen_server server = {0};
|
||||
server.wl_display = wl_display_create();
|
||||
server.backend = wlr_backend_autocreate(server.wl_display);
|
||||
server.renderer = wlr_backend_get_renderer(server.backend);
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
wlr_renderer_init_wl_display(server.renderer, server.wl_display);
|
||||
server.allocator = wlr_allocator_autocreate(server.backend,
|
||||
server.renderer);
|
||||
|
||||
wlr_compositor_create(server.wl_display, server.renderer);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
|
@ -22,6 +23,8 @@
|
|||
struct sample_state {
|
||||
struct wl_display *display;
|
||||
struct wlr_xcursor *xcursor;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
float default_color[4];
|
||||
float clear_color[4];
|
||||
struct wlr_output_layout *layout;
|
||||
|
@ -90,7 +93,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct sample_output *output = wl_container_of(listener, output, frame);
|
||||
struct sample_state *sample = output->sample;
|
||||
struct wlr_output *wlr_output = output->output;
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
struct wlr_renderer *renderer = sample->renderer;
|
||||
|
||||
wlr_output_attach_render(wlr_output, NULL);
|
||||
|
||||
|
@ -144,6 +147,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
sample_output->output = output;
|
||||
sample_output->sample = sample;
|
||||
|
@ -269,6 +275,10 @@ int main(int argc, char *argv[]) {
|
|||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
wl_list_init(&state.cursors);
|
||||
wl_list_init(&state.pointers);
|
||||
wl_list_init(&state.outputs);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
|
@ -27,6 +28,7 @@ struct sample_state {
|
|||
struct wl_listener new_output;
|
||||
struct wl_listener new_input;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wlr_output_layout *layout;
|
||||
float x_offs, y_offs;
|
||||
|
@ -158,6 +160,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
wlr_output_layout_add_auto(sample->layout, output);
|
||||
sample_output->output = output;
|
||||
|
@ -273,11 +278,13 @@ int main(int argc, char *argv[]) {
|
|||
wl_signal_add(&wlr->events.new_input, &state.new_input);
|
||||
state.new_input.notify = new_input_notify;
|
||||
|
||||
state.renderer = wlr_backend_get_renderer(wlr);
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
state.cat_texture = wlr_texture_from_pixels(state.renderer,
|
||||
DRM_FORMAT_ABGR8888, cat_tex.width * 4, cat_tex.width, cat_tex.height,
|
||||
cat_tex.pixel_data);
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
if (!wlr_backend_start(wlr)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
|
@ -24,6 +25,8 @@
|
|||
struct sample_state {
|
||||
struct wl_display *display;
|
||||
struct compositor_state *compositor;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_xcursor_manager *xcursor_manager;
|
||||
struct wlr_cursor *cursor;
|
||||
double cur_x, cur_y;
|
||||
|
@ -95,7 +98,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
struct sample_output *sample_output = wl_container_of(listener, sample_output, frame);
|
||||
struct sample_state *state = sample_output->state;
|
||||
struct wlr_output *wlr_output = sample_output->output;
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
|
||||
struct wlr_renderer *renderer = state->renderer;
|
||||
assert(renderer);
|
||||
|
||||
wlr_output_attach_render(wlr_output, NULL);
|
||||
|
@ -250,6 +253,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
sample_output->output = output;
|
||||
sample_output->state = sample;
|
||||
|
@ -331,6 +337,10 @@ int main(int argc, char *argv[]) {
|
|||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
state.cursor = wlr_cursor_create();
|
||||
state.layout = wlr_output_layout_create();
|
||||
wlr_cursor_attach_output_layout(state.cursor, state.layout);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
@ -24,6 +25,7 @@ struct sample_state {
|
|||
struct wl_listener new_input;
|
||||
struct timespec last_frame;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wl_list outputs;
|
||||
};
|
||||
|
||||
|
@ -103,6 +105,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
|
||||
struct wlr_output_mode *mode = wlr_output_preferred_mode(output);
|
||||
|
@ -195,13 +200,15 @@ int main(int argc, char *argv[]) {
|
|||
state.new_input.notify = new_input_notify;
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.last_frame);
|
||||
|
||||
state.renderer = wlr_backend_get_renderer(wlr);
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
if (!state.renderer) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
wlr_backend_destroy(wlr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
if (!wlr_backend_start(wlr)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
@ -25,6 +26,7 @@ struct sample_state {
|
|||
struct wl_listener new_input;
|
||||
struct timespec last_frame;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wl_list outputs;
|
||||
enum wl_output_transform transform;
|
||||
|
@ -105,6 +107,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
sample_output->x_offs = sample_output->y_offs = 0;
|
||||
sample_output->x_vel = sample_output->y_vel = 128;
|
||||
|
@ -245,7 +250,7 @@ int main(int argc, char *argv[]) {
|
|||
state.new_input.notify = new_input_notify;
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.last_frame);
|
||||
|
||||
state.renderer = wlr_backend_get_renderer(wlr);
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
if (!state.renderer) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
@ -259,6 +264,8 @@ int main(int argc, char *argv[]) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
if (!wlr_backend_start(wlr)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
@ -25,6 +26,8 @@ static const int border_width = 3;
|
|||
struct server {
|
||||
struct wl_display *display;
|
||||
struct wlr_backend *backend;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_scene *scene;
|
||||
|
||||
struct wl_list outputs;
|
||||
|
@ -73,6 +76,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
|
|||
struct server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
|
||||
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
|
||||
|
||||
struct output *output =
|
||||
calloc(1, sizeof(struct output));
|
||||
output->wlr = wlr_output;
|
||||
|
@ -161,11 +166,14 @@ int main(int argc, char *argv[]) {
|
|||
server.backend = wlr_backend_autocreate(server.display);
|
||||
server.scene = wlr_scene_create();
|
||||
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(server.backend);
|
||||
wlr_renderer_init_wl_display(renderer, server.display);
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
wlr_renderer_init_wl_display(server.renderer, server.display);
|
||||
|
||||
server.allocator = wlr_allocator_autocreate(server.backend,
|
||||
server.renderer);
|
||||
|
||||
struct wlr_compositor *compositor =
|
||||
wlr_compositor_create(server.display, renderer);
|
||||
wlr_compositor_create(server.display, server.renderer);
|
||||
|
||||
wlr_xdg_shell_create(server.display);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
|
@ -18,6 +19,8 @@ struct sample_state {
|
|||
struct wl_display *display;
|
||||
struct wl_listener new_output;
|
||||
struct wl_listener new_input;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct timespec last_frame;
|
||||
float color[4];
|
||||
int dec;
|
||||
|
@ -61,8 +64,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
wlr_output_attach_render(wlr_output, NULL);
|
||||
|
||||
struct wlr_renderer *renderer =
|
||||
wlr_backend_get_renderer(wlr_output->backend);
|
||||
struct wlr_renderer *renderer = sample->renderer;
|
||||
wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
|
||||
wlr_renderer_clear(renderer, sample->color);
|
||||
wlr_renderer_end(renderer);
|
||||
|
@ -84,6 +86,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
struct wlr_output *output = data;
|
||||
struct sample_state *sample =
|
||||
wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output =
|
||||
calloc(1, sizeof(struct sample_output));
|
||||
sample_output->output = output;
|
||||
|
@ -171,6 +176,10 @@ int main(void) {
|
|||
if (!backend) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
state.renderer = wlr_renderer_autocreate(backend);
|
||||
state.allocator = wlr_allocator_autocreate(backend, state.renderer);
|
||||
|
||||
wl_signal_add(&backend->events.new_output, &state.new_output);
|
||||
state.new_output.notify = new_output_notify;
|
||||
wl_signal_add(&backend->events.new_input, &state.new_input);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
|
@ -22,6 +23,7 @@
|
|||
struct sample_state {
|
||||
struct wl_display *display;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
bool proximity, tap, button;
|
||||
double distance;
|
||||
double pressure;
|
||||
|
@ -237,6 +239,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
sample_output->output = output;
|
||||
sample_output->sample = sample;
|
||||
|
@ -361,11 +366,14 @@ int main(int argc, char *argv[]) {
|
|||
state.new_input.notify = new_input_notify;
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.last_frame);
|
||||
|
||||
state.renderer = wlr_backend_get_renderer(wlr);
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
if (!state.renderer) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
if (!wlr_backend_start(wlr)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
|
@ -23,6 +24,7 @@
|
|||
struct sample_state {
|
||||
struct wl_display *display;
|
||||
struct wlr_renderer *renderer;
|
||||
struct wlr_allocator *allocator;
|
||||
struct wlr_texture *cat_texture;
|
||||
struct wl_list touch_points;
|
||||
struct timespec last_frame;
|
||||
|
@ -148,6 +150,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
|
|||
static void new_output_notify(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct sample_state *sample = wl_container_of(listener, sample, new_output);
|
||||
|
||||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
|
||||
sample_output->output = output;
|
||||
sample_output->sample = sample;
|
||||
|
@ -254,8 +259,7 @@ int main(int argc, char *argv[]) {
|
|||
state.new_input.notify = new_input_notify;
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.last_frame);
|
||||
|
||||
|
||||
state.renderer = wlr_backend_get_renderer(wlr);
|
||||
state.renderer = wlr_renderer_autocreate(wlr);
|
||||
if (!state.renderer) {
|
||||
wlr_log(WLR_ERROR, "Could not start compositor, OOM");
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -268,6 +272,8 @@ int main(int argc, char *argv[]) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
|
||||
|
||||
if (!wlr_backend_start(wlr)) {
|
||||
wlr_log(WLR_ERROR, "Failed to start backend");
|
||||
wlr_backend_destroy(wlr);
|
||||
|
|
Loading…
Reference in New Issue