VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/feedback/feedback_context.c@ 42500

Last change on this file since 42500 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: feedback_context.c 42499 2012-08-01 10:26:43Z vboxsync $ */
2
3/** @file
4 * VBox feedback spu, context tracking.
5 */
6
7/*
8 * Copyright (C) 2009 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#include "cr_spu.h"
20#include "cr_error.h"
21#include "feedbackspu.h"
22
23/*@todo Multithreading case. (See feedback_spu.self.RenderMode)*/
24
25GLint FEEDBACKSPU_APIENTRY
26feedbackspu_VBoxCreateContext( GLint con, const char *dpyName, GLint visual, GLint shareCtx )
27{
28 GLint ctx, slot;
29
30#ifdef CHROMIUM_THREADSAFE
31 crLockMutex(&feedback_spu.mutex);
32#endif
33
34 ctx = feedback_spu.child.VBoxCreateContext(con, dpyName, visual, shareCtx);
35
36 /* find an empty context slot */
37 for (slot = 0; slot < feedback_spu.numContexts; slot++) {
38 if (!feedback_spu.context[slot].clientState) {
39 /* found empty slot */
40 break;
41 }
42 }
43 if (slot == feedback_spu.numContexts) {
44 feedback_spu.numContexts++;
45 }
46
47 feedback_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL);
48 feedback_spu.context[slot].clientCtx = ctx;
49
50#ifdef CHROMIUM_THREADSAFE
51 crUnlockMutex(&feedback_spu.mutex);
52#endif
53
54 return ctx;
55}
56
57GLint FEEDBACKSPU_APIENTRY
58feedbackspu_CreateContext( const char *dpyName, GLint visual, GLint shareCtx )
59{
60 return feedbackspu_VBoxCreateContext( 0, dpyName, visual, shareCtx );
61}
62
63void FEEDBACKSPU_APIENTRY
64feedbackspu_MakeCurrent( GLint window, GLint nativeWindow, GLint ctx )
65{
66#ifdef CHROMIUM_THREADSAFE
67 crLockMutex(&feedback_spu.mutex);
68#endif
69 feedback_spu.child.MakeCurrent(window, nativeWindow, ctx);
70
71 if (ctx) {
72 int slot;
73 GLint oldmode;
74
75 for (slot=0; slot<feedback_spu.numContexts; ++slot)
76 if (feedback_spu.context[slot].clientCtx == ctx) break;
77 CRASSERT(slot < feedback_spu.numContexts);
78
79 crStateMakeCurrent(feedback_spu.context[slot].clientState);
80
81 crStateGetIntegerv(GL_RENDER_MODE, &oldmode);
82
83 if (oldmode!=feedback_spu.render_mode)
84 {
85 feedback_spu.self.RenderMode(oldmode);
86 }
87 }
88 else
89 {
90 crStateMakeCurrent(NULL);
91 }
92
93#ifdef CHROMIUM_THREADSAFE
94 crUnlockMutex(&feedback_spu.mutex);
95#endif
96}
97
98void FEEDBACKSPU_APIENTRY
99feedbackspu_DestroyContext( GLint ctx )
100{
101#ifdef CHROMIUM_THREADSAFE
102 crLockMutex(&feedback_spu.mutex);
103#endif
104 feedback_spu.child.DestroyContext(ctx);
105
106 if (ctx) {
107 int slot;
108
109 for (slot=0; slot<feedback_spu.numContexts; ++slot)
110 if (feedback_spu.context[slot].clientCtx == ctx) break;
111 CRASSERT(slot < feedback_spu.numContexts);
112
113 crStateDestroyContext(feedback_spu.context[slot].clientState);
114
115 feedback_spu.context[slot].clientState = NULL;
116 feedback_spu.context[slot].clientCtx = 0;
117 }
118
119#ifdef CHROMIUM_THREADSAFE
120 crUnlockMutex(&feedback_spu.mutex);
121#endif
122}
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