diff --git a/headers/os/opengl/GLRenderer.h b/headers/os/opengl/GLRenderer.h index 7f73a3c725..f1f2b60efe 100644 --- a/headers/os/opengl/GLRenderer.h +++ b/headers/os/opengl/GLRenderer.h @@ -27,8 +27,8 @@ public: void Acquire(); void Release(); - virtual void LockGL(); - virtual void UnlockGL(); + virtual void LockGL(); + virtual void UnlockGL(); virtual void SwapBuffers(bool VSync = false); virtual void Draw(BRect updateRect); diff --git a/src/add-ons/opengl/mesa/MesaSoftRenderer.cpp b/src/add-ons/opengl/mesa/MesaSoftRenderer.cpp index 683d63c6f3..4a1ec7b8e7 100644 --- a/src/add-ons/opengl/mesa/MesaSoftRenderer.cpp +++ b/src/add-ons/opengl/mesa/MesaSoftRenderer.cpp @@ -8,6 +8,8 @@ * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. */ + +#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__) #include "MesaSoftRenderer.h" extern "C" { @@ -156,6 +158,24 @@ MesaSoftRenderer::~MesaSoftRenderer() } +void +MesaSoftRenderer::LockGL() +{ + BGLRenderer::LockGL(); + + UpdateState(fContext, 0); + _mesa_make_current(fContext, fFrameBuffer); +} + + +void +MesaSoftRenderer::UnlockGL() +{ + + BGLRenderer::UnlockGL(); +} + + void MesaSoftRenderer::SwapBuffers(bool VSync = false) { @@ -172,6 +192,7 @@ MesaSoftRenderer::SwapBuffers(bool VSync = false) void MesaSoftRenderer::Draw(BRect updateRect) { + CALLED(); if (fBitmap) GLView()->DrawBitmap(fBitmap, updateRect, updateRect); } @@ -180,6 +201,7 @@ MesaSoftRenderer::Draw(BRect updateRect) status_t MesaSoftRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap) { + CALLED(); color_space scs = fBitmap->ColorSpace(); color_space dcs = bitmap->ColorSpace(); @@ -216,6 +238,7 @@ MesaSoftRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap) status_t MesaSoftRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location) { + CALLED(); color_space scs = bitmap->ColorSpace(); color_space dcs = fBitmap->ColorSpace(); @@ -252,6 +275,7 @@ MesaSoftRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location) void MesaSoftRenderer::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { + CALLED(); /* poll for window size change and realloc software Z/stencil/etc if needed */ _mesa_ResizeBuffersMESA(); } @@ -282,6 +306,8 @@ MesaSoftRenderer::Error(GLcontext *ctx) void MesaSoftRenderer::ClearIndex(GLcontext *ctx, GLuint index) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; mr->fClearIndex = index; } @@ -290,6 +316,8 @@ MesaSoftRenderer::ClearIndex(GLcontext *ctx, GLuint index) void MesaSoftRenderer::ClearColor(GLcontext *ctx, const GLfloat color[4]) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_RCOMP], color[0]); CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_GCOMP], color[1]); @@ -322,6 +350,8 @@ MesaSoftRenderer::ClearFront(GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; BGLView *bglview = mr->GLView(); assert(bglview); @@ -367,6 +397,8 @@ MesaSoftRenderer::ClearBack(GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; BGLView *bglview = mr->GLView(); assert(bglview); @@ -507,6 +539,8 @@ MesaSoftRenderer::WriteRGBASpanFront(const GLcontext *ctx, GLuint n, CONST GLubyte rgba[][4], const GLubyte mask[]) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; BGLView *bglview = mr->GLView(); assert(bglview); @@ -533,6 +567,8 @@ MesaSoftRenderer::WriteRGBSpanFront(const GLcontext *ctx, GLuint n, CONST GLubyte rgba[][3], const GLubyte mask[]) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; BGLView *bglview = mr->GLView(); assert(bglview); @@ -559,6 +595,8 @@ MesaSoftRenderer::WriteMonoRGBASpanFront(const GLcontext *ctx, GLuint n, const GLchan color[4], const GLubyte mask[]) { + CALLED(); + MesaSoftRenderer *mr = (MesaSoftRenderer *) ctx->DriverCtx; BGLView *bglview = mr->GLView(); assert(bglview); diff --git a/src/add-ons/opengl/mesa/MesaSoftRenderer.h b/src/add-ons/opengl/mesa/MesaSoftRenderer.h index c0267fe25c..24ba3069c5 100644 --- a/src/add-ons/opengl/mesa/MesaSoftRenderer.h +++ b/src/add-ons/opengl/mesa/MesaSoftRenderer.h @@ -24,6 +24,9 @@ class MesaSoftRenderer : public BGLRenderer public: MesaSoftRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher); virtual ~MesaSoftRenderer(); + + virtual void LockGL(); + virtual void UnlockGL(); virtual void SwapBuffers(bool VSync = false); virtual void Draw(BRect updateRect); diff --git a/src/kits/opengl/GLRenderer.cpp b/src/kits/opengl/GLRenderer.cpp index 125b752a00..f63ee1f9b3 100644 --- a/src/kits/opengl/GLRenderer.cpp +++ b/src/kits/opengl/GLRenderer.cpp @@ -8,6 +8,7 @@ BGLRenderer::BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher) : fRefCount(1), + fView(view), fOptions(bgl_options), fDispatcher(dispatcher) { @@ -39,12 +40,15 @@ BGLRenderer::Release() void BGLRenderer::LockGL() { + fView->LockLooper(); } void BGLRenderer::UnlockGL() { + if (fView->Looper()->IsLocked()) + fView->UnlockLooper(); }