[PATCH 2/3] glamor: Don't use PACK/UNPACK_SKIP_ROWS/PIXELS.
Eric Anholt
eric at anholt.net
Tue Dec 30 14:54:28 PST 2014
It's not available in GLES2 (though it's in GLES3). It's trivial to
do the math, and avoids going through more switch statements in the GL
on desktop.
Signed-off-by: Eric Anholt <eric at anholt.net>
---
glamor/glamor_transfer.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index 8914155..7a60c91 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -97,20 +97,16 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
if (x2 <= x1 || y2 <= y1)
continue;
- glPixelStorei(GL_UNPACK_SKIP_ROWS, y1 - dy_dst + dy_src);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, x1 - dx_dst + dx_src);
-
glTexSubImage2D(GL_TEXTURE_2D, 0,
x1 - box->x1, y1 - box->y1,
x2 - x1, y2 - y1,
format, type,
- bits);
+ bits + ((y1 - dy_dst + dy_src) * byte_stride +
+ (x1 - dx_dst + dx_src) * bytes_per_pixel));
}
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
}
/*
@@ -189,14 +185,13 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
if (x2 <= x1 || y2 <= y1)
continue;
- glPixelStorei(GL_PACK_SKIP_PIXELS, x1 - dx_src + dx_dst);
- glPixelStorei(GL_PACK_SKIP_ROWS, y1 - dy_src + dy_dst);
- glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1, format, type, bits);
+ glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1,
+ format, type,
+ bits + ((y1 - dy_src + dy_dst) * byte_stride +
+ (x1 - dx_src + dx_dst) * bytes_per_pixel));
}
}
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
- glPixelStorei(GL_PACK_SKIP_ROWS, 0);
- glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
}
/*
--
2.1.3
More information about the xorg-devel
mailing list