diff options
author | Keith Packard <keithp@keithp.com> | 2008-03-21 03:08:24 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-03-21 03:12:36 -0700 |
commit | 645980596450ed21c3b8927410a6bfe38a0c55d1 (patch) | |
tree | dd5ab9dbbc1786fd5c631d2a181aaaa9b3f1c39a /src/i830_render.c | |
parent | bf725b92cf93d74a6f414f81f319dddbc2c78525 (diff) |
Transformed coord computed using floats. Don't move bilinear composite dst.
The homogeneous coordinate computation in the core server cannot be used for
many legal matrices as it overflows. Just use floats in the driver; faster
and avoids troubles.
When compositing with bilinear filter, don't push the dst coordinates around
as that makes the output blurry when pixels are aligned.
Diffstat (limited to 'src/i830_render.c')
-rw-r--r-- | src/i830_render.c | 118 |
1 files changed, 70 insertions, 48 deletions
diff --git a/src/i830_render.c b/src/i830_render.c index 87543ef6..195e9a8c 100644 --- a/src/i830_render.c +++ b/src/i830_render.c @@ -396,6 +396,7 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture, I830Ptr pI830 = I830PTR(pScrn); uint32_t dst_format, dst_offset, dst_pitch; Bool is_affine_src, is_affine_mask; + Bool is_nearest = FALSE; IntelEmitInvarientState(pScrn); *pI830->last_3d = LAST_3D_RENDER; @@ -407,9 +408,13 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture, if (!i830_texture_setup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); + if (pSrcPicture->filter == PictFilterNearest) + is_nearest = TRUE; if (pMask != NULL) { if (!i830_texture_setup(pMaskPicture, pMask, 1)) I830FALLBACK("fail to setup mask texture\n"); + if (pMaskPicture->filter == PictFilterNearest) + is_nearest = TRUE; } else { pI830->transform[1] = NULL; pI830->scale_units[1][0] = -1; @@ -419,6 +424,11 @@ i830_prepare_composite(int op, PicturePtr pSrcPicture, is_affine_src = i830_transform_is_affine (pI830->transform[0]); is_affine_mask = i830_transform_is_affine (pI830->transform[1]); + if (is_nearest) + pI830->coord_adjust = -0.125; + else + pI830->coord_adjust = 0; + if (!is_affine_src || !is_affine_mask) I830FALLBACK("non-affine transform unsupported on 8xx hardware\n"); @@ -591,56 +601,68 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, per_vertex = 2; /* dest x/y */ if (is_affine_src) { - i830_get_transformed_coordinates(srcX, srcY, - pI830->transform[0], - &src_x[0], &src_y[0]); - i830_get_transformed_coordinates(srcX, srcY + h, - pI830->transform[0], - &src_x[1], &src_y[1]); - i830_get_transformed_coordinates(srcX + w, srcY + h, - pI830->transform[0], - &src_x[2], &src_y[2]); + if (!i830_get_transformed_coordinates(srcX, srcY, + pI830->transform[0], + &src_x[0], &src_y[0])) + return; + if (!i830_get_transformed_coordinates(srcX, srcY + h, + pI830->transform[0], + &src_x[1], &src_y[1])) + return; + if (!i830_get_transformed_coordinates(srcX + w, srcY + h, + pI830->transform[0], + &src_x[2], &src_y[2])) + return; per_vertex += 2; /* src x/y */ } else { - i830_get_transformed_coordinates_3d(srcX, srcY, - pI830->transform[0], - &src_x[0], &src_y[0], - &src_w[0]); - i830_get_transformed_coordinates_3d(srcX, srcY + h, - pI830->transform[0], - &src_x[1], &src_y[1], - &src_w[1]); - i830_get_transformed_coordinates_3d(srcX + w, srcY + h, - pI830->transform[0], - &src_x[2], &src_y[2], - &src_w[2]); + if (!i830_get_transformed_coordinates_3d(srcX, srcY, + pI830->transform[0], + &src_x[0], &src_y[0], + &src_w[0])) + return; + if (!i830_get_transformed_coordinates_3d(srcX, srcY + h, + pI830->transform[0], + &src_x[1], &src_y[1], + &src_w[1])) + return; + if (!i830_get_transformed_coordinates_3d(srcX + w, srcY + h, + pI830->transform[0], + &src_x[2], &src_y[2], + &src_w[2])) + return; per_vertex += 4; /* src x/y/z/w */ } if (has_mask) { if (is_affine_mask) { - i830_get_transformed_coordinates(maskX, maskY, - pI830->transform[1], - &mask_x[0], &mask_y[0]); - i830_get_transformed_coordinates(maskX, maskY + h, - pI830->transform[1], - &mask_x[1], &mask_y[1]); - i830_get_transformed_coordinates(maskX + w, maskY + h, - pI830->transform[1], - &mask_x[2], &mask_y[2]); + if (!i830_get_transformed_coordinates(maskX, maskY, + pI830->transform[1], + &mask_x[0], &mask_y[0])) + return; + if (!i830_get_transformed_coordinates(maskX, maskY + h, + pI830->transform[1], + &mask_x[1], &mask_y[1])) + return; + if (!i830_get_transformed_coordinates(maskX + w, maskY + h, + pI830->transform[1], + &mask_x[2], &mask_y[2])) + return; per_vertex += 2; /* mask x/y */ } else { - i830_get_transformed_coordinates_3d(maskX, maskY, - pI830->transform[1], - &mask_x[0], &mask_y[0], - &mask_w[0]); - i830_get_transformed_coordinates_3d(maskX, maskY + h, - pI830->transform[1], - &mask_x[1], &mask_y[1], - &mask_w[1]); - i830_get_transformed_coordinates_3d(maskX + w, maskY + h, - pI830->transform[1], - &mask_x[2], &mask_y[2], - &mask_w[2]); + if (!i830_get_transformed_coordinates_3d(maskX, maskY, + pI830->transform[1], + &mask_x[0], &mask_y[0], + &mask_w[0])) + return; + if (!i830_get_transformed_coordinates_3d(maskX, maskY + h, + pI830->transform[1], + &mask_x[1], &mask_y[1], + &mask_w[1])) + return; + if (!i830_get_transformed_coordinates_3d(maskX + w, maskY + h, + pI830->transform[1], + &mask_x[2], &mask_y[2], + &mask_w[2])) + return; per_vertex += 4; /* mask x/y/z/w */ } } @@ -655,8 +677,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, OUT_BATCH(MI_NOOP); OUT_BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST | (num_floats-1)); - OUT_BATCH_F(-0.125 + dstX + w); - OUT_BATCH_F(-0.125 + dstY + h); + OUT_BATCH_F(pI830->coord_adjust + dstX + w); + OUT_BATCH_F(pI830->coord_adjust + dstY + h); OUT_BATCH_F(src_x[2] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[2] / pI830->scale_units[0][1]); if (!is_affine_src) { @@ -672,8 +694,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, } } - OUT_BATCH_F(-0.125 + dstX); - OUT_BATCH_F(-0.125 + dstY + h); + OUT_BATCH_F(pI830->coord_adjust + dstX); + OUT_BATCH_F(pI830->coord_adjust + dstY + h); OUT_BATCH_F(src_x[1] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[1] / pI830->scale_units[0][1]); if (!is_affine_src) { @@ -689,8 +711,8 @@ i830_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, } } - OUT_BATCH_F(-0.125 + dstX); - OUT_BATCH_F(-0.125 + dstY); + OUT_BATCH_F(pI830->coord_adjust + dstX); + OUT_BATCH_F(pI830->coord_adjust + dstY); OUT_BATCH_F(src_x[0] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[0] / pI830->scale_units[0][1]); if (!is_affine_src) { |