static Bool _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, int w, int h, int left_pad, int image_format, char *bits, Bool fallback) { PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); RegionPtr clip; int x_off, y_off; Bool ret = FALSE; PixmapPtr temp_pixmap, sub_pixmap; glamor_pixmap_private *temp_pixmap_priv; BoxRec box; int stride; glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off); clip = fbGetCompositeClip(gc); if (image_format == XYBitmap) { assert(depth == 1); goto fail; } if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) { glamor_fallback("has no fbo.\n"); goto fail; } if (image_format != ZPixmap) { glamor_fallback("non-ZPixmap\n"); goto fail; } if (!glamor_set_planemask(pixmap, gc->planemask)) { goto fail; } /* create a temporary pixmap and upload the bits to that * pixmap, then apply clip copy it to the destination pixmap.*/ stride = PixmapBytePad(w, depth); box.x1 = x + drawable->x; box.y1 = y + drawable->y; box.x2 = x + w + drawable->x; box.y2 = y + h + drawable->y; if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN) || gc->alu != GXcopy) { temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0); if (temp_pixmap == NULL) goto fail; temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap); if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) { temp_pixmap_priv->base.picture = pixmap_priv->base.picture; temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture; } glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h, stride, bits, 0); glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y); glamor_destroy_pixmap(temp_pixmap); } else { glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off, w, h, stride, bits, 0); } ret = TRUE; goto done; fail: glamor_set_planemask(pixmap, ~0); if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable)) goto done; glamor_fallback("to %p (%c)\n", drawable, glamor_get_drawable_location(drawable)); sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x, y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW); if (sub_pixmap) { if (clip != NULL) pixman_region_translate (clip, -x - drawable->x, -y - drawable->y); fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h, left_pad, image_format, bits); glamor_put_sub_pixmap(sub_pixmap, pixmap, x + x_off + drawable->x, y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW); if (clip != NULL) pixman_region_translate (clip, x + drawable->x, y + drawable->y); } else fbPutImage(drawable, gc, depth, x, y, w, h, left_pad, image_format, bits); ret = TRUE; done: return ret; }
/** @file glamor_fillspans.c * * GC fill implementation, based loosely on fb_fill.c */ Bool glamor_fill(DrawablePtr drawable, GCPtr gc, int x, int y, int width, int height, Bool fallback) { PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable); int off_x, off_y; PixmapPtr sub_pixmap = NULL; glamor_access_t sub_pixmap_access; DrawablePtr saved_drawable = NULL; int saved_x = x, saved_y = y; glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y); switch (gc->fillStyle) { case FillSolid: if (!glamor_solid(dst_pixmap, x + off_x, y + off_y, width, height, gc->alu, gc->planemask, gc->fgPixel)) goto fail; break; case FillStippled: case FillOpaqueStippled: if (!glamor_stipple(dst_pixmap, gc->stipple, x + off_x, y + off_y, width, height, gc->alu, gc->planemask, gc->fgPixel, gc->bgPixel, gc->patOrg.x, gc->patOrg.y)) goto fail; break; case FillTiled: if (!glamor_tile(dst_pixmap, gc->tile.pixmap, x + off_x, y + off_y, width, height, gc->alu, gc->planemask, x - drawable->x - gc->patOrg.x, y - drawable->y - gc->patOrg.y)) goto fail; break; } return TRUE; fail: if (!fallback) { if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable) && glamor_ddx_fallback_check_gc(gc)) return FALSE; } /* Is it possible to set the access as WO? */ sub_pixmap_access = GLAMOR_ACCESS_RW; sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x, y + off_y, width, height, sub_pixmap_access); if (sub_pixmap != NULL) { if (gc->fillStyle != FillSolid) { gc->patOrg.x += (drawable->x - x); gc->patOrg.y += (drawable->y - y); } saved_drawable = drawable; drawable = &sub_pixmap->drawable; saved_x = x; saved_y = y; x = 0; y = 0; } if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) { if (glamor_prepare_access_gc(gc)) { fbFill(drawable, gc, x, y, width, height); glamor_finish_access_gc(gc); } glamor_finish_access(drawable, GLAMOR_ACCESS_RW); } if (sub_pixmap != NULL) { if (gc->fillStyle != FillSolid) { gc->patOrg.x -= (saved_drawable->x - saved_x); gc->patOrg.y -= (saved_drawable->y - saved_y); } x = saved_x; y = saved_y; glamor_put_sub_pixmap(sub_pixmap, dst_pixmap, x + off_x, y + off_y, width, height, sub_pixmap_access); } return TRUE; }