Merge pull request #48 from nyorain/wlr_texture

Rename wlr_surface -> wlr_texture; attach -> upload
This commit is contained in:
Drew DeVault 2017-08-08 13:12:16 -04:00 committed by GitHub
commit ba87585bbe
20 changed files with 233 additions and 233 deletions

View file

@ -32,11 +32,11 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) {
struct wl_resource *_res;
float matrix[16];
wl_list_for_each(_res, &sample->compositor.surfaces, link) {
struct wlr_surface *surface = wl_resource_get_user_data(_res);
if (surface->valid) {
wlr_surface_get_matrix(surface, &matrix,
struct wlr_texture *texture = wl_resource_get_user_data(_res);
if (texture->valid) {
wlr_texture_get_matrix(texture, &matrix,
&wlr_output->transform_matrix, 200, 200);
wlr_render_with_matrix(sample->renderer, surface, &matrix);
wlr_render_with_matrix(sample->renderer, texture, &matrix);
}
}

View file

@ -10,10 +10,10 @@ static void surface_destroy(struct wl_client *client, struct wl_resource *resour
static void surface_attach(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *buffer_resource, int32_t sx, int32_t sy) {
struct wlr_surface *surface = wl_resource_get_user_data(resource);
struct wlr_texture *texture = wl_resource_get_user_data(resource);
struct wl_shm_buffer *buffer = wl_shm_buffer_get(buffer_resource);
uint32_t format = wl_shm_buffer_get_format(buffer);
wlr_surface_attach_shm(surface, format, buffer);
wlr_texture_upload_shm(texture, format, buffer);
}
static void surface_damage(struct wl_client *client,
@ -78,13 +78,13 @@ struct wl_surface_interface surface_interface = {
};
static void destroy_surface(struct wl_resource *resource) {
struct wlr_surface *surface = wl_resource_get_user_data(resource);
wlr_surface_destroy(surface);
struct wlr_texture *surface = wl_resource_get_user_data(resource);
wlr_texture_destroy(surface);
}
static void destroy_surface_listener(struct wl_listener *listener, void *data) {
struct wl_compositor_state *state;
struct wlr_surface *surface = data;
struct wlr_texture *surface = data;
state = wl_container_of(listener, state, destroy_surface_listener);
struct wl_resource *res = NULL;
@ -101,13 +101,13 @@ static void wl_compositor_create_surface(struct wl_client *client,
struct wl_compositor_state *state = wl_resource_get_user_data(resource);
struct wl_resource *surface_resource = wl_resource_create(client,
&wl_surface_interface, wl_resource_get_version(resource), id);
struct wlr_surface *surface = wlr_render_surface_init(state->renderer);
surface->resource = surface_resource;
struct wlr_texture *texture = wlr_render_texture_init(state->renderer);
texture->resource = surface_resource;
wl_resource_set_implementation(surface_resource, &surface_interface,
surface, destroy_surface);
wl_resource_set_user_data(surface_resource, surface);
texture, destroy_surface);
wl_resource_set_user_data(surface_resource, texture);
wl_list_insert(&state->surfaces, wl_resource_get_link(surface_resource));
wl_signal_add(&surface->destroy_signal, &state->destroy_surface_listener);
wl_signal_add(&texture->destroy_signal, &state->destroy_surface_listener);
}
static void wl_compositor_create_region(struct wl_client *client,

View file

@ -23,7 +23,7 @@
struct sample_state {
struct wl_list config;
struct wlr_renderer *renderer;
struct wlr_surface *cat_texture;
struct wlr_texture *cat_texture;
};
struct output_data {
@ -52,7 +52,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
float matrix[16];
for (int y = -128 + (int)odata->y_offs; y < height; y += 128) {
for (int x = -128 + (int)odata->x_offs; x < width; x += 128) {
wlr_surface_get_matrix(sample->cat_texture, &matrix,
wlr_texture_get_matrix(sample->cat_texture, &matrix,
&wlr_output->transform_matrix, x, y);
wlr_render_with_matrix(sample->renderer,
sample->cat_texture, &matrix);
@ -205,13 +205,13 @@ int main(int argc, char *argv[]) {
compositor_init(&compositor);
state.renderer = wlr_gles2_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
wlr_surface_attach_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888,
state.cat_texture = wlr_render_texture_init(state.renderer);
wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888,
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor_run(&compositor);
wlr_surface_destroy(state.cat_texture);
wlr_texture_destroy(state.cat_texture);
wlr_renderer_destroy(state.renderer);
struct output_config *ptr, *tmp;

View file

@ -22,7 +22,7 @@
struct sample_state {
struct wlr_renderer *renderer;
struct wlr_surface *cat_texture;
struct wlr_texture *cat_texture;
list_t *touch_points;
};
@ -45,7 +45,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
float matrix[16];
for (size_t i = 0; i < sample->touch_points->length; ++i) {
struct touch_point *p = sample->touch_points->items[i];
wlr_surface_get_matrix(sample->cat_texture, &matrix,
wlr_texture_get_matrix(sample->cat_texture, &matrix,
&wlr_output->transform_matrix,
(int)(p->x * width) - sample->cat_texture->width / 2,
(int)(p->y * height) - sample->cat_texture->height / 2);
@ -105,12 +105,12 @@ int main(int argc, char *argv[]) {
compositor_init(&compositor);
state.renderer = wlr_gles2_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
wlr_surface_attach_pixels(state.cat_texture, WL_SHM_FORMAT_ARGB8888,
state.cat_texture = wlr_render_texture_init(state.renderer);
wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ARGB8888,
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor_run(&compositor);
wlr_surface_destroy(state.cat_texture);
wlr_texture_destroy(state.cat_texture);
wlr_renderer_destroy(state.renderer);
}