VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.c@ 34382

最後變更 在這個檔案從34382是 33540,由 vboxsync 提交於 14 年 前

*: spelling fixes, thanks Timeless!

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 4.7 KB
 
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 "chromium.h"
8#include "cr_error.h"
9#include "cr_mem.h"
10#include "cr_pixeldata.h"
11#include "server_dispatch.h"
12#include "server.h"
13
14void SERVER_DISPATCH_APIENTRY
15crServerDispatchGetTexImage(GLenum target, GLint level, GLenum format,
16 GLenum type, GLvoid * pixels)
17{
18 GLsizei width, height, depth, size;
19 GLvoid *buffer = NULL;
20
21
22#ifdef CR_ARB_pixel_buffer_object
23 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
24 {
25 GLvoid *pbo_offset;
26
27 /*pixels are actually a pointer to location of 8byte network pointer in hgcm buffer
28 regardless of guest/host bitness we're using only 4lower bytes as there're no
29 pbo>4gb (yet?)
30 */
31 pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
32
33 cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, pbo_offset);
34
35 return;
36 }
37#endif
38
39 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
40 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
41 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
42
43 size = crTextureSize(format, type, width, height, depth);
44
45#if 0
46 {
47 CRContext *ctx = crStateGetCurrent();
48 CRTextureObj *tobj;
49 CRTextureLevel *tl;
50 GLint id;
51
52 crDebug("GetTexImage: %d, %i, %d, %d", target, level, format, type);
53 crDebug("===StateTracker===");
54 crDebug("Current TU: %i", ctx->texture.curTextureUnit);
55
56 if (target==GL_TEXTURE_2D)
57 {
58 tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
59 CRASSERT(tobj);
60 tl = &tobj->level[0][level];
61 crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
62 }
63 else
64 {
65 crDebug("Not 2D tex");
66 }
67
68 crDebug("===GPU===");
69 cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &id);
70 crDebug("Current TU: %i", id);
71 if (target==GL_TEXTURE_2D)
72 {
73 cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
74 crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
75 }
76 }
77#endif
78
79 if (size && (buffer = crAlloc(size))) {
80 /* Note, the other pixel PACK parameters (default values) should
81 * be OK at this point.
82 */
83 cr_server.head_spu->dispatch_table.PixelStorei(GL_PACK_ALIGNMENT, 1);
84 cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, buffer);
85 crServerReturnValue( buffer, size );
86 crFree(buffer);
87 }
88 else {
89 /* need to return _something_ to avoid blowing up */
90 GLuint dummy = 0;
91 crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
92 }
93}
94
95
96#if CR_ARB_texture_compression
97
98void SERVER_DISPATCH_APIENTRY
99crServerDispatchGetCompressedTexImageARB(GLenum target, GLint level,
100 GLvoid *img)
101{
102 GLint size;
103 GLvoid *buffer=NULL;
104
105#ifdef CR_ARB_pixel_buffer_object
106 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
107 {
108 GLvoid *pbo_offset;
109
110 pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)img));
111
112 cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, pbo_offset);
113
114 return;
115 }
116#endif
117
118 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size);
119
120 if (size && (buffer = crAlloc(size))) {
121 /* XXX the pixel PACK parameter should be OK at this point */
122 cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, buffer);
123 crServerReturnValue( buffer, size );
124 crFree(buffer);
125 }
126 else {
127 /* need to return _something_ to avoid blowing up */
128 GLuint dummy = 0;
129 crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
130 }
131}
132
133#endif /* CR_ARB_texture_compression */
134
135void SERVER_DISPATCH_APIENTRY crServerDispatchGetPolygonStipple( GLubyte * mask )
136{
137#ifdef CR_ARB_pixel_buffer_object
138 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
139 {
140 GLvoid *pbo_offset;
141
142 pbo_offset = (GLubyte*) ((uintptr_t) *((GLint*)mask));
143
144 cr_server.head_spu->dispatch_table.GetPolygonStipple(pbo_offset);
145 }
146 else
147#endif
148 {
149 GLubyte local_mask[128];
150
151 cr_server.head_spu->dispatch_table.GetPolygonStipple( local_mask );
152 crServerReturnValue( &(local_mask[0]), 128*sizeof(GLubyte) );
153 }
154}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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