glamor_putimage: Optimize for direct uploading and fallback path.

This commit optimize two cases:
1. When the clip contains the whole area, we can directly upload
the texel data to the pixmap, and don't need to do one extra
clipped copy.

2. At fallback path, we don't read back the whole pixmap, just
need a sub region.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2012-04-25 11:59:47 +08:00 committed by Eric Anholt
parent ea70ebe0ac
commit 05da99106b

View File

@ -256,9 +256,12 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
int x_off, y_off; int x_off, y_off;
float vertices[8], texcoords[8]; float vertices[8], texcoords[8];
Bool ret = FALSE; Bool ret = FALSE;
PixmapPtr temp_pixmap; PixmapPtr temp_pixmap, sub_pixmap;
glamor_pixmap_private *temp_pixmap_priv; glamor_pixmap_private *temp_pixmap_priv;
BoxRec box;
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
clip = fbGetCompositeClip(gc);
if (image_format == XYBitmap) { if (image_format == XYBitmap) {
assert(depth == 1); assert(depth == 1);
goto fail; goto fail;
@ -279,9 +282,13 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
} }
/* create a temporary pixmap and upload the bits to that /* create a temporary pixmap and upload the bits to that
* pixmap, then apply clip copy it to the destination pixmap.*/ * pixmap, then apply clip copy it to the destination pixmap.*/
box.x1 = x + drawable->x;
box.y1 = y + drawable->y;
box.x2 = x + w + drawable->x;
box.y2 = y + h + drawable->y;
clip = fbGetCompositeClip(gc); if ((clip != NULL && !RegionContainsRect(clip, &box))
if (clip != NULL) { || gc->alu != GXcopy) {
temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0); temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
if (temp_pixmap == NULL) if (temp_pixmap == NULL)
goto fail; goto fail;
@ -298,12 +305,9 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y); glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
glamor_destroy_pixmap(temp_pixmap); glamor_destroy_pixmap(temp_pixmap);
} else { } else
ErrorF("put image directly. \n"); glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
glamor_upload_sub_pixmap_to_texture(pixmap, drawable->x + x_off, drawable->y + y_off,
w, h, pixmap->devKind, bits, 0); w, h, pixmap->devKind, bits, 0);
}
ret = TRUE; ret = TRUE;
goto done; goto done;
@ -316,11 +320,26 @@ fail:
glamor_fallback("to %p (%c)\n", glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable)); drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RW)) {
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, fbPutImage(drawable, gc, depth, x, y, w, h,
left_pad, image_format, bits); left_pad, image_format, bits);
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RW);
}
ret = TRUE; ret = TRUE;
done: done: