aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2023-11-30 19:55:51 -0500
committerAlexander Orzechowski <alex@ozal.ski>2023-11-30 19:55:51 -0500
commite85e8bc3249aeb0eebbde1debee51a5941aa08b4 (patch)
tree597839b98614d2f80f4bac3873b181dfdab58833 /render
parent4c6caa7c48d887fb4292a08f898af83d9954d571 (diff)
wlr_texture: Introduce wlr_texture_read_pixels_options helpers
Diffstat (limited to 'render')
-rw-r--r--render/wlr_texture.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/render/wlr_texture.c b/render/wlr_texture.c
index be10f20a..3496305f 100644
--- a/render/wlr_texture.c
+++ b/render/wlr_texture.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <wlr/render/interface.h>
#include <wlr/render/wlr_texture.h>
+#include "render/pixel_format.h"
#include "types/wlr_buffer.h"
void wlr_texture_init(struct wlr_texture *texture, struct wlr_renderer *renderer,
@@ -26,6 +27,31 @@ void wlr_texture_destroy(struct wlr_texture *texture) {
}
}
+void wlr_texture_read_pixels_options_get_src_box(
+ const struct wlr_texture_read_pixels_options *options,
+ const struct wlr_texture *texture, struct wlr_box *box) {
+ if (wlr_box_empty(&options->src_box)) {
+ *box = (struct wlr_box){
+ .x = 0,
+ .y = 0,
+ .width = texture->width,
+ .height = texture->height,
+ };
+ return;
+ }
+
+ *box = options->src_box;
+}
+
+void *wlr_texture_read_pixel_options_get_data(
+ const struct wlr_texture_read_pixels_options *options) {
+ const struct wlr_pixel_format_info *fmt = drm_get_pixel_format_info(options->format);
+
+ return (char *)options->data +
+ pixel_format_info_min_stride(fmt, options->dst_x) +
+ options->dst_y * options->stride;
+}
+
bool wlr_texture_read_pixels(struct wlr_texture *texture,
const struct wlr_texture_read_pixels_options *options) {
if (!texture->impl->read_pixels) {