diff options
Diffstat (limited to 'src/sna/sna_blt.c')
-rw-r--r-- | src/sna/sna_blt.c | 154 |
1 files changed, 34 insertions, 120 deletions
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index 80fad6d2..ff8e3eb1 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -1138,20 +1138,20 @@ blt_composite_copy_boxes_with_alpha(struct sna *sna, static bool prepare_blt_copy(struct sna *sna, struct sna_composite_op *op, + struct kgem_bo *bo, uint32_t alpha_fixup) { PixmapPtr src = op->u.blt.src_pixmap; - struct sna_pixmap *priv = sna_pixmap(src); - if (!kgem_bo_can_blt(&sna->kgem, priv->gpu_bo)) { + if (!kgem_bo_can_blt(&sna->kgem, bo)) { DBG(("%s: fallback -- can't blt from source\n", __FUNCTION__)); return false; } - if (!kgem_check_many_bo_fenced(&sna->kgem, op->dst.bo, priv->gpu_bo, NULL)) { + if (!kgem_check_many_bo_fenced(&sna->kgem, op->dst.bo, bo, NULL)) { _kgem_submit(&sna->kgem); if (!kgem_check_many_bo_fenced(&sna->kgem, - op->dst.bo, priv->gpu_bo, NULL)) { + op->dst.bo, bo, NULL)) { DBG(("%s: fallback -- no room in aperture\n", __FUNCTION__)); return false; } @@ -1170,9 +1170,7 @@ prepare_blt_copy(struct sna *sna, op->box = blt_composite_copy_box_with_alpha; op->boxes = blt_composite_copy_boxes_with_alpha; - if (!sna_blt_alpha_fixup_init(sna, &op->u.blt, - priv->gpu_bo, - op->dst.bo, + if (!sna_blt_alpha_fixup_init(sna, &op->u.blt, bo, op->dst.bo, src->drawable.bitsPerPixel, alpha_fixup)) return false; @@ -1181,15 +1179,13 @@ prepare_blt_copy(struct sna *sna, op->box = blt_composite_copy_box; op->boxes = blt_composite_copy_boxes; - if (!sna_blt_copy_init(sna, &op->u.blt, - priv->gpu_bo, - op->dst.bo, + if (!sna_blt_copy_init(sna, &op->u.blt, bo, op->dst.bo, src->drawable.bitsPerPixel, GXcopy)) return false; } - return begin_blt(sna, op); + return true; } fastcall static void @@ -1434,119 +1430,33 @@ prepare_blt_put(struct sna *sna, uint32_t alpha_fixup) { PixmapPtr src = op->u.blt.src_pixmap; - struct sna_pixmap *priv; - struct kgem_bo *src_bo; DBG(("%s\n", __FUNCTION__)); - op->done = nop_done; + if (!sna_pixmap_move_to_cpu(src, MOVE_READ)) + return false; - src_bo = NULL; - priv = sna_pixmap(src); - if (priv) - src_bo = priv->cpu_bo; - if (src_bo) { - if (alpha_fixup) { - op->blt = blt_composite_copy_with_alpha; - op->box = blt_composite_copy_box_with_alpha; - op->boxes = blt_composite_copy_boxes_with_alpha; - - if (!sna_blt_alpha_fixup_init(sna, &op->u.blt, - src_bo, op->dst.bo, - op->dst.pixmap->drawable.bitsPerPixel, - alpha_fixup)) - return false; - } else { - op->blt = blt_composite_copy; - op->box = blt_composite_copy_box; - op->boxes = blt_composite_copy_boxes; - - if (!sna_blt_copy_init(sna, &op->u.blt, - src_bo, op->dst.bo, - op->dst.pixmap->drawable.bitsPerPixel, - GXcopy)) - return false; - } + assert(src->devKind); + assert(src->devPrivate.ptr); - return begin_blt(sna, op); - } else { - if (!sna_pixmap_move_to_cpu(src, MOVE_READ)) - return false; + if (alpha_fixup) + return false; /* XXX */ - assert(src->devKind); - assert(src->devPrivate.ptr); - - if (alpha_fixup) - return false; /* XXX */ - - if (alpha_fixup) { - op->u.blt.pixel = alpha_fixup; - op->blt = blt_put_composite_with_alpha; - op->box = blt_put_composite_box_with_alpha; - op->boxes = blt_put_composite_boxes_with_alpha; - } else { - op->blt = blt_put_composite; - op->box = blt_put_composite_box; - op->boxes = blt_put_composite_boxes; - } + if (alpha_fixup) { + op->u.blt.pixel = alpha_fixup; + op->blt = blt_put_composite_with_alpha; + op->box = blt_put_composite_box_with_alpha; + op->boxes = blt_put_composite_boxes_with_alpha; + } else { + op->blt = blt_put_composite; + op->box = blt_put_composite_box; + op->boxes = blt_put_composite_boxes; } + op->done = nop_done; return true; } -static bool -has_gpu_area(PixmapPtr pixmap, int x, int y, int w, int h) -{ - struct sna_pixmap *priv = sna_pixmap(pixmap); - BoxRec area; - - if (!priv) - return false; - if (!priv->gpu_bo) - return false; - - if (priv->cpu_damage == NULL) - return true; - if (priv->cpu_damage->mode == DAMAGE_ALL) - return false; - - area.x1 = x; - area.y1 = y; - area.x2 = x + w; - area.y2 = y + h; - if (priv->gpu_damage && - sna_damage_contains_box__no_reduce(priv->gpu_damage, &area)) - return true; - - return sna_damage_contains_box(priv->cpu_damage, - &area) == PIXMAN_REGION_OUT; -} - -static bool -has_cpu_area(PixmapPtr pixmap, int x, int y, int w, int h) -{ - struct sna_pixmap *priv = sna_pixmap(pixmap); - BoxRec area; - - if (!priv) - return true; - if (priv->gpu_damage == NULL) - return true; - if (priv->gpu_damage->mode == DAMAGE_ALL) - return false; - - area.x1 = x; - area.y1 = y; - area.x2 = x + w; - area.y2 = y + h; - if (priv->cpu_damage && - sna_damage_contains_box__no_reduce(priv->cpu_damage, &area)) - return true; - - return sna_damage_contains_box(priv->gpu_damage, - &area) == PIXMAN_REGION_OUT; -} - static void reduce_damage(struct sna_composite_op *op, int dst_x, int dst_y, @@ -1592,7 +1502,9 @@ sna_blt_composite(struct sna *sna, PictFormat src_format = src->format; PixmapPtr src_pixmap; struct sna_pixmap *priv; + struct kgem_bo *bo; int16_t tx, ty; + BoxRec box; uint32_t alpha_fixup; bool was_clear; bool ret; @@ -1748,13 +1660,15 @@ clear: __FUNCTION__, tmp->dst.x, tmp->dst.y, tmp->u.blt.sx, tmp->u.blt.sy, alpha_fixup)); - if (has_gpu_area(src_pixmap, x, y, width, height)) - ret = prepare_blt_copy(sna, tmp, alpha_fixup); - else if (has_cpu_area(src_pixmap, x, y, width, height)) - ret = prepare_blt_put(sna, tmp, alpha_fixup); - else if (sna_pixmap_move_to_gpu(src_pixmap, MOVE_READ)) - ret = prepare_blt_copy(sna, tmp, alpha_fixup); - else + ret = false; + box.x1 = x; + box.y1 = y; + box.x2 = x + width; + box.y2 = y + height; + bo = __sna_render_pixmap_bo(sna, src_pixmap, &box, true); + if (bo) + ret = prepare_blt_copy(sna, tmp, bo, alpha_fixup); + if (!ret) ret = prepare_blt_put(sna, tmp, alpha_fixup); return ret; |