VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/expando/expandospu.c@ 55998

Last change on this file since 55998 was 54905, checked in by vboxsync, 10 years ago

Host 3D: Chromium server: add Expando SPU and DLM module in order to record and save OpenGL Display Lists (currently disabled).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: expandospu.c 54905 2015-03-23 11:20:58Z vboxsync $ */
2/* Copyright (c) 2001, Stanford University
3 * All rights reserved
4 *
5 * See the file LICENSE.txt for information on redistributing this software.
6 */
7
8#include <stdio.h>
9#include "cr_spu.h"
10#include "cr_dlm.h"
11#include "cr_mem.h"
12#include "expandospu.h"
13
14extern GLint EXPANDOSPU_APIENTRY
15expandoCreateContext(const char *displayName, GLint visBits, GLint shareCtx)
16{
17 ExpandoContextState *contextState;
18 GLint contextId;
19
20 /* Allocate our own per-context record */
21 contextState = crCalloc(sizeof(ExpandoContextState));
22 if (contextState == NULL) {
23 crError("expando: couldn't allocate per-context state");
24 return 0;
25 }
26
27 /* Get an official context ID from our super */
28 contextId = expando_spu.super.CreateContext(displayName, visBits, shareCtx);
29
30 /* Supplement that with our DLM. In a more correct situation, we should
31 * see if we've been called through glXCreateContext, which has a parameter
32 * for sharing DLMs. We don't currently get that information, so for now
33 * give each context its own DLM.
34 */
35 contextState->dlm = crDLMNewDLM(0, NULL);
36 if (!contextState->dlm) {
37 crError("expando: couldn't get DLM!");
38 }
39
40 contextState->dlmContext = crDLMNewContext(contextState->dlm);
41 if (!contextState->dlmContext) {
42 crError("expando: couldn't get dlmContext");
43 }
44
45 /* The DLM needs us to use the state tracker to track client
46 * state, so we can compile client-state-using functions correctly.
47 */
48 contextState->State = crStateCreateContext(NULL, visBits, NULL);
49
50 /* Associate the Expando context with the user context. */
51 crHashtableAdd(expando_spu.contextTable, contextId, (void *)contextState);
52
53 return contextId;
54}
55
56void expando_free_context_state(void *data)
57{
58 ExpandoContextState *expandoContextState = (ExpandoContextState *)data;
59
60 crDLMFreeContext(expandoContextState->dlmContext);
61 crDLMFreeDLM(expandoContextState->dlm);
62 crStateDestroyContext(expandoContextState->State);
63 crFree(expandoContextState);
64}
65
66extern void EXPANDOSPU_APIENTRY
67expandoDestroyContext(GLint contextId)
68{
69 /* Destroy our context information */
70 crHashtableDelete(expando_spu.contextTable, contextId,
71 expando_free_context_state);
72
73 /* Pass along the destruction to our super. */
74 expando_spu.super.DestroyContext(contextId);
75}
76
77extern void EXPANDOSPU_APIENTRY
78expandoMakeCurrent(GLint crWindow, GLint nativeWindow, GLint contextId)
79{
80 ExpandoContextState *expandoContextState;
81
82 expando_spu.super.MakeCurrent(crWindow, nativeWindow, contextId);
83
84 expandoContextState = crHashtableSearch(expando_spu.contextTable, contextId);
85 if (expandoContextState) {
86 crDLMSetCurrentState(expandoContextState->dlmContext);
87 crStateMakeCurrent(expandoContextState->State);
88 }
89 else {
90 crDLMSetCurrentState(NULL);
91 crStateMakeCurrent(NULL);
92 }
93}
94
95extern void EXPANDOSPU_APIENTRY
96expandoNewList(GLuint list, GLenum mode)
97{
98 crDebug("Expando SPU: expandoNewList()");
99 crDLMNewList(list, mode);
100}
101
102extern void EXPANDOSPU_APIENTRY
103expandoEndList(void)
104{
105 crDebug("Expando SPU: expandoEndList()");
106 crDLMEndList();
107}
108
109extern void EXPANDOSPU_APIENTRY
110expandoDeleteLists(GLuint first, GLsizei range)
111{
112 crDLMDeleteLists(first, range);
113}
114
115extern GLuint EXPANDOSPU_APIENTRY
116expandoGenLists(GLsizei range)
117{
118 return crDLMGenLists(range);
119}
120
121extern GLboolean EXPANDOSPU_APIENTRY
122expandoIsList(GLuint list)
123{
124 return crDLMIsList(list);
125}
126
127extern void EXPANDOSPU_APIENTRY
128expandoCallList(GLuint list)
129{
130 GLenum mode = crDLMGetCurrentMode();
131 if (mode != GL_FALSE) {
132 crDLMCompileCallList(list);
133 if (mode == GL_COMPILE) return;
134 }
135
136 /* Instead of passing through the CallList,
137 * expand it into its components. This will cause
138 * a recursion if there are any compiled CallList
139 * elements within the display list.
140 */
141 crDLMReplayList(list, &expando_spu.self);
142}
143
144extern void EXPANDOSPU_APIENTRY
145expandoCallLists(GLsizei n, GLenum type, const GLvoid *lists)
146{
147 GLenum mode = crDLMGetCurrentMode();
148 if (mode != GL_FALSE) {
149 crDLMCompileCallLists(n, type, lists);
150 if (mode == GL_COMPILE) return;
151 }
152 /* Instead of passing through the CallLists,
153 * expand it into its components. This will cause
154 * a recursion if there are any compiled CallLists
155 * elements within the display list.
156 */
157 crDLMReplayLists(n, type, lists, &expando_spu.self);
158}
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