aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/dri/swrast/swrast.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-04 09:28:39 +0100
committermarha <marha@users.sourceforge.net>2011-11-04 09:28:39 +0100
commit23e2767dc3e6b8891d4b55b711c70c6bc85a6f85 (patch)
tree04c538697c3afbd401afb1bb614460b16be28844 /mesalib/src/mesa/drivers/dri/swrast/swrast.c
parent125500b44d0253d7fd7a59905ab730151d4f66e2 (diff)
parent02f377d5e2dd18537d0807ad63675a0970b5a37d (diff)
downloadvcxsrv-23e2767dc3e6b8891d4b55b711c70c6bc85a6f85.tar.gz
vcxsrv-23e2767dc3e6b8891d4b55b711c70c6bc85a6f85.tar.bz2
vcxsrv-23e2767dc3e6b8891d4b55b711c70c6bc85a6f85.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winglobals.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/include/scrnintstr.h xorg-server/xkb/ddxList.c xorg-server/xkb/ddxLoad.c
Diffstat (limited to 'mesalib/src/mesa/drivers/dri/swrast/swrast.c')
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c84
1 files changed, 80 insertions, 4 deletions
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index b1abc502f..75eb46ee6 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -296,7 +296,7 @@ swrast_alloc_front_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
rb->Data = NULL;
rb->Width = width;
rb->Height = height;
-
+ rb->RowStride = width;
xrb->pitch = bytes_per_line(width * xrb->bpp, 32);
return GL_TRUE;
@@ -320,7 +320,8 @@ swrast_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
static struct swrast_renderbuffer *
-swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
+swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv,
+ GLboolean front)
{
struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
GLuint pixel_format;
@@ -334,6 +335,7 @@ swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
pixel_format = choose_pixel_format(visual);
+ xrb->dPriv = dPriv;
xrb->Base.Delete = swrast_delete_renderbuffer;
if (front) {
xrb->Base.AllocStorage = swrast_alloc_front_storage;
@@ -380,6 +382,78 @@ swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
return xrb;
}
+static void
+swrast_map_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+ GLubyte *map = rb->Data;
+ int cpp = _mesa_get_format_bytes(rb->Format);
+ int stride = rb->RowStride * cpp;
+
+ if (rb->AllocStorage == swrast_alloc_front_storage) {
+ __DRIdrawable *dPriv = xrb->dPriv;
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+
+ xrb->map_mode = mode;
+ xrb->map_x = x;
+ xrb->map_y = y;
+ xrb->map_w = w;
+ xrb->map_h = h;
+
+ stride = w * cpp;
+ rb->Data = malloc(h * stride);
+
+ sPriv->swrast_loader->getImage(dPriv, x, y, w, h,
+ (char *)rb->Data,
+ dPriv->loaderPrivate);
+
+ *out_map = rb->Data;
+ *out_stride = stride;
+ return;
+ }
+
+ ASSERT(rb->Data);
+
+ if (rb->AllocStorage == swrast_alloc_back_storage) {
+ map += (rb->Height - 1) * stride;
+ stride = -stride;
+ }
+
+ map += y * stride;
+ map += x * cpp;
+
+ *out_map = map;
+ *out_stride = stride;
+}
+
+static void
+swrast_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+
+ if (rb->AllocStorage == swrast_alloc_front_storage) {
+ __DRIdrawable *dPriv = xrb->dPriv;
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+
+ if (xrb->map_mode & GL_MAP_WRITE_BIT) {
+ sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_DRAW,
+ xrb->map_x, xrb->map_y,
+ xrb->map_w, xrb->map_h,
+ rb->Data,
+ dPriv->loaderPrivate);
+ }
+
+ free(rb->Data);
+ rb->Data = NULL;
+ }
+}
+
static GLboolean
dri_create_buffer(__DRIscreen * sPriv,
__DRIdrawable * dPriv,
@@ -411,12 +485,12 @@ dri_create_buffer(__DRIscreen * sPriv,
_mesa_initialize_window_framebuffer(fb, visual);
/* add front renderbuffer */
- frontrb = swrast_new_renderbuffer(visual, GL_TRUE);
+ frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base);
/* add back renderbuffer */
if (visual->doubleBufferMode) {
- backrb = swrast_new_renderbuffer(visual, GL_FALSE);
+ backrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base);
}
@@ -581,6 +655,8 @@ swrast_init_driver_functions(struct dd_function_table *driver)
driver->GetBufferSize = NULL;
driver->Viewport = viewport;
driver->ChooseTextureFormat = swrastChooseTextureFormat;
+ driver->MapRenderbuffer = swrast_map_renderbuffer;
+ driver->UnmapRenderbuffer = swrast_unmap_renderbuffer;
}
static const char *es2_extensions[] = {