diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:41:37 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-11-22 02:41:37 +0000 |
commit | 9740fe78ad46dacb0349f19ebc11015fc13ecc9c (patch) | |
tree | 569feb0dddd15872582fb9b868abca8f1989c664 /lib/mesa/src/hgl/GLView.cpp | |
parent | bf4c88183bf9b8cff6d81c27df7702559282a0ac (diff) |
import Mesa 11.0.6
Diffstat (limited to 'lib/mesa/src/hgl/GLView.cpp')
-rw-r--r-- | lib/mesa/src/hgl/GLView.cpp | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/lib/mesa/src/hgl/GLView.cpp b/lib/mesa/src/hgl/GLView.cpp index 3462c8854..9ae5b5c83 100644 --- a/lib/mesa/src/hgl/GLView.cpp +++ b/lib/mesa/src/hgl/GLView.cpp @@ -18,12 +18,12 @@ #include <string.h> #include <DirectWindow.h> -#include "GLRenderer.h" +#include <GLRenderer.h> -#include <private/interface/DirectWindowPrivate.h> +#include "interface/DirectWindowPrivate.h" +#include "GLDispatcher.h" #include "GLRendererRoster.h" -#include "glapi/glapi.h" struct glview_direct_info { direct_buffer_info* direct_info; @@ -39,6 +39,7 @@ BGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode, ulong options) : BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), + // | B_FULL_UPDATE_ON_RESIZE) fGc(NULL), fOptions(options), fDitherCount(0), @@ -46,9 +47,10 @@ BGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode, fDisplayLock("BGLView display lock"), fClipInfo(NULL), fRenderer(NULL), + fRoster(NULL), fDitherMap(NULL) { - fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options); + fRoster = new GLRendererRoster(this, options); } @@ -66,7 +68,7 @@ BGLView::LockGL() // TODO: acquire the OpenGL API lock it on this glview fDisplayLock.Lock(); - if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) + if (fRenderer) fRenderer->LockGL(); } @@ -74,16 +76,7 @@ BGLView::LockGL() void BGLView::UnlockGL() { - thread_id lockerThread = fDisplayLock.LockingThread(); - thread_id callerThread = find_thread(NULL); - - if (lockerThread != B_ERROR && lockerThread != callerThread) { - printf("UnlockGL is called from wrong thread, lockerThread: %d, callerThread: %d\n", - (int)lockerThread, (int)callerThread); - debugger("[!]"); - } - - if (fRenderer != NULL && fDisplayLock.CountLocks() == 1) + if (fRenderer) fRenderer->UnlockGL(); fDisplayLock.Unlock(); @@ -119,7 +112,15 @@ BGLView::EmbeddedView() void* BGLView::GetGLProcAddress(const char* procName) { - return (void*)_glapi_get_proc_address(procName); + BGLDispatcher* glDispatcher = NULL; + + if (fRenderer) + glDispatcher = fRenderer->GLDispatcher(); + + if (glDispatcher) + return (void*)glDispatcher->AddressOf(procName); + + return NULL; } @@ -168,8 +169,9 @@ void BGLView::Draw(BRect updateRect) { if (fRenderer) { - if (!fClipInfo || !fClipInfo->enable_direct_mode) - fRenderer->Draw(updateRect); + _LockDraw(); + fRenderer->Draw(updateRect); + _UnlockDraw(); return; } // TODO: auto-size and center the string @@ -187,6 +189,7 @@ BGLView::AttachedToWindow() for (BView* view = this; view != NULL; view = view->Parent()) view->ConvertToParent(&fBounds); + fRenderer = fRoster->GetRenderer(); if (fRenderer != NULL) { // Jackburton: The following code was commented because it doesn't look // good in "direct" mode: @@ -234,6 +237,10 @@ BGLView::AllAttached() void BGLView::DetachedFromWindow() { + if (fRenderer) + fRenderer->Release(); + fRenderer = NULL; + BView::DetachedFromWindow(); } @@ -253,9 +260,12 @@ BGLView::FrameResized(float width, float height) v->ConvertToParent(&fBounds); if (fRenderer) { - //_LockDraw(); + LockGL(); + _LockDraw(); + _CallDirectConnected(); fRenderer->FrameResized(width, height); - //_UnlockDraw(); + _UnlockDraw(); + UnlockGL(); } BView::FrameResized(width, height); @@ -332,7 +342,6 @@ BGLView::GetSupportedSuites(BMessage* data) void BGLView::DirectConnected(direct_buffer_info* info) { - printf("BGLView::DirectConnected\n"); if (fClipInfo == NULL) { fClipInfo = new (std::nothrow) glview_direct_info(); if (fClipInfo == NULL) @@ -341,33 +350,33 @@ BGLView::DirectConnected(direct_buffer_info* info) direct_buffer_info* localInfo = fClipInfo->direct_info; - _LockDraw(); switch (info->buffer_state & B_DIRECT_MODE_MASK) { case B_DIRECT_START: fClipInfo->direct_connected = true; memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); + _UnlockDraw(); break; case B_DIRECT_MODIFY: + _LockDraw(); memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE); + _UnlockDraw(); break; case B_DIRECT_STOP: fClipInfo->direct_connected = false; + _LockDraw(); break; } if (fRenderer) _CallDirectConnected(); - - _UnlockDraw(); } void BGLView::EnableDirectMode(bool enabled) { - printf("BGLView::EnableDirectMode: %d\n", (int)enabled); if (fRenderer) fRenderer->EnableDirectMode(enabled); if (fClipInfo == NULL) { @@ -403,10 +412,8 @@ BGLView::_UnlockDraw() void BGLView::_CallDirectConnected() { - if (!fClipInfo || !fClipInfo->direct_connected) { - fRenderer->DirectConnected(NULL); + if (!fClipInfo) return; - } direct_buffer_info* localInfo = fClipInfo->direct_info; direct_buffer_info* info = (direct_buffer_info*)malloc( @@ -465,9 +472,10 @@ BGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode, fDisplayLock("BGLView display lock"), fClipInfo(NULL), fRenderer(NULL), + fRoster(NULL), fDitherMap(NULL) { - fRenderer = GLRendererRoster::Roster()->GetRenderer(this, options); + fRoster = new GLRendererRoster(this, options); } |