mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-23 08:56:29 -05:00
render/gles2: use wlr_drm for wl_drm implementation
This allows use to remove all of our special wl_drm support code.
This commit is contained in:
parent
d7b19fb294
commit
4e07d4cbf9
2 changed files with 4 additions and 113 deletions
|
|
@ -234,81 +234,6 @@ static struct wlr_texture *gles2_texture_from_pixels(
|
|||
return &texture->wlr_texture;
|
||||
}
|
||||
|
||||
struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
||||
|
||||
if (!renderer->procs.glEGLImageTargetTexture2DOES) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_egl_context prev_ctx;
|
||||
wlr_egl_save_context(&prev_ctx);
|
||||
wlr_egl_make_current(renderer->egl);
|
||||
|
||||
EGLint fmt;
|
||||
int width, height;
|
||||
bool inverted_y;
|
||||
EGLImageKHR image = wlr_egl_create_image_from_wl_drm(renderer->egl, resource,
|
||||
&fmt, &width, &height, &inverted_y);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
wlr_log(WLR_ERROR, "Failed to create EGL image from wl_drm resource");
|
||||
goto error_ctx;
|
||||
}
|
||||
|
||||
struct wlr_gles2_texture *texture =
|
||||
gles2_texture_create(renderer, width, height);
|
||||
if (texture == NULL) {
|
||||
goto error_image;
|
||||
}
|
||||
wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height);
|
||||
texture->renderer = renderer;
|
||||
|
||||
texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways
|
||||
texture->image = image;
|
||||
texture->inverted_y = inverted_y;
|
||||
|
||||
switch (fmt) {
|
||||
case EGL_TEXTURE_RGB:
|
||||
texture->has_alpha = false;
|
||||
break;
|
||||
case EGL_TEXTURE_RGBA:
|
||||
case EGL_TEXTURE_EXTERNAL_WL:
|
||||
texture->has_alpha = true;
|
||||
break;
|
||||
default:
|
||||
wlr_log(WLR_ERROR, "Invalid or unsupported EGL buffer format");
|
||||
goto error_texture;
|
||||
}
|
||||
|
||||
texture->target = GL_TEXTURE_EXTERNAL_OES;
|
||||
|
||||
push_gles2_debug(renderer);
|
||||
|
||||
glGenTextures(1, &texture->tex);
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture->tex);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
renderer->procs.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
|
||||
texture->image);
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
|
||||
|
||||
pop_gles2_debug(renderer);
|
||||
|
||||
wlr_egl_restore_context(&prev_ctx);
|
||||
|
||||
return &texture->wlr_texture;
|
||||
|
||||
error_texture:
|
||||
wl_list_remove(&texture->link);
|
||||
free(texture);
|
||||
error_image:
|
||||
wlr_egl_destroy_image(renderer->egl, image);
|
||||
error_ctx:
|
||||
wlr_egl_restore_context(&prev_ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct wlr_texture *gles2_texture_from_dmabuf(
|
||||
struct wlr_renderer *wlr_renderer,
|
||||
struct wlr_dmabuf_attributes *attribs) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue