summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-06-24 00:34:11 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-06-24 00:34:11 +0100
commit3c1d5bc35e02dfd8234c029dcab5661e1656ca8e (patch)
tree83cafb25a39c58300323252ee0bf5e1a2edc8c8b
parente3b4c10f239f69e5282bde1d3b0c3685b24cf0aa (diff)
sna: Clip the fbcon to the frontbuffer
...both to correct the placement of the fbcon into the smaller scanout and to ensure that we correctly clip the boxes to be copied. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_display.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index cb1beba7..f92a1dbf 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -502,6 +502,8 @@ void sna_copy_fbcon(struct sna *sna)
struct kgem_bo *bo;
BoxRec box;
bool ok;
+ int sx, sy;
+ int dx, dy;
int i;
if (sna->kgem.wedged)
@@ -527,8 +529,8 @@ void sna_copy_fbcon(struct sna *sna)
goto cleanup_fbcon;
box.x1 = box.y1 = 0;
- box.x2 = fbcon->width;
- box.y2 = fbcon->height;
+ box.x2 = min(fbcon->width, sna->front->drawable.width);
+ box.y2 = min(fbcon->height, sna->front->drawable.height);
bo = sna_create_bo_for_fbcon(sna, fbcon);
if (bo == NULL)
@@ -537,11 +539,21 @@ void sna_copy_fbcon(struct sna *sna)
priv = sna_pixmap(sna->front);
assert(priv && priv->gpu_bo);
+ sx = dx = 0;
+ if (box.x2 < fbcon->width)
+ sx = (fbcon->width - box.x2) / 2.;
+ if (box.x2 < sna->front->drawable.width)
+ dx = (sna->front->drawable.width - box.x2) / 2.;
+
+ sy = dy = 0;
+ if (box.y2 < fbcon->height)
+ sy = (fbcon->height - box.y2) / 2.;
+ if (box.y2 < sna->front->drawable.height)
+ dy = (sna->front->drawable.height - box.y2) / 2.;
+
ok = sna->render.copy_boxes(sna, GXcopy,
- sna->front, bo, 0, 0,
- sna->front, priv->gpu_bo,
- (sna->front->drawable.width - fbcon->width)/2,
- (sna->front->drawable.height - fbcon->height)/2,
+ sna->front, bo, sx, sy,
+ sna->front, priv->gpu_bo, dx, dy,
&box, 1);
sna_damage_add_box(&priv->gpu_damage, &box);