mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Change wl_shm_buffer to use a resource pointer
This commit also has the effect of making wl_shm_buffer no longer a wl_buffer derivative. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
		
							parent
							
								
									ee0d986a50
								
							
						
					
					
						commit
						3af748b872
					
				
					 2 changed files with 19 additions and 37 deletions
				
			
		| 
						 | 
					@ -305,13 +305,10 @@ wl_shm_buffer_get_width(struct wl_shm_buffer *buffer);
 | 
				
			||||||
int32_t
 | 
					int32_t
 | 
				
			||||||
wl_shm_buffer_get_height(struct wl_shm_buffer *buffer);
 | 
					wl_shm_buffer_get_height(struct wl_shm_buffer *buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					 | 
				
			||||||
wl_buffer_is_shm(struct wl_buffer *buffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
wl_display_init_shm(struct wl_display *display);
 | 
					wl_display_init_shm(struct wl_display *display);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_buffer *
 | 
					struct wl_shm_buffer *
 | 
				
			||||||
wl_shm_buffer_create(struct wl_client *client,
 | 
					wl_shm_buffer_create(struct wl_client *client,
 | 
				
			||||||
		     uint32_t id, int32_t width, int32_t height,
 | 
							     uint32_t id, int32_t width, int32_t height,
 | 
				
			||||||
		     int32_t stride, uint32_t format);
 | 
							     int32_t stride, uint32_t format);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,8 @@ struct wl_shm_pool {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_shm_buffer {
 | 
					struct wl_shm_buffer {
 | 
				
			||||||
	struct wl_buffer buffer;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
 | 
						int32_t width, height;
 | 
				
			||||||
	int32_t stride;
 | 
						int32_t stride;
 | 
				
			||||||
	uint32_t format;
 | 
						uint32_t format;
 | 
				
			||||||
	int offset;
 | 
						int offset;
 | 
				
			||||||
| 
						 | 
					@ -118,23 +119,18 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer->buffer.width = width;
 | 
						buffer->width = width;
 | 
				
			||||||
	buffer->buffer.height = height;
 | 
						buffer->height = height;
 | 
				
			||||||
	buffer->buffer.busy_count = 0;
 | 
					 | 
				
			||||||
	buffer->format = format;
 | 
						buffer->format = format;
 | 
				
			||||||
	buffer->stride = stride;
 | 
						buffer->stride = stride;
 | 
				
			||||||
	buffer->offset = offset;
 | 
						buffer->offset = offset;
 | 
				
			||||||
	buffer->pool = pool;
 | 
						buffer->pool = pool;
 | 
				
			||||||
	pool->refcount++;
 | 
						pool->refcount++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer->buffer.resource.object.id = id;
 | 
						buffer->resource = wl_client_add_object(client, &wl_buffer_interface,
 | 
				
			||||||
	buffer->buffer.resource.object.interface = &wl_buffer_interface;
 | 
											&shm_buffer_interface,
 | 
				
			||||||
	buffer->buffer.resource.object.implementation = &shm_buffer_interface;
 | 
											id, buffer);
 | 
				
			||||||
	buffer->buffer.resource.data = buffer;
 | 
						wl_resource_set_destructor(buffer->resource, destroy_buffer);
 | 
				
			||||||
	buffer->buffer.resource.client = client;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.destroy = destroy_buffer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	wl_client_add_resource(client, &buffer->buffer.resource);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -249,7 +245,7 @@ wl_display_init_shm(struct wl_display *display)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WL_EXPORT struct wl_buffer *
 | 
					WL_EXPORT struct wl_shm_buffer *
 | 
				
			||||||
wl_shm_buffer_create(struct wl_client *client,
 | 
					wl_shm_buffer_create(struct wl_client *client,
 | 
				
			||||||
		     uint32_t id, int32_t width, int32_t height,
 | 
							     uint32_t id, int32_t width, int32_t height,
 | 
				
			||||||
		     int32_t stride, uint32_t format)
 | 
							     int32_t stride, uint32_t format)
 | 
				
			||||||
| 
						 | 
					@ -268,24 +264,20 @@ wl_shm_buffer_create(struct wl_client *client,
 | 
				
			||||||
	if (buffer == NULL)
 | 
						if (buffer == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer->buffer.width = width;
 | 
						buffer->width = width;
 | 
				
			||||||
	buffer->buffer.height = height;
 | 
						buffer->height = height;
 | 
				
			||||||
	buffer->buffer.busy_count = 0;
 | 
					 | 
				
			||||||
	buffer->format = format;
 | 
						buffer->format = format;
 | 
				
			||||||
	buffer->stride = stride;
 | 
						buffer->stride = stride;
 | 
				
			||||||
	buffer->offset = 0;
 | 
						buffer->offset = 0;
 | 
				
			||||||
	buffer->pool = NULL;
 | 
						buffer->pool = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer->buffer.resource.object.id = id;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.object.interface = &wl_buffer_interface;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.object.implementation = &shm_buffer_interface;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.data = buffer;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.client = client;
 | 
					 | 
				
			||||||
	buffer->buffer.resource.destroy = destroy_buffer;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_client_add_resource(client, &buffer->buffer.resource);
 | 
						buffer->resource = wl_client_add_object(client, &wl_buffer_interface,
 | 
				
			||||||
 | 
											&shm_buffer_interface,
 | 
				
			||||||
 | 
											id, buffer);
 | 
				
			||||||
 | 
						wl_resource_set_destructor(buffer->resource, destroy_buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &buffer->buffer;
 | 
						return buffer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WL_EXPORT struct wl_shm_buffer *
 | 
					WL_EXPORT struct wl_shm_buffer *
 | 
				
			||||||
| 
						 | 
					@ -298,13 +290,6 @@ wl_shm_buffer_get(struct wl_resource *resource)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WL_EXPORT int
 | 
					 | 
				
			||||||
wl_buffer_is_shm(struct wl_buffer *buffer)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return buffer->resource.object.implementation == 
 | 
					 | 
				
			||||||
		(void (**)(void)) &shm_buffer_interface;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WL_EXPORT int32_t
 | 
					WL_EXPORT int32_t
 | 
				
			||||||
wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer)
 | 
					wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -329,11 +314,11 @@ wl_shm_buffer_get_format(struct wl_shm_buffer *buffer)
 | 
				
			||||||
WL_EXPORT int32_t
 | 
					WL_EXPORT int32_t
 | 
				
			||||||
wl_shm_buffer_get_width(struct wl_shm_buffer *buffer)
 | 
					wl_shm_buffer_get_width(struct wl_shm_buffer *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return buffer->buffer.width;
 | 
						return buffer->width;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WL_EXPORT int32_t
 | 
					WL_EXPORT int32_t
 | 
				
			||||||
wl_shm_buffer_get_height(struct wl_shm_buffer *buffer)
 | 
					wl_shm_buffer_get_height(struct wl_shm_buffer *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return buffer->buffer.height;
 | 
						return buffer->height;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue