@ -51,7 +51,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
struct wlr_gles2_texture * texture =
struct wlr_gles2_texture * texture =
get_gles2_texture_in_context ( wlr_texture ) ;
get_gles2_texture_in_context ( wlr_texture ) ;
if ( texture - > t ype ! = WLR_GLES2_TEXTURE_GLTEX ) {
if ( texture - > t arget ! = GL_TEXTURE_2D ) {
wlr_log ( WLR_ERROR , " Cannot write pixels to immutable texture " ) ;
wlr_log ( WLR_ERROR , " Cannot write pixels to immutable texture " ) ;
return false ;
return false ;
}
}
@ -63,7 +63,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
// TODO: what if the unpack subimage extension isn't supported?
// TODO: what if the unpack subimage extension isn't supported?
PUSH_GLES2_DEBUG ;
PUSH_GLES2_DEBUG ;
glBindTexture ( GL_TEXTURE_2D , texture - > gl_ tex) ;
glBindTexture ( GL_TEXTURE_2D , texture - > tex) ;
glPixelStorei ( GL_UNPACK_ROW_LENGTH_EXT , stride / ( fmt - > bpp / 8 ) ) ;
glPixelStorei ( GL_UNPACK_ROW_LENGTH_EXT , stride / ( fmt - > bpp / 8 ) ) ;
glPixelStorei ( GL_UNPACK_SKIP_PIXELS_EXT , src_x ) ;
glPixelStorei ( GL_UNPACK_SKIP_PIXELS_EXT , src_x ) ;
@ -85,7 +85,7 @@ static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture,
struct wlr_gles2_texture * texture = gles2_get_texture ( wlr_texture ) ;
struct wlr_gles2_texture * texture = gles2_get_texture ( wlr_texture ) ;
if ( ! texture - > image ) {
if ( ! texture - > image ) {
assert ( texture - > t ype = = WLR_GLES2_TEXTURE_GLTEX ) ;
assert ( texture - > t arget = = GL_TEXTURE_2D ) ;
if ( ! eglCreateImageKHR ) {
if ( ! eglCreateImageKHR ) {
return false ;
return false ;
@ -93,7 +93,7 @@ static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture,
texture - > image = eglCreateImageKHR ( texture - > egl - > display ,
texture - > image = eglCreateImageKHR ( texture - > egl - > display ,
texture - > egl - > context , EGL_GL_TEXTURE_2D_KHR ,
texture - > egl - > context , EGL_GL_TEXTURE_2D_KHR ,
( EGLClientBuffer ) ( uintptr_t ) texture - > gl_ tex, NULL ) ;
( EGLClientBuffer ) ( uintptr_t ) texture - > tex, NULL ) ;
if ( texture - > image = = EGL_NO_IMAGE_KHR ) {
if ( texture - > image = = EGL_NO_IMAGE_KHR ) {
return false ;
return false ;
}
}
@ -121,15 +121,9 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
PUSH_GLES2_DEBUG ;
PUSH_GLES2_DEBUG ;
if ( texture - > image_tex ) {
glDeleteTextures ( 1 , & texture - > tex ) ;
glDeleteTextures ( 1 , & texture - > image_tex ) ;
}
wlr_egl_destroy_image ( texture - > egl , texture - > image ) ;
wlr_egl_destroy_image ( texture - > egl , texture - > image ) ;
if ( texture - > type = = WLR_GLES2_TEXTURE_GLTEX ) {
glDeleteTextures ( 1 , & texture - > gl_tex ) ;
}
POP_GLES2_DEBUG ;
POP_GLES2_DEBUG ;
free ( texture ) ;
free ( texture ) ;
@ -166,14 +160,14 @@ struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl,
texture - > egl = egl ;
texture - > egl = egl ;
texture - > width = width ;
texture - > width = width ;
texture - > height = height ;
texture - > height = height ;
texture - > t ype = WLR_GLES2_TEXTURE_GLTEX ;
texture - > t arget = GL_TEXTURE_2D ;
texture - > has_alpha = fmt - > has_alpha ;
texture - > has_alpha = fmt - > has_alpha ;
texture - > wl_format = fmt - > wl_format ;
texture - > wl_format = fmt - > wl_format ;
PUSH_GLES2_DEBUG ;
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > gl_ tex) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( GL_TEXTURE_2D , texture - > gl_ tex) ;
glBindTexture ( GL_TEXTURE_2D , texture - > tex) ;
glPixelStorei ( GL_UNPACK_ROW_LENGTH_EXT , stride / ( fmt - > bpp / 8 ) ) ;
glPixelStorei ( GL_UNPACK_ROW_LENGTH_EXT , stride / ( fmt - > bpp / 8 ) ) ;
glTexImage2D ( GL_TEXTURE_2D , 0 , fmt - > gl_format , width , height , 0 ,
glTexImage2D ( GL_TEXTURE_2D , 0 , fmt - > gl_format , width , height , 0 ,
@ -202,7 +196,6 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
}
}
wlr_texture_init ( & texture - > wlr_texture , & texture_impl ) ;
wlr_texture_init ( & texture - > wlr_texture , & texture_impl ) ;
texture - > egl = egl ;
texture - > egl = egl ;
texture - > wl_drm = data ;
EGLint fmt ;
EGLint fmt ;
texture - > wl_format = 0xFFFFFFFF ; // texture can't be written anyways
texture - > wl_format = 0xFFFFFFFF ; // texture can't be written anyways
@ -213,17 +206,12 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
return NULL ;
return NULL ;
}
}
GLenum target ;
switch ( fmt ) {
switch ( fmt ) {
case EGL_TEXTURE_RGB :
case EGL_TEXTURE_RGB :
case EGL_TEXTURE_RGBA :
texture - > has_alpha = false ;
target = GL_TEXTURE_2D ;
texture - > type = WLR_GLES2_TEXTURE_WL_DRM_GL ;
texture - > has_alpha = fmt = = EGL_TEXTURE_RGBA ;
break ;
break ;
case EGL_TEXTURE_RGBA :
case EGL_TEXTURE_EXTERNAL_WL :
case EGL_TEXTURE_EXTERNAL_WL :
target = GL_TEXTURE_EXTERNAL_OES ;
texture - > type = WLR_GLES2_TEXTURE_WL_DRM_EXT ;
texture - > has_alpha = true ;
texture - > has_alpha = true ;
break ;
break ;
default :
default :
@ -232,11 +220,13 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
return NULL ;
return NULL ;
}
}
texture - > target = GL_TEXTURE_EXTERNAL_OES ;
PUSH_GLES2_DEBUG ;
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > image_ tex) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( target , texture - > image_ tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > tex) ;
glEGLImageTargetTexture2DOES ( target , texture - > image ) ;
glEGLImageTargetTexture2DOES ( GL_TEXTURE_EXTERNAL_OES , texture - > image ) ;
POP_GLES2_DEBUG ;
POP_GLES2_DEBUG ;
return & texture - > wlr_texture ;
return & texture - > wlr_texture ;
@ -280,7 +270,7 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
texture - > egl = egl ;
texture - > egl = egl ;
texture - > width = attribs - > width ;
texture - > width = attribs - > width ;
texture - > height = attribs - > height ;
texture - > height = attribs - > height ;
texture - > t ype = WLR_GLES2_TEXTURE_DMABUF ;
texture - > t arget = GL_TEXTURE_EXTERNAL_OES ;
texture - > has_alpha = true ;
texture - > has_alpha = true ;
texture - > wl_format = 0xFFFFFFFF ; // texture can't be written anyways
texture - > wl_format = 0xFFFFFFFF ; // texture can't be written anyways
texture - > inverted_y =
texture - > inverted_y =
@ -294,8 +284,8 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
PUSH_GLES2_DEBUG ;
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > image_ tex) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > image_ tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > tex) ;
glEGLImageTargetTexture2DOES ( GL_TEXTURE_EXTERNAL_OES , texture - > image ) ;
glEGLImageTargetTexture2DOES ( GL_TEXTURE_EXTERNAL_OES , texture - > image ) ;
POP_GLES2_DEBUG ;
POP_GLES2_DEBUG ;