aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-08 02:11:56 +0200
committeremersion <contact@emersion.fr>2017-10-08 02:11:56 +0200
commit0ce313530446b801302850f03c4a8d8c20cfd782 (patch)
treecc0779ca8ef0000fb3e357fb1ac9c96bf2bed51e /render/gles2
parent55c063f440fd12b1ee8bba5cef56a75c33e66719 (diff)
Move read_pixels from output to renderer
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/renderer.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index d6c22ebe..9a013338 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -226,7 +226,23 @@ static bool wlr_gles2_buffer_is_drm(struct wlr_renderer *_renderer,
(struct wlr_gles2_renderer *)_renderer;
EGLint format;
return wlr_egl_query_buffer(renderer->egl, buffer,
- EGL_TEXTURE_FORMAT, &format);
+ EGL_TEXTURE_FORMAT, &format);
+}
+
+static void rgba_to_argb(uint32_t *data, size_t height, size_t stride) {
+ size_t n = height*stride/4;
+ for (size_t i = 0; i < n; ++i) {
+ uint32_t v = data[i];
+ uint32_t rgb = (v & 0xffffff00) >> 8;
+ uint32_t a = v & 0x000000ff;
+ data[i] = rgb | (a << 24);
+ }
+}
+
+static void wlr_gles2_read_pixels(struct wlr_renderer *renderer, int x, int y,
+ int width, int height, void *out_data) {
+ glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, out_data);
+ rgba_to_argb(out_data, height, width*4);
}
static struct wlr_renderer_impl wlr_renderer_impl = {
@@ -238,6 +254,7 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
.render_ellipse = wlr_gles2_render_ellipse,
.formats = wlr_gles2_formats,
.buffer_is_drm = wlr_gles2_buffer_is_drm,
+ .read_pixels = wlr_gles2_read_pixels,
};
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) {