aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast/s_blit.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-01-24 08:36:10 +0100
committermarha <marha@users.sourceforge.net>2013-01-24 08:36:10 +0100
commit06872e284da1c00ce03b234ca24aefeac64990d2 (patch)
treee1e8bee8a20f7b759b50edfc21d2313489280d10 /mesalib/src/mesa/swrast/s_blit.c
parent470f7ca9f0be348faf2f03fc16811844c5eeffce (diff)
downloadvcxsrv-06872e284da1c00ce03b234ca24aefeac64990d2.tar.gz
vcxsrv-06872e284da1c00ce03b234ca24aefeac64990d2.tar.bz2
vcxsrv-06872e284da1c00ce03b234ca24aefeac64990d2.zip
fontconfig mesa pixman xkbcomp xserver git update 24 jan 2013
fontconfig: fb3b410998aba8835999e2ca7003a180431cfaf4 mesa: 5bd86b26df30d32412ca1b7ac02892ab5e10c6ef pixman: b527a0e615a726aa6a7d18f0ea0b38564b153afa xkbcomp: 705b9bbb426410f9510601c7010da51184919b36 xserver: 7fe5e6dfa5c1e71d8b7540b28c1d508687a2fbee
Diffstat (limited to 'mesalib/src/mesa/swrast/s_blit.c')
-rw-r--r--mesalib/src/mesa/swrast/s_blit.c71
1 files changed, 32 insertions, 39 deletions
diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c
index 3a4e7eec0..82fa43f1c 100644
--- a/mesalib/src/mesa/swrast/s_blit.c
+++ b/mesalib/src/mesa/swrast/s_blit.c
@@ -188,29 +188,6 @@ blit_nearest(struct gl_context *ctx,
return;
}
- /* choose row resampler */
- switch (pixelSize) {
- case 1:
- resampleRow = resample_row_1;
- break;
- case 2:
- resampleRow = resample_row_2;
- break;
- case 4:
- resampleRow = resample_row_4;
- break;
- case 8:
- resampleRow = resample_row_8;
- break;
- case 16:
- resampleRow = resample_row_16;
- break;
- default:
- _mesa_problem(ctx, "unexpected pixel size (%d) in blit_nearest",
- pixelSize);
- return;
- }
-
/* Blit to all the draw buffers */
for (i = 0; i < numDrawBuffers; i++) {
if (buffer == GL_COLOR_BUFFER_BIT) {
@@ -232,6 +209,29 @@ blit_nearest(struct gl_context *ctx,
}
}
+ /* choose row resampler */
+ switch (pixelSize) {
+ case 1:
+ resampleRow = resample_row_1;
+ break;
+ case 2:
+ resampleRow = resample_row_2;
+ break;
+ case 4:
+ resampleRow = resample_row_4;
+ break;
+ case 8:
+ resampleRow = resample_row_8;
+ break;
+ case 16:
+ resampleRow = resample_row_16;
+ break;
+ default:
+ _mesa_problem(ctx, "unexpected pixel size (%d) in blit_nearest",
+ pixelSize);
+ return;
+ }
+
if ((readRb == drawRb) ||
(readAtt->Texture && drawAtt->Texture &&
(readAtt->Texture == drawAtt->Texture))) {
@@ -304,7 +304,8 @@ blit_nearest(struct gl_context *ctx,
}
for (dstRow = 0; dstRow < dstHeight; dstRow++) {
- GLint srcRow = (dstRow * srcHeight) / dstHeight;
+ GLfloat srcRowF = (dstRow + 0.5F) / dstHeight * srcHeight - 0.5F;
+ GLint srcRow = IROUND(srcRowF);
GLubyte *dstRowStart = dstMap + dstRowStride * dstRow;
ASSERT(srcRow >= 0);
@@ -347,7 +348,7 @@ blit_nearest(struct gl_context *ctx,
/* store pixel row in destination */
switch (mode) {
case DIRECT:
- memcpy(dstRowStart, dstBuffer, pixelSize * srcWidth);
+ memcpy(dstRowStart, dstBuffer, pixelSize * dstWidth);
break;
case UNPACK_RGBA_FLOAT:
_mesa_pack_float_rgba_row(drawRb->Format, dstWidth, dstBuffer,
@@ -404,17 +405,15 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth,
const GLubyte (*srcColor0)[4] = (const GLubyte (*)[4]) srcBuffer0;
const GLubyte (*srcColor1)[4] = (const GLubyte (*)[4]) srcBuffer1;
GLubyte (*dstColor)[4] = (GLubyte (*)[4]) dstBuffer;
- const GLfloat dstWidthF = (GLfloat) dstWidth;
GLint dstCol;
for (dstCol = 0; dstCol < dstWidth; dstCol++) {
- const GLfloat srcCol = (dstCol * srcWidth) / dstWidthF;
- GLint srcCol0 = IFLOOR(srcCol);
+ const GLfloat srcCol = (dstCol + 0.5F) / dstWidth * srcWidth - 0.5F;
+ GLint srcCol0 = MAX2(0, IFLOOR(srcCol));
GLint srcCol1 = srcCol0 + 1;
GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */
GLfloat red, green, blue, alpha;
- ASSERT(srcCol0 >= 0);
ASSERT(srcCol0 < srcWidth);
ASSERT(srcCol1 <= srcWidth);
@@ -461,17 +460,15 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth,
const GLfloat (*srcColor0)[4] = (const GLfloat (*)[4]) srcBuffer0;
const GLfloat (*srcColor1)[4] = (const GLfloat (*)[4]) srcBuffer1;
GLfloat (*dstColor)[4] = (GLfloat (*)[4]) dstBuffer;
- const GLfloat dstWidthF = (GLfloat) dstWidth;
GLint dstCol;
for (dstCol = 0; dstCol < dstWidth; dstCol++) {
- const GLfloat srcCol = (dstCol * srcWidth) / dstWidthF;
- GLint srcCol0 = IFLOOR(srcCol);
+ const GLfloat srcCol = (dstCol + 0.5F) / dstWidth * srcWidth - 0.5F;
+ GLint srcCol0 = MAX2(0, IFLOOR(srcCol));
GLint srcCol1 = srcCol0 + 1;
GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */
GLfloat red, green, blue, alpha;
- ASSERT(srcCol0 >= 0);
ASSERT(srcCol0 < srcWidth);
ASSERT(srcCol1 <= srcWidth);
@@ -526,7 +523,6 @@ blit_linear(struct gl_context *ctx,
const GLint dstWidth = ABS(dstX1 - dstX0);
const GLint srcHeight = ABS(srcY1 - srcY0);
const GLint dstHeight = ABS(dstY1 - dstY0);
- const GLfloat dstHeightF = (GLfloat) dstHeight;
const GLint srcXpos = MIN2(srcX0, srcX1);
const GLint srcYpos = MIN2(srcY0, srcY1);
@@ -654,14 +650,11 @@ blit_linear(struct gl_context *ctx,
for (dstRow = 0; dstRow < dstHeight; dstRow++) {
const GLint dstY = dstYpos + dstRow;
- const GLfloat srcRow = (dstRow * srcHeight) / dstHeightF;
- GLint srcRow0 = IFLOOR(srcRow);
+ GLfloat srcRow = (dstRow + 0.5F) / dstHeight * srcHeight - 0.5F;
+ GLint srcRow0 = MAX2(0, IFLOOR(srcRow));
GLint srcRow1 = srcRow0 + 1;
GLfloat rowWeight = srcRow - srcRow0; /* fractional part of srcRow */
- ASSERT(srcRow >= 0);
- ASSERT(srcRow < srcHeight);
-
if (srcRow1 == srcHeight) {
/* last row fudge */
srcRow1 = srcRow0;