VirtualBox

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

Last change on this file since 69310 was 69310, checked in by vboxsync, 7 years ago

common/crOpenGL: scm updates

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