VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.c@ 33281

Last change on this file since 33281 was 27983, checked in by vboxsync, 15 years ago

crOpenGL: fix 32/64bit bug

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "cr_spu.h"
8#include "chromium.h"
9#include "cr_error.h"
10#include "cr_mem.h"
11#include "cr_net.h"
12#include "cr_pixeldata.h"
13#include "cr_unpack.h"
14#include "server_dispatch.h"
15#include "server.h"
16
17
18void SERVER_DISPATCH_APIENTRY
19crServerDispatchReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
20 GLenum format, GLenum type, GLvoid *pixels)
21{
22 CRMessageReadPixels *rp;
23 const GLint stride = READ_DATA( 24, GLint );
24 const GLint alignment = READ_DATA( 28, GLint );
25 const GLint skipRows = READ_DATA( 32, GLint );
26 const GLint skipPixels = READ_DATA( 36, GLint );
27 const GLint bytes_per_row = READ_DATA( 40, GLint );
28 const GLint rowLength = READ_DATA( 44, GLint );
29 const int msg_len = sizeof(*rp) + bytes_per_row * height;
30
31 CRASSERT(bytes_per_row > 0);
32
33#ifdef CR_ARB_pixel_buffer_object
34 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
35 {
36 GLvoid *pbo_offset;
37
38 /*pixels are actualy a pointer to location of 8byte network pointer in hgcm buffer
39 regarless of guest/host bitness we're using only 4lower bytes as there're no
40 pbo>4gb (yet?)
41 */
42 pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
43
44 cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
45 format, type, pbo_offset);
46 }
47 else
48#endif
49 {
50 rp = (CRMessageReadPixels *) crAlloc( msg_len );
51
52 /* Note: the ReadPixels data gets densely packed into the buffer
53 * (no skip pixels, skip rows, etc. It's up to the receiver (pack spu,
54 * tilesort spu, etc) to apply the real PixelStore packing parameters.
55 */
56 cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
57 format, type, rp + 1);
58
59 rp->header.type = CR_MESSAGE_READ_PIXELS;
60 rp->width = width;
61 rp->height = height;
62 rp->bytes_per_row = bytes_per_row;
63 rp->stride = stride;
64 rp->format = format;
65 rp->type = type;
66 rp->alignment = alignment;
67 rp->skipRows = skipRows;
68 rp->skipPixels = skipPixels;
69 rp->rowLength = rowLength;
70
71 /* <pixels> points to the 8-byte network pointer */
72 crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) );
73
74 crNetSend( cr_server.curClient->conn, NULL, rp, msg_len );
75 crFree( rp );
76 }
77}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette