summaryrefslogtreecommitdiff
path: root/src/sna
diff options
context:
space:
mode:
Diffstat (limited to 'src/sna')
-rw-r--r--src/sna/sna.h4
-rw-r--r--src/sna/sna_accel.c12
-rw-r--r--src/sna/sna_blt.c10
-rw-r--r--src/sna/sna_io.c35
4 files changed, 29 insertions, 32 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h
index a1737c11..f16324e0 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -681,9 +681,9 @@ void sna_read_boxes(struct sna *sna,
struct kgem_bo *src_bo, int16_t src_dx, int16_t src_dy,
PixmapPtr dst, int16_t dst_dx, int16_t dst_dy,
const BoxRec *box, int n);
-void sna_write_boxes(struct sna *sna,
+void sna_write_boxes(struct sna *sna, PixmapPtr dst,
struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
- const void *src, int stride, int bpp, int16_t src_dx, int16_t src_dy,
+ const void *src, int stride, int16_t src_dx, int16_t src_dy,
const BoxRec *box, int n);
struct kgem_bo *sna_replace(struct sna *sna,
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index afae205f..06826d2a 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1214,11 +1214,10 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
pixmap->devPrivate.ptr,
pixmap->devKind);
} else {
- sna_write_boxes(sna,
+ sna_write_boxes(sna, pixmap,
priv->gpu_bo, 0, 0,
pixmap->devPrivate.ptr,
pixmap->devKind,
- pixmap->drawable.bitsPerPixel,
0, 0,
box, n);
}
@@ -1581,11 +1580,10 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
pixmap->devPrivate.ptr,
pixmap->devKind);
} else {
- sna_write_boxes(sna,
+ sna_write_boxes(sna, pixmap,
priv->gpu_bo, 0, 0,
pixmap->devPrivate.ptr,
pixmap->devKind,
- pixmap->drawable.bitsPerPixel,
0, 0,
box, n);
}
@@ -1847,11 +1845,10 @@ sna_put_image_upload_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
}
if (!ok && gc->alu == GXcopy) {
- sna_write_boxes(sna,
+ sna_write_boxes(sna, pixmap,
priv->gpu_bo, 0, 0,
bits,
stride,
- pixmap->drawable.bitsPerPixel,
-x, -y,
box, nbox);
ok = TRUE;
@@ -2774,11 +2771,10 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
} else {
DBG(("%s: dst is on the GPU, src is on the CPU, uploading\n",
__FUNCTION__));
- sna_write_boxes(sna,
+ sna_write_boxes(sna, dst_pixmap,
dst_priv->gpu_bo, dst_dx, dst_dy,
src_pixmap->devPrivate.ptr,
src_pixmap->devKind,
- src_pixmap->drawable.bitsPerPixel,
src_dx, src_dy,
box, n);
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 4c253768..5879e973 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -1006,9 +1006,9 @@ blt_put_composite(struct sna *sna,
box.x2 = dst_x + r->width;
box.y2 = dst_y + r->height;
- sna_write_boxes(sna,
+ sna_write_boxes(sna, dst,
dst_priv->gpu_bo, 0, 0,
- data, pitch, bpp, src_x, src_y,
+ data, pitch, src_x, src_y,
&box, 1);
}
}
@@ -1038,11 +1038,10 @@ fastcall static void blt_put_composite_box(struct sna *sna,
sna_replace(sna, op->dst.pixmap, op->dst.bo,
data, pitch);
} else {
- sna_write_boxes(sna,
+ sna_write_boxes(sna, op->dst.pixmap,
op->dst.bo, op->dst.x, op->dst.y,
src->devPrivate.ptr,
src->devKind,
- src->drawable.bitsPerPixel,
op->u.blt.sx, op->u.blt.sy,
box, 1);
}
@@ -1074,11 +1073,10 @@ static void blt_put_composite_boxes(struct sna *sna,
sna_replace(sna, op->dst.pixmap, op->dst.bo,
data, pitch);
} else {
- sna_write_boxes(sna,
+ sna_write_boxes(sna, op->dst.pixmap,
op->dst.bo, op->dst.x, op->dst.y,
src->devPrivate.ptr,
src->devKind,
- src->drawable.bitsPerPixel,
op->u.blt.sx, op->u.blt.sy,
box, n);
}
diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c
index 1c25b9de..c5e66f14 100644
--- a/src/sna/sna_io.c
+++ b/src/sna/sna_io.c
@@ -305,9 +305,9 @@ static void write_boxes_inplace(struct kgem *kgem,
} while (--n);
}
-void sna_write_boxes(struct sna *sna,
+void sna_write_boxes(struct sna *sna, PixmapPtr dst,
struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
- const void *src, int stride, int bpp, int16_t src_dx, int16_t src_dy,
+ const void *src, int stride, int16_t src_dx, int16_t src_dy,
const BoxRec *box, int nbox)
{
struct kgem *kgem = &sna->kgem;
@@ -322,7 +322,7 @@ void sna_write_boxes(struct sna *sna,
!kgem_bo_map_will_stall(kgem, dst_bo)) {
fallback:
write_boxes_inplace(kgem,
- src, stride, bpp, src_dx, src_dy,
+ src, stride, dst->drawable.bitsPerPixel, src_dx, src_dy,
dst_bo, dst_dx, dst_dy,
box, nbox);
return;
@@ -348,11 +348,14 @@ fallback:
tmp.drawable.width = extents.x2 - extents.x1;
tmp.drawable.height = extents.y2 - extents.y1;
- tmp.drawable.depth = bpp;
- tmp.drawable.bitsPerPixel = bpp;
+ tmp.drawable.depth = dst->drawable.depth;
+ tmp.drawable.bitsPerPixel = dst->drawable.bitsPerPixel;
tmp.devPrivate.ptr = NULL;
- tmp.devKind = tmp.drawable.width * bpp / 8;
+ assert(tmp.drawable.width);
+ assert(tmp.drawable.height);
+
+ tmp.devKind = tmp.drawable.width * tmp.drawable.bitsPerPixel / 8;
tmp.devKind = ALIGN(tmp.devKind, 4);
src_bo = kgem_create_buffer(kgem,
@@ -365,7 +368,7 @@ fallback:
src_bo->pitch = tmp.devKind;
for (n = 0; n < nbox; n++) {
- memcpy_blt(src, ptr, bpp,
+ memcpy_blt(src, ptr, tmp.drawable.bitsPerPixel,
stride, tmp.devKind,
box[n].x1 + src_dx,
box[n].y1 + src_dy,
@@ -377,7 +380,7 @@ fallback:
n = sna->render.copy_boxes(sna, GXcopy,
&tmp, src_bo, -extents.x1, -extents.y1,
- &tmp, dst_bo, dst_dx, dst_dy,
+ dst, dst_bo, dst_dx, dst_dy,
box, nbox);
kgem_bo_destroy(&sna->kgem, src_bo);
@@ -389,17 +392,16 @@ fallback:
}
cmd = XY_SRC_COPY_BLT_CMD;
- if (bpp == 32)
- cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
br13 = dst_bo->pitch;
if (kgem->gen >= 40 && dst_bo->tiling) {
cmd |= BLT_DST_TILED;
br13 >>= 2;
}
br13 |= 0xcc << 16;
- switch (bpp) {
+ switch (dst->drawable.bitsPerPixel) {
default:
- case 32: br13 |= 1 << 25; /* RGB8888 */
+ case 32: cmd |= BLT_WRITE_ALPHA | BLT_WRITE_RGB;
+ br13 |= 1 << 25; /* RGB8888 */
case 16: br13 |= 1 << 24; /* RGB565 */
case 8: break;
}
@@ -431,7 +433,7 @@ fallback:
for (n = 0; n < nbox_this_time; n++) {
int height = box[n].y2 - box[n].y1;
int width = box[n].x2 - box[n].x1;
- offset += PITCH(width, bpp >> 3) * height;
+ offset += PITCH(width, dst->drawable.bitsPerPixel >> 3) * height;
}
src_bo = kgem_create_buffer(kgem, offset,
@@ -444,7 +446,7 @@ fallback:
do {
int height = box->y2 - box->y1;
int width = box->x2 - box->x1;
- int pitch = PITCH(width, bpp >> 3);
+ int pitch = PITCH(width, dst->drawable.bitsPerPixel >> 3);
uint32_t *b;
DBG((" %s: box src=(%d, %d), dst=(%d, %d) size=(%d, %d), dst offset=%d, dst pitch=%d\n",
@@ -455,13 +457,14 @@ fallback:
offset, pitch));
assert(box->x1 + src_dx >= 0);
- assert((box->x2 + src_dx)*bpp <= 8*stride);
+ assert((box->x2 + src_dx)*dst->drawable.bitsPerPixel <= 8*stride);
assert(box->y1 + src_dy >= 0);
assert(box->x1 + dst_dx >= 0);
assert(box->y1 + dst_dy >= 0);
- memcpy_blt(src, (char *)ptr + offset, bpp,
+ memcpy_blt(src, (char *)ptr + offset,
+ dst->drawable.bitsPerPixel,
stride, pitch,
box->x1 + src_dx, box->y1 + src_dy,
0, 0,