@ -51,7 +51,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
struct wlr_gles2_texture * 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 " ) ;
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?
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_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 ) ;
if ( ! texture - > image ) {
assert ( texture - > t ype = = WLR_GLES2_TEXTURE_GLTEX ) ;
assert ( texture - > t arget = = GL_TEXTURE_2D ) ;
if ( ! eglCreateImageKHR ) {
return false ;
@ -93,7 +93,7 @@ static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture,
texture - > image = eglCreateImageKHR ( texture - > egl - > display ,
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 ) {
return false ;
}
@ -121,15 +121,9 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
PUSH_GLES2_DEBUG ;
if ( texture - > image_tex ) {
glDeleteTextures ( 1 , & texture - > image_tex ) ;
}
glDeleteTextures ( 1 , & texture - > tex ) ;
wlr_egl_destroy_image ( texture - > egl , texture - > image ) ;
if ( texture - > type = = WLR_GLES2_TEXTURE_GLTEX ) {
glDeleteTextures ( 1 , & texture - > gl_tex ) ;
}
POP_GLES2_DEBUG ;
free ( texture ) ;
@ -166,14 +160,14 @@ struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl,
texture - > egl = egl ;
texture - > width = width ;
texture - > height = height ;
texture - > t ype = WLR_GLES2_TEXTURE_GLTEX ;
texture - > t arget = GL_TEXTURE_2D ;
texture - > has_alpha = fmt - > has_alpha ;
texture - > wl_format = fmt - > wl_format ;
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > gl_ tex) ;
glBindTexture ( GL_TEXTURE_2D , texture - > gl_ tex) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( GL_TEXTURE_2D , texture - > tex) ;
glPixelStorei ( GL_UNPACK_ROW_LENGTH_EXT , stride / ( fmt - > bpp / 8 ) ) ;
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 ) ;
texture - > egl = egl ;
texture - > wl_drm = data ;
EGLint fmt ;
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 ;
}
GLenum target ;
switch ( fmt ) {
case EGL_TEXTURE_RGB :
case EGL_TEXTURE_RGBA :
target = GL_TEXTURE_2D ;
texture - > type = WLR_GLES2_TEXTURE_WL_DRM_GL ;
texture - > has_alpha = fmt = = EGL_TEXTURE_RGBA ;
texture - > has_alpha = false ;
break ;
case EGL_TEXTURE_RGBA :
case EGL_TEXTURE_EXTERNAL_WL :
target = GL_TEXTURE_EXTERNAL_OES ;
texture - > type = WLR_GLES2_TEXTURE_WL_DRM_EXT ;
texture - > has_alpha = true ;
break ;
default :
@ -232,11 +220,13 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
return NULL ;
}
texture - > target = GL_TEXTURE_EXTERNAL_OES ;
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > image_ tex) ;
glBindTexture ( target , texture - > image_ tex) ;
glEGLImageTargetTexture2DOES ( target , texture - > image ) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > tex) ;
glEGLImageTargetTexture2DOES ( GL_TEXTURE_EXTERNAL_OES , texture - > image ) ;
POP_GLES2_DEBUG ;
return & texture - > wlr_texture ;
@ -280,7 +270,7 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
texture - > egl = egl ;
texture - > width = attribs - > width ;
texture - > height = attribs - > height ;
texture - > t ype = WLR_GLES2_TEXTURE_DMABUF ;
texture - > t arget = GL_TEXTURE_EXTERNAL_OES ;
texture - > has_alpha = true ;
texture - > wl_format = 0xFFFFFFFF ; // texture can't be written anyways
texture - > inverted_y =
@ -294,8 +284,8 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
PUSH_GLES2_DEBUG ;
glGenTextures ( 1 , & texture - > image_ tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > image_ tex) ;
glGenTextures ( 1 , & texture - > tex) ;
glBindTexture ( GL_TEXTURE_EXTERNAL_OES , texture - > tex) ;
glEGLImageTargetTexture2DOES ( GL_TEXTURE_EXTERNAL_OES , texture - > image ) ;
POP_GLES2_DEBUG ;