diff options
author | wm4 <wm4@nowhere> | 2020-05-22 14:18:35 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-22 14:18:35 +0200 |
commit | 77f730f63c340fc88e8c3db0cb73cff1807d7432 (patch) | |
tree | 0e5c9491454fe367534837b5103455a4b977a016 /video | |
parent | 1be32529b161d6c67d51004062ee4e6280036fb3 (diff) | |
download | mpv-77f730f63c340fc88e8c3db0cb73cff1807d7432.tar.bz2 mpv-77f730f63c340fc88e8c3db0cb73cff1807d7432.tar.xz |
mp_image: add helper for clearing regions outside of a rectangle
Not sure if generally useful; the following commit uses it.
Diffstat (limited to 'video')
-rw-r--r-- | video/mp_image.c | 14 | ||||
-rw-r--r-- | video/mp_image.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 81d2b7e04f..0e95a59808 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -678,6 +678,20 @@ void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1) } } +void mp_image_clear_rc(struct mp_image *mpi, struct mp_rect rc) +{ + mp_image_clear(mpi, rc.x0, rc.y0, rc.x1, rc.y1); +} + +// Clear the are of the image _not_ covered by rc. +void mp_image_clear_rc_inv(struct mp_image *mpi, struct mp_rect rc) +{ + struct mp_rect clr[4]; + int cnt = mp_rect_subtract(&(struct mp_rect){0, 0, mpi->w, mpi->h}, &rc, clr); + for (int n = 0; n < cnt; n++) + mp_image_clear_rc(mpi, clr[n]); +} + void mp_image_vflip(struct mp_image *img) { for (int p = 0; p < img->num_planes; p++) { diff --git a/video/mp_image.h b/video/mp_image.h index 5b7eada496..dd82251464 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -137,6 +137,8 @@ void mp_image_setrefp(struct mp_image **p_img, struct mp_image *new_value); void mp_image_unrefp(struct mp_image **p_img); void mp_image_clear(struct mp_image *mpi, int x0, int y0, int x1, int y1); +void mp_image_clear_rc(struct mp_image *mpi, struct mp_rect rc); +void mp_image_clear_rc_inv(struct mp_image *mpi, struct mp_rect rc); void mp_image_crop(struct mp_image *img, int x0, int y0, int x1, int y1); void mp_image_crop_rc(struct mp_image *img, struct mp_rect rc); void mp_image_vflip(struct mp_image *img); |