summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-10-12 17:57:28 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-10-12 17:57:28 +0100
commit877e9c57c788cb3d4db1e96e519b26ca5d542465 (patch)
treeec0c55c0b825d4ab56966ab44f2082bb154fba5d
parent1ec41590c9d142a77a2fdcfcd9a762aca99d9d86 (diff)
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 <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_video_overlay.c23
1 files 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;