aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-14 19:36:17 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-06-07 09:22:56 -0400
commit6e43d642b2d0db5a3bd711507133abdb4da2d47c (patch)
tree98d8bec1c1380853259789ca51e411f5d48978c9 /render
parent38ba5881a078eb35b3f82abaf5e4873a9a3a981e (diff)
render/gles2: add support for DATA_PTR buffers in texture_from_buffer
Diffstat (limited to 'render')
-rw-r--r--render/gles2/texture.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 7d8ad106..d42cff18 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -13,6 +13,7 @@
#include <wlr/util/log.h>
#include "render/gles2.h"
#include "render/pixel_format.h"
+#include "types/wlr_buffer.h"
#include "util/signal.h"
static const struct wlr_texture_impl texture_impl;
@@ -364,15 +365,9 @@ static void texture_handle_buffer_destroy(struct wl_listener *listener,
gles2_texture_destroy(texture);
}
-struct wlr_texture *gles2_texture_from_buffer(struct wlr_renderer *wlr_renderer,
- struct wlr_buffer *buffer) {
- struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
-
- struct wlr_dmabuf_attributes dmabuf;
- if (!wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
- return false;
- }
-
+static struct wlr_texture *gles2_texture_from_dmabuf_buffer(
+ struct wlr_gles2_renderer *renderer, struct wlr_buffer *buffer,
+ struct wlr_dmabuf_attributes *dmabuf) {
struct wlr_gles2_texture *texture;
wl_list_for_each(texture, &renderer->textures, link) {
if (texture->buffer == buffer) {
@@ -386,7 +381,7 @@ struct wlr_texture *gles2_texture_from_buffer(struct wlr_renderer *wlr_renderer,
}
struct wlr_texture *wlr_texture =
- gles2_texture_from_dmabuf(wlr_renderer, &dmabuf);
+ gles2_texture_from_dmabuf(&renderer->wlr_renderer, dmabuf);
if (wlr_texture == NULL) {
return false;
}
@@ -400,6 +395,26 @@ struct wlr_texture *gles2_texture_from_buffer(struct wlr_renderer *wlr_renderer,
return &texture->wlr_texture;
}
+struct wlr_texture *gles2_texture_from_buffer(struct wlr_renderer *wlr_renderer,
+ struct wlr_buffer *buffer) {
+ struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
+
+ void *data;
+ uint32_t format;
+ size_t stride;
+ struct wlr_dmabuf_attributes dmabuf;
+ if (wlr_buffer_get_dmabuf(buffer, &dmabuf)) {
+ return gles2_texture_from_dmabuf_buffer(renderer, buffer, &dmabuf);
+ } else if (buffer_begin_data_ptr_access(buffer, &data, &format, &stride)) {
+ struct wlr_texture *tex = gles2_texture_from_pixels(wlr_renderer,
+ format, stride, buffer->width, buffer->height, data);
+ buffer_end_data_ptr_access(buffer);
+ return tex;
+ } else {
+ return NULL;
+ }
+}
+
void wlr_gles2_texture_get_attribs(struct wlr_texture *wlr_texture,
struct wlr_gles2_texture_attribs *attribs) {
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);