[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58669] branches/soc-2013-viewport_fx/ intern/ghost/intern: WGL_ContextEGL in working order

Jason Wilkins Jason.A.Wilkins at gmail.com
Sat Jul 27 18:38:52 CEST 2013


Revision: 58669
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58669
Author:   jwilkins
Date:     2013-07-27 16:38:52 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
WGL_ContextEGL in working order

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.h
    branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp	2013-07-27 16:28:43 UTC (rev 58668)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.cpp	2013-07-27 16:38:52 UTC (rev 58669)
@@ -151,26 +151,26 @@
 	if (!result) {
 		EGLenum error = eglGetError();
 
-		const char* code = get_egl_error_enum_string(error),
+		const char* code = get_egl_error_enum_string(error);
 		const char* msg  = get_egl_error_message_string(error);
 
 #ifndef NDEBUG
 		fprintf(
 			stderr,
-			"%s(%d): EGL Error (%4X): %s: %s\n",
+			"%s(%d):[%s] -> EGL Error (%04X): %s: %s\n",
 			file,
 			line,
 			text,
 			error,
-			code ? code : "Unknown Code",
-			msg  ? msg  : "Unknown Error");
+			code ? code : "<Unknown>",
+			msg  ? msg  : "<Unknown>");
 #else
 		fprintf(
 			stderr,
-			"EGL Error (%4X): %s: %s\n",
+			"EGL Error (%04X): %s: %s\n",
 			error,
-			code ? code : "Unknown Code",
-			msg  ? msg  : "Unknown Error");
+			code ? code : "<Unknown>",
+			msg  ? msg  : "<Unknown>");
 #endif
 	}
 
@@ -251,8 +251,27 @@
 
 GHOST_ContextEGL::~GHOST_ContextEGL()
 {
-	removeDrawingContext();
+	bindAPI(m_api);
 
+	if (m_context != EGL_NO_CONTEXT) {
+		if (m_context == ::eglGetCurrentContext())
+			EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+
+		if (m_context != m_sharedContext || m_sharedCount == 1) {
+			assert(m_sharedCount > 0);
+
+			m_sharedCount--;
+
+			if (m_sharedCount == 0)
+				m_sharedContext = EGL_NO_CONTEXT;
+
+			EGL_CHK(::eglDestroyContext(m_display, m_context));
+		}
+	}
+
+	if (m_surface != EGL_NO_SURFACE)
+		EGL_CHK(::eglDestroySurface(m_display, m_surface));
+
 	EGL_CHK(::eglTerminate(m_display));
 }
 
@@ -286,7 +305,7 @@
 
 
 
-GHOST_TSuccess GHOST_ContextEGL::installDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
+GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
 {
 	std::vector<EGLint> attrib_list;
 
@@ -376,7 +395,7 @@
 		goto error;
 
 	// common error is to assume that ChooseConfig worked because it returned EGL_TRUE
-	if (num_config != 1)
+	if (num_config != 1) // num_config should be exactly 1
 		goto error;
 
 	m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
@@ -398,7 +417,7 @@
 	if (!EGL_CHK(m_context != EGL_NO_CONTEXT))
 		goto error;
 
-	if (!EGL_CHK(m_sharedContext != EGL_NO_CONTEXT))
+	if (m_sharedContext == EGL_NO_CONTEXT)
 		m_sharedContext = m_context;
 
 	m_sharedCount++;
@@ -409,11 +428,6 @@
 	return GHOST_kSuccess;
 
 error:
-	removeDrawingContext();
-
-	EGL_CHK(eglTerminate(m_display));
-	m_display = EGL_NO_DISPLAY;
-
 	EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
 
 	return GHOST_kFailure;
@@ -421,35 +435,6 @@
 
 
 
-GHOST_TSuccess GHOST_ContextEGL::removeDrawingContext()
-{
-	bindAPI(m_api);
-
-	if (m_context != EGL_NO_CONTEXT) {
-		if (m_context == ::eglGetCurrentContext())
-			EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
-
-		if (m_context != m_sharedContext || m_sharedCount == 1) {
-			assert(m_sharedCount > 0);
-
-			m_sharedCount--;
-
-			if (m_sharedCount == 0)
-				m_sharedContext = EGL_NO_CONTEXT;
-
-			if (EGL_CHK(::eglDestroyContext(m_display, m_context)))
-				m_context = EGL_NO_CONTEXT;
-		}
-	}
-
-	if (m_surface != EGL_NO_SURFACE && EGL_CHK(::eglDestroySurface(m_display, m_surface)))
-		m_surface = EGL_NO_SURFACE;
-
-	return m_surface == EGL_NO_SURFACE && m_context == EGL_NO_CONTEXT ? GHOST_kSuccess : GHOST_kFailure;
-}
-
-
-
 GHOST_TSuccess GHOST_ContextEGL::releaseNativeHandles()
 {
 	m_nativeWindow  = NULL;

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.h
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.h	2013-07-27 16:28:43 UTC (rev 58668)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextEGL.h	2013-07-27 16:38:52 UTC (rev 58669)
@@ -75,16 +75,9 @@
 	 * \param numOfAASamples	Number of samples used for AA (zero if no AA)
 	 * \return Indication as to whether installation has succeeded.
 	 */
-	virtual GHOST_TSuccess installDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
+	virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
 
 	/**
-	 * Removes the current drawing context.
-	 * \return Indication as to whether removal has succeeded.
-	 */
-	virtual GHOST_TSuccess removeDrawingContext();
-
-
-	/**
 	 * Removes references to native handles from this context and then returns
 	 * GHOST_kSuccess if it is OK for the parent to release the handles
 	 * and GHOST_kFailure if releasing the handles will interfere with sharing

Modified: branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp
===================================================================
--- branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp	2013-07-27 16:28:43 UTC (rev 58668)
+++ branches/soc-2013-viewport_fx/intern/ghost/intern/GHOST_ContextWGL.cpp	2013-07-27 16:38:52 UTC (rev 58669)
@@ -85,7 +85,14 @@
 		const char* formattedMsg = count > 0 ? message : "<FormatMessage Failed>";
 
 #ifndef NDEBUG
-		_ftprintf(stderr, "%s(%d):%s -> Windows Error (%04X): %s\n", file, line, text, error, formattedMsg);
+		_ftprintf(
+			stderr,
+			"%s(%d):[%s] -> Win32 Error (%04X): %s\n",
+			file, 
+			line,
+			text,
+			error,
+			formattedMsg);
 #else
 		_ftprintf(stderr, "Windows Error (%4X): %s\n", error, formattedMsg);
 #endif
@@ -143,8 +150,7 @@
 				s_sharedHDC   = NULL;
 			}
 
-			if (WIN32_CHK(::wglDeleteContext(m_hGLRC)))
-				m_hGLRC = NULL;
+			WIN32_CHK(::wglDeleteContext(m_hGLRC));
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list