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>
This commit is contained in:
Chris Wilson 2011-06-24 00:34:11 +01:00
parent e3b4c10f23
commit 3c1d5bc35e
1 changed files with 18 additions and 6 deletions

View File

@ -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);