server_readpixels.c revision febfe671adda070d044dced344f97b3971f2a660
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/* Copyright (c) 2001, Stanford University
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * All rights reserved
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * See the file LICENSE.txt for information on redistributing this software.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_spu.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "chromium.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_error.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_mem.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_net.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_pixeldata.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_unpack.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "server_dispatch.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "server.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid SERVER_DISPATCH_APIENTRY
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrServerDispatchReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
febfe671adda070d044dced344f97b3971f2a660vboxsync GLenum format, GLenum type, GLvoid *pixels)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
febfe671adda070d044dced344f97b3971f2a660vboxsync CRMessageReadPixels *rp;
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint stride = READ_DATA( 24, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint alignment = READ_DATA( 28, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint skipRows = READ_DATA( 32, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint skipPixels = READ_DATA( 36, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint bytes_per_row = READ_DATA( 40, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const GLint rowLength = READ_DATA( 44, GLint );
febfe671adda070d044dced344f97b3971f2a660vboxsync const int msg_len = sizeof(*rp) + bytes_per_row * height;
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync CRASSERT(bytes_per_row > 0);
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync rp = (CRMessageReadPixels *) crAlloc( msg_len );
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync /* Note: the ReadPixels data gets densely packed into the buffer
febfe671adda070d044dced344f97b3971f2a660vboxsync * (no skip pixels, skip rows, etc. It's up to the receiver (pack spu,
febfe671adda070d044dced344f97b3971f2a660vboxsync * tilesort spu, etc) to apply the real PixelStore packing parameters.
febfe671adda070d044dced344f97b3971f2a660vboxsync */
febfe671adda070d044dced344f97b3971f2a660vboxsync cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
febfe671adda070d044dced344f97b3971f2a660vboxsync format, type, rp + 1);
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->header.type = CR_MESSAGE_READ_PIXELS;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->width = width;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->height = height;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->bytes_per_row = bytes_per_row;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->stride = stride;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->format = format;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->type = type;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->alignment = alignment;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->skipRows = skipRows;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->skipPixels = skipPixels;
febfe671adda070d044dced344f97b3971f2a660vboxsync rp->rowLength = rowLength;
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync /* <pixels> points to the 8-byte network pointer */
febfe671adda070d044dced344f97b3971f2a660vboxsync crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) );
febfe671adda070d044dced344f97b3971f2a660vboxsync
febfe671adda070d044dced344f97b3971f2a660vboxsync crNetSend( cr_server.curClient->conn, NULL, rp, msg_len );
febfe671adda070d044dced344f97b3971f2a660vboxsync crFree( rp );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}