aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa/src/mesa/main/context.c
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:46:25 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:46:25 +0200
commit844a4094f098684dd1da5bc11e73479fb61373a3 (patch)
tree5441f02930e1658777a262f3d3647d64f99cde22 /nx-X11/extras/Mesa/src/mesa/main/context.c
parentf4092abdf94af6a99aff944d6264bc1284e8bdd4 (diff)
downloadnx-libs-844a4094f098684dd1da5bc11e73479fb61373a3.tar.gz
nx-libs-844a4094f098684dd1da5bc11e73479fb61373a3.tar.bz2
nx-libs-844a4094f098684dd1da5bc11e73479fb61373a3.zip
Imported nx-X11-3.1.0-3.tar.gznx-X11/3.1.0-3
Summary: Imported nx-X11-3.1.0-3.tar.gz Keywords: Imported nx-X11-3.1.0-3.tar.gz into Git repository
Diffstat (limited to 'nx-X11/extras/Mesa/src/mesa/main/context.c')
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/context.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa/src/mesa/main/context.c b/nx-X11/extras/Mesa/src/mesa/main/context.c
index 25a3f6a37..eb4b4ce4e 100644
--- a/nx-X11/extras/Mesa/src/mesa/main/context.c
+++ b/nx-X11/extras/Mesa/src/mesa/main/context.c
@@ -131,6 +131,10 @@
#endif
#include "shaderobjects.h"
+#ifdef NXAGENT_SERVER
+#include "WSDrawBuffer.h"
+#endif
+
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
#endif
@@ -143,6 +147,47 @@ int MESA_VERBOSE = 0;
int MESA_DEBUG_FLAGS = 0;
#endif
+#ifdef NXAGENT_SERVER
+extern WSDrawBufferPtr pWSDrawBuffer;
+
+int IsWSDrawBuffer(GLframebuffer *mesa_buffer)
+{
+ WSDrawBufferPtr p = pWSDrawBuffer;
+
+ while (p != NULL) {
+ if (p -> DrawBuffer == mesa_buffer) {
+ return 1;
+ }
+ p = p -> next;
+ }
+ return 0;
+}
+
+void FreeWSDrawBuffer(GLframebuffer *mesa_buffer)
+{
+ WSDrawBufferPtr p = pWSDrawBuffer;
+ WSDrawBufferPtr pOld = NULL;
+
+ if (p == NULL)
+ return;
+
+ if (p -> DrawBuffer == mesa_buffer) {
+ pWSDrawBuffer = p -> next;
+ free(p);
+ return;
+ }
+
+ while (p -> next != NULL) {
+ if (p -> next -> DrawBuffer == mesa_buffer) {
+ pOld = p -> next;
+ p -> next = p -> next -> next;
+ free(pOld);
+ return;
+ }
+ p = p -> next;
+ }
+}
+#endif
/* ubyte -> float conversion */
GLfloat _mesa_ubyte_to_float_color_tab[256];
@@ -1520,6 +1565,10 @@ void
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
+ #ifdef NXAGENT_SERVER
+ int flag;
+ #endif
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(newCtx, "_mesa_make_current()\n");
@@ -1558,11 +1607,30 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
ASSERT(readBuffer->Name == 0);
newCtx->WinSysDrawBuffer = drawBuffer;
newCtx->WinSysReadBuffer = readBuffer;
+
+#ifdef NXAGENT_SERVER
+ flag = 0;
+ if (newCtx->DrawBuffer) {
+ if (!IsWSDrawBuffer(newCtx->DrawBuffer)) {
+ if (newCtx->DrawBuffer->Name == 0) {
+ flag = 1;
+ }
+ FreeWSDrawBuffer(newCtx->DrawBuffer);
+ }
+ else flag = 1;
+ }
+
+ if (!newCtx->DrawBuffer || flag) {
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
+ }
+#else
/* don't replace user-buffer bindings with window system buffer */
if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
newCtx->DrawBuffer = drawBuffer;
newCtx->ReadBuffer = readBuffer;
}
+#endif
newCtx->NewState |= _NEW_BUFFERS;