From 877e9c57c788cb3d4db1e96e519b26ca5d542465 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 12 Oct 2012 17:57:28 +0100 Subject: sna/overlay: Trim suggested BestSize to fit within the overlay constraints As the maximum reported image sizes are for the source image, we should be careful not to recommend the application use an output Window larger than can be handled by the overlay hardware. So shrink it to fit, whilst preserving the aspect ratio. Signed-off-by: Chris Wilson --- src/sna/sna_video_overlay.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index babdfc61..b73e9ddf 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -285,12 +285,29 @@ sna_video_overlay_query_best_size(ScrnInfoPtr scrn, Bool motion, short vid_w, short vid_h, short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data) + unsigned int *p_w, unsigned int *p_h, + pointer data) { - if (vid_w > (drw_w << 1)) + struct sna *sna = to_sna(scrn); + short max_w, max_h; + + if (vid_w > (drw_w << 1) || vid_h > (drw_h << 1)){ drw_w = vid_w >> 1; - if (vid_h > (drw_h << 1)) drw_h = vid_h >> 1; + } + + if (sna->kgem.gen < 21) { + max_w = IMAGE_MAX_WIDTH_LEGACY; + max_h = IMAGE_MAX_HEIGHT_LEGACY; + } else { + max_w = IMAGE_MAX_WIDTH; + max_h = IMAGE_MAX_HEIGHT; + } + + while (drw_w > max_w || drw_h > max_h) { + drw_w >>= 1; + drw_h >>= 1; + } *p_w = drw_w; *p_h = drw_h; -- cgit v1.2.3