VirtualBox

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

最後變更 在這個檔案從19099是 19099,由 vboxsync 提交於 16 年 前

crOpenGL: fix multicontext crashes (public bug #3762)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.6 KB
 
1/* $Id: feedback_context.c 19099 2009-04-22 09:13:20Z vboxsync $ */
2
3/** @file
4 * VBox feedback spu, context tracking.
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
10 * Sun Microsystems, Inc. confidential
11 * All rights reserved
12 */
13
14#include "cr_spu.h"
15#include "cr_error.h"
16#include "feedbackspu.h"
17
18/*@todo Multithreading case. (See feedback_spu.self.RenderMode)*/
19
20GLint FEEDBACKSPU_APIENTRY
21feedbackspu_CreateContext( const char *dpyName, GLint visual, GLint shareCtx )
22{
23 GLint ctx, slot;
24
25#ifdef CHROMIUM_THREADSAFE
26 crLockMutex(&feedback_spu.mutex);
27#endif
28
29 ctx = feedback_spu.child.CreateContext(dpyName, visual, shareCtx);
30
31 /* find an empty context slot */
32 for (slot = 0; slot < feedback_spu.numContexts; slot++) {
33 if (!feedback_spu.context[slot].clientState) {
34 /* found empty slot */
35 break;
36 }
37 }
38 if (slot == feedback_spu.numContexts) {
39 feedback_spu.numContexts++;
40 }
41
42 feedback_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL);
43 feedback_spu.context[slot].clientCtx = ctx;
44
45#ifdef CHROMIUM_THREADSAFE
46 crUnlockMutex(&feedback_spu.mutex);
47#endif
48
49 return ctx;
50}
51
52void FEEDBACKSPU_APIENTRY
53feedbackspu_MakeCurrent( GLint window, GLint nativeWindow, GLint ctx )
54{
55#ifdef CHROMIUM_THREADSAFE
56 crLockMutex(&feedback_spu.mutex);
57#endif
58 feedback_spu.child.MakeCurrent(window, nativeWindow, ctx);
59
60 if (ctx) {
61 int slot;
62 GLint oldmode;
63
64 for (slot=0; slot<feedback_spu.numContexts; ++slot)
65 if (feedback_spu.context[slot].clientCtx == ctx) break;
66 CRASSERT(slot < feedback_spu.numContexts);
67
68 crStateMakeCurrent(feedback_spu.context[slot].clientState);
69
70 crStateGetIntegerv(GL_RENDER_MODE, &oldmode);
71
72 if (oldmode!=feedback_spu.render_mode)
73 {
74 feedback_spu.self.RenderMode(oldmode);
75 }
76 }
77 else
78 {
79 crStateMakeCurrent(NULL);
80 }
81
82#ifdef CHROMIUM_THREADSAFE
83 crUnlockMutex(&feedback_spu.mutex);
84#endif
85}
86
87void FEEDBACKSPU_APIENTRY
88feedbackspu_DestroyContext( GLint ctx )
89{
90#ifdef CHROMIUM_THREADSAFE
91 crLockMutex(&feedback_spu.mutex);
92#endif
93 feedback_spu.child.DestroyContext(ctx);
94
95 if (ctx) {
96 int slot;
97
98 for (slot=0; slot<feedback_spu.numContexts; ++slot)
99 if (feedback_spu.context[slot].clientCtx == ctx) break;
100 CRASSERT(slot < feedback_spu.numContexts);
101
102 crStateDestroyContext(feedback_spu.context[slot].clientState);
103
104 feedback_spu.context[slot].clientState = NULL;
105 feedback_spu.context[slot].clientCtx = 0;
106 }
107
108#ifdef CHROMIUM_THREADSAFE
109 crUnlockMutex(&feedback_spu.mutex);
110#endif
111}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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