[vlc-commits] vout: DrawRect: refactor and memset
Francois Cartegnie
git at videolan.org
Mon Nov 27 15:38:22 CET 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 27 12:53:38 2017 +0100| [d8476023cd8e402c59356733d0e0670ea19c95f2] | committer: Francois Cartegnie
vout: DrawRect: refactor and memset
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d8476023cd8e402c59356733d0e0670ea19c95f2
---
src/video_output/video_widgets.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/video_output/video_widgets.c b/src/video_output/video_widgets.c
index 61c7dcc75e..c143d7ec6e 100644
--- a/src/video_output/video_widgets.c
+++ b/src/video_output/video_widgets.c
@@ -51,21 +51,21 @@ static void DrawRect(subpicture_region_t *r, int fill, uint8_t color,
{
uint8_t *p = r->p_picture->p->p_pixels;
int pitch = r->p_picture->p->i_pitch;
+ if( x1 > x2 || y1 > y2 )
+ return;
if (fill == STYLE_FILLED) {
- for (int y = y1; y <= y2; y++) {
- for (int x = x1; x <= x2; x++)
- p[x + pitch * y] = color;
+ if(x1 == 0 && x2 + 1 == r->p_picture->p->i_visible_pitch) {
+ memset(&p[pitch * y1], color, pitch * (y2 - y1 + 1));
+ } else {
+ for (int y = y1; y <= y2; y++)
+ memset(&p[x1 + pitch * y], color, x2 - x1 + 1);
}
} else {
- for (int y = y1; y <= y2; y++) {
- p[x1 + pitch * y] = color;
- p[x2 + pitch * y] = color;
- }
- for (int x = x1; x <= x2; x++) {
- p[x + pitch * y1] = color;
- p[x + pitch * y2] = color;
- }
+ DrawRect(r, STYLE_FILLED, color, x1, y1, x1, y2);
+ DrawRect(r, STYLE_FILLED, color, x2, y1, x2, y2);
+ DrawRect(r, STYLE_FILLED, color, x1, y1, x2, y1);
+ DrawRect(r, STYLE_FILLED, color, x1, y2, x2, y2);
}
}
More information about the vlc-commits
mailing list