VirtualBox

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

Last change on this file since 78341 was 78341, checked in by vboxsync, 6 years ago

Config.kmk,Additions/common/crOpenGL,VBox/GuestHost/OpenGL,HostServices/SharedOpenGL: Remove CHROMIUM_THREADSAFE define and apply the current default

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: feedback_context.c 78341 2019-04-28 16:47:51Z vboxsync $ */
2/** @file
3 * VBox feedback spu, context tracking.
4 */
5
6/*
7 * Copyright (C) 2009-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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 crLockMutex(&feedback_spu.mutex);
39 ctx = feedback_spu.child.VBoxCreateContext(con, dpyName, visual, shareCtx);
40
41 /* find an empty context slot */
42 for (slot = 0; slot < feedback_spu.numContexts; slot++) {
43 if (!feedback_spu.context[slot].clientState) {
44 /* found empty slot */
45 break;
46 }
47 }
48 if (slot == feedback_spu.numContexts) {
49 feedback_spu.numContexts++;
50 }
51
52 feedback_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL);
53 feedback_spu.context[slot].clientCtx = ctx;
54
55 crUnlockMutex(&feedback_spu.mutex);
56 return ctx;
57}
58
59GLint FEEDBACKSPU_APIENTRY
60feedbackspu_CreateContext( const char *dpyName, GLint visual, GLint shareCtx )
61{
62 return feedbackspu_VBoxCreateContext( 0, dpyName, visual, shareCtx );
63}
64
65void FEEDBACKSPU_APIENTRY
66feedbackspu_MakeCurrent( GLint window, GLint nativeWindow, GLint ctx )
67{
68 crLockMutex(&feedback_spu.mutex);
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 crUnlockMutex(&feedback_spu.mutex);
94}
95
96void FEEDBACKSPU_APIENTRY
97feedbackspu_DestroyContext( GLint ctx )
98{
99 crLockMutex(&feedback_spu.mutex);
100 feedback_spu.child.DestroyContext(ctx);
101
102 if (ctx) {
103 int slot;
104
105 for (slot=0; slot<feedback_spu.numContexts; ++slot)
106 if (feedback_spu.context[slot].clientCtx == ctx) break;
107 CRASSERT(slot < feedback_spu.numContexts);
108
109 crStateDestroyContext(feedback_spu.context[slot].clientState);
110
111 feedback_spu.context[slot].clientState = NULL;
112 feedback_spu.context[slot].clientCtx = 0;
113 }
114
115 crUnlockMutex(&feedback_spu.mutex);
116}
117
Note: See TracBrowser for help on using the repository browser.

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