summaryrefslogtreecommitdiff
path: root/src/glx/drisw_glx.c
diff options
context:
space:
mode:
authorGeorge Sapountzis <gsapountzis@gmail.com>2010-03-28 19:30:03 +0300
committerGeorge Sapountzis <gsapountzis@gmail.com>2010-03-28 19:30:54 +0300
commita24fc90703f62d286031cb2ee8f625ef728243fd (patch)
tree5772b573c75440f065636b27045029dcea4fd197 /src/glx/drisw_glx.c
parentc42fe8cd278fdff831f557bbfcbfde16bd38a65d (diff)
drisw: probably better hack for stride and some comments
Diffstat (limited to 'src/glx/drisw_glx.c')
-rw-r--r--src/glx/drisw_glx.c89
1 files changed, 30 insertions, 59 deletions
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index b561523946..786faff81c 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -129,10 +129,32 @@ swrastGetDrawableInfo(__DRIdrawable * draw,
*h = uh;
}
+/**
+ * Align renderbuffer pitch.
+ *
+ * This should be chosen by the driver and the loader (libGL, xserver/glx)
+ * should use the driver provided pitch.
+ *
+ * It seems that the xorg loader (that is the xserver loading swrast_dri for
+ * indirect rendering, not client-side libGL) requires that the pitch is
+ * exactly the image width padded to 32 bits. XXX
+ *
+ * The above restriction can probably be overcome by using ScratchPixmap and
+ * CopyArea in the xserver, similar to ShmPutImage, and setting the width of
+ * the scratch pixmap to 'pitch / cpp'.
+ */
+static inline int
+bytes_per_line(unsigned pitch_bits, unsigned mul)
+{
+ unsigned mask = mul - 1;
+
+ return ((pitch_bits + mask) & ~mask) / 8;
+}
+
static void
-swrastPutImage2(__DRIdrawable * draw, int op,
- int x, int y, int w, int h,
- char *data, int pitch, void *loaderPrivate)
+swrastPutImage(__DRIdrawable * draw, int op,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
@@ -158,7 +180,7 @@ swrastPutImage2(__DRIdrawable * draw, int op,
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = pitch;
+ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
@@ -166,9 +188,9 @@ swrastPutImage2(__DRIdrawable * draw, int op,
}
static void
-swrastGetImage2(__DRIdrawable * read,
- int x, int y, int w, int h,
- char *data, int pitch, void *loaderPrivate)
+swrastGetImage(__DRIdrawable * read,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
{
__GLXDRIdrawablePrivate *prp = loaderPrivate;
__GLXDRIdrawable *pread = &(prp->base);
@@ -182,64 +204,13 @@ swrastGetImage2(__DRIdrawable * read,
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = pitch;
+ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
ximage->data = NULL;
}
-/**
- * Align renderbuffer pitch.
- *
- * This should be chosen by the driver and the loader (libGL, xserver/glx)
- * should use the driver provided pitch.
- *
- * It seems that the xorg loader (that is the xserver loading swrast_dri for
- * indirect rendering, not client-side libGL) requires that the pitch is
- * exactly the image width padded to 32 bits. XXX
- *
- * Is this a hard requirement that requires extra copies for different pitches
- * or can the xorg loader use the driver pitch without extra copies ?
- */
-static inline int
-bytes_per_line(unsigned pitch_bits, unsigned mul)
-{
- unsigned mask = mul - 1;
-
- return ((pitch_bits + mask) & ~mask) / 8;
-}
-
-static void
-swrastPutImage(__DRIdrawable * draw, int op,
- int x, int y, int w, int h,
- char *data, void *loaderPrivate)
-{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
- int bpp, pitch;
-
- bpp = pdp->ximage->bits_per_pixel;
-
- pitch = bytes_per_line(w * bpp, 32);
-
- swrastPutImage2(draw, op, x, y, w, h, data, pitch, loaderPrivate);
-}
-
-static void
-swrastGetImage(__DRIdrawable * read,
- int x, int y, int w, int h,
- char *data, void *loaderPrivate)
-{
- __GLXDRIdrawablePrivate *prp = loaderPrivate;
- int bpp, pitch;
-
- bpp = prp->ximage->bits_per_pixel;
-
- pitch = bytes_per_line(w * bpp, 32);
-
- swrastGetImage2(read, x, y, w, h, data, pitch, loaderPrivate);
-}
-
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
{__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
swrastGetDrawableInfo,