mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Handle failure to reference a buffer name better
This commit is contained in:
		
							parent
							
								
									5b75f1b218
								
							
						
					
					
						commit
						c071f4d008
					
				
					 5 changed files with 34 additions and 12 deletions
				
			
		
							
								
								
									
										34
									
								
								compositor.c
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								compositor.c
									
										
									
									
									
								
							| 
						 | 
					@ -442,6 +442,7 @@ surface_attach(struct wl_client *client,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlsc_surface *es = (struct wlsc_surface *) surface;
 | 
						struct wlsc_surface *es = (struct wlsc_surface *) surface;
 | 
				
			||||||
	struct wlsc_compositor *ec = es->compositor;
 | 
						struct wlsc_compositor *ec = es->compositor;
 | 
				
			||||||
 | 
						EGLImageKHR image;
 | 
				
			||||||
	EGLint attribs[] = {
 | 
						EGLint attribs[] = {
 | 
				
			||||||
		EGL_WIDTH,		0,
 | 
							EGL_WIDTH,		0,
 | 
				
			||||||
		EGL_HEIGHT,		0,
 | 
							EGL_HEIGHT,		0,
 | 
				
			||||||
| 
						 | 
					@ -450,14 +451,36 @@ surface_attach(struct wl_client *client,
 | 
				
			||||||
		EGL_NONE
 | 
							EGL_NONE
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						attribs[1] = width;
 | 
				
			||||||
 | 
						attribs[3] = height;
 | 
				
			||||||
 | 
						attribs[5] = stride / 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						image = eglCreateImageKHR(ec->display, ec->context,
 | 
				
			||||||
 | 
									  EGL_DRM_IMAGE_MESA,
 | 
				
			||||||
 | 
									  (EGLClientBuffer) name, attribs);
 | 
				
			||||||
 | 
						if (image == NULL) {
 | 
				
			||||||
 | 
							/* FIXME: Define a real exception event instead of
 | 
				
			||||||
 | 
							 * abusing this one */
 | 
				
			||||||
 | 
							wl_client_post_event(client, ec->wl_display,
 | 
				
			||||||
 | 
									     WL_DISPLAY_INVALID_OBJECT, 0);
 | 
				
			||||||
 | 
							fprintf(stderr, "failed to create image for name %d\n", name);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (visual == &ec->argb_visual)
 | 
						if (visual == &ec->argb_visual)
 | 
				
			||||||
		es->visual = &ec->argb_visual;
 | 
							es->visual = &ec->argb_visual;
 | 
				
			||||||
	else if (visual == &ec->premultiplied_argb_visual)
 | 
						else if (visual == &ec->premultiplied_argb_visual)
 | 
				
			||||||
		es->visual = &ec->premultiplied_argb_visual;
 | 
							es->visual = &ec->premultiplied_argb_visual;
 | 
				
			||||||
	else if (visual == &ec->rgb_visual)
 | 
						else if (visual == &ec->rgb_visual)
 | 
				
			||||||
		es->visual = &ec->rgb_visual;
 | 
							es->visual = &ec->rgb_visual;
 | 
				
			||||||
	else
 | 
						else {
 | 
				
			||||||
		/* FIXME: Smack client with an exception event */;
 | 
							/* FIXME: Define a real exception event instead of
 | 
				
			||||||
 | 
							 * abusing this one */
 | 
				
			||||||
 | 
							wl_client_post_event(client, ec->display,
 | 
				
			||||||
 | 
									     WL_DISPLAY_INVALID_OBJECT, 0);
 | 
				
			||||||
 | 
							fprintf(stderr, "invalid visual in surface_attach\n");
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glBindTexture(GL_TEXTURE_2D, es->texture);
 | 
						glBindTexture(GL_TEXTURE_2D, es->texture);
 | 
				
			||||||
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
| 
						 | 
					@ -468,13 +491,8 @@ surface_attach(struct wl_client *client,
 | 
				
			||||||
	if (es->image)
 | 
						if (es->image)
 | 
				
			||||||
		eglDestroyImageKHR(ec->display, es->image);
 | 
							eglDestroyImageKHR(ec->display, es->image);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	attribs[1] = width;
 | 
						es->image = image;
 | 
				
			||||||
	attribs[3] = height;
 | 
					 | 
				
			||||||
	attribs[5] = stride / 4;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	es->image = eglCreateImageKHR(ec->display, ec->context,
 | 
					 | 
				
			||||||
				      EGL_DRM_IMAGE_MESA,
 | 
					 | 
				
			||||||
				      (EGLClientBuffer) name, attribs);
 | 
					 | 
				
			||||||
	glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, es->image);
 | 
						glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, es->image);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include <ffi.h>
 | 
					#include <ffi.h>
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "wayland-util.h"
 | 
					#include "wayland-util.h"
 | 
				
			||||||
#include "connection.h"
 | 
					#include "connection.h"
 | 
				
			||||||
| 
						 | 
					@ -69,6 +70,7 @@ wl_connection_create(int fd,
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
wl_connection_destroy(struct wl_connection *connection)
 | 
					wl_connection_destroy(struct wl_connection *connection)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						close(connection->fd);
 | 
				
			||||||
	free(connection);
 | 
						free(connection);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -308,6 +308,7 @@ display_handle_invalid_object(void *data,
 | 
				
			||||||
			      struct wl_display *display, uint32_t id)
 | 
								      struct wl_display *display, uint32_t id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	fprintf(stderr, "sent request to invalid object\n");
 | 
						fprintf(stderr, "sent request to invalid object\n");
 | 
				
			||||||
 | 
						abort();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
			      
 | 
								      
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -316,6 +317,7 @@ display_handle_invalid_method(void *data,
 | 
				
			||||||
			      uint32_t id, uint32_t opcode)
 | 
								      uint32_t id, uint32_t opcode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	fprintf(stderr, "sent invalid request opcode\n");
 | 
						fprintf(stderr, "sent invalid request opcode\n");
 | 
				
			||||||
 | 
						abort();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -323,6 +325,7 @@ display_handle_no_memory(void *data,
 | 
				
			||||||
			 struct wl_display *display)
 | 
								 struct wl_display *display)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	fprintf(stderr, "server out of memory\n");
 | 
						fprintf(stderr, "server out of memory\n");
 | 
				
			||||||
 | 
						abort();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,9 +65,6 @@ struct wl_global {
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					 | 
				
			||||||
wl_client_destroy(struct wl_client *client);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WL_EXPORT void
 | 
					WL_EXPORT void
 | 
				
			||||||
wl_client_post_event(struct wl_client *client, struct wl_object *sender,
 | 
					wl_client_post_event(struct wl_client *client, struct wl_object *sender,
 | 
				
			||||||
		     uint32_t opcode, ...)
 | 
							     uint32_t opcode, ...)
 | 
				
			||||||
| 
						 | 
					@ -210,7 +207,7 @@ wl_object_destroy(struct wl_object *object)
 | 
				
			||||||
	interface->destroy(NULL, (struct wl_surface *) object);
 | 
						interface->destroy(NULL, (struct wl_surface *) object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					WL_EXPORT void
 | 
				
			||||||
wl_client_destroy(struct wl_client *client)
 | 
					wl_client_destroy(struct wl_client *client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_surface *surface;
 | 
						struct wl_surface *surface;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,6 +89,8 @@ typedef void (*wl_client_connect_func_t)(struct wl_client *client, struct wl_obj
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int wl_display_add_global(struct wl_display *display, struct wl_object *object, wl_client_connect_func_t func);
 | 
					int wl_display_add_global(struct wl_display *display, struct wl_object *object, wl_client_connect_func_t func);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wl_client_destroy(struct wl_client *client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_compositor {
 | 
					struct wl_compositor {
 | 
				
			||||||
	struct wl_object base;
 | 
						struct wl_object base;
 | 
				
			||||||
	const char *device;
 | 
						const char *device;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue