Info logging only shows in debug compilation Added support for UseCurrentContext flag Updated fghPlatformCloseWindowEGL for performance so that eglMakeCurrent isn't invoked unless it's the current window and that the EGL context isn't destroyed unless no other windows uses
This commit is contained in:
parent
b241816870
commit
468e13e958
@ -32,7 +32,11 @@
|
|||||||
#include "egl/fg_window_egl.h"
|
#include "egl/fg_window_egl.h"
|
||||||
|
|
||||||
#include <slog2.h>
|
#include <slog2.h>
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define LOGI(...)
|
||||||
|
#else
|
||||||
#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END))
|
#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END))
|
||||||
|
#endif
|
||||||
#define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
|
#define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
|
||||||
#include <sys/keycodes.h>
|
#include <sys/keycodes.h>
|
||||||
#include <input/screen_helpers.h>
|
#include <input/screen_helpers.h>
|
||||||
@ -165,7 +169,8 @@ fg_time_t fgPlatformSystemTime ( void )
|
|||||||
*/
|
*/
|
||||||
void fgPlatformSleepForEvents( fg_time_t msec )
|
void fgPlatformSleepForEvents( fg_time_t msec )
|
||||||
{
|
{
|
||||||
if(fgStructure.CurrentWindow && fgDisplay.pDisplay.event == NULL && bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
|
if(fgStructure.CurrentWindow && fgDisplay.pDisplay.event == NULL &&
|
||||||
|
bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
|
||||||
LOGW("BPS couldn't get event");
|
LOGW("BPS couldn't get event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,10 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
|
|
||||||
/* Create context */
|
/* Create context */
|
||||||
fghChooseConfig(&window->Window.pContext.egl.Config);
|
fghChooseConfig(&window->Window.pContext.egl.Config);
|
||||||
|
window->Window.Context = EGL_NO_CONTEXT;
|
||||||
|
if( fgState.UseCurrentContext == GL_TRUE )
|
||||||
|
window->Window.Context = eglGetCurrentContext();
|
||||||
|
if( window->Window.Context == EGL_NO_CONTEXT )
|
||||||
window->Window.Context = fghCreateNewContextEGL(window);
|
window->Window.Context = fghCreateNewContextEGL(window);
|
||||||
|
|
||||||
/* Create EGL window */
|
/* Create EGL window */
|
||||||
|
@ -138,9 +138,28 @@ void fghPlatformOpenWindowEGL( SFG_Window* window )
|
|||||||
*/
|
*/
|
||||||
void fghPlatformCloseWindowEGL( SFG_Window* window )
|
void fghPlatformCloseWindowEGL( SFG_Window* window )
|
||||||
{
|
{
|
||||||
|
/* Based on fg_window_mswin fgPlatformCloseWindow */
|
||||||
|
if( fgStructure.CurrentWindow == window )
|
||||||
eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
if (window->Window.Context != EGL_NO_CONTEXT) {
|
if (window->Window.Context != EGL_NO_CONTEXT) {
|
||||||
|
/* Step through the list of windows. If the rendering context is not being used by another window, then delete it */
|
||||||
|
{
|
||||||
|
GLboolean used = GL_FALSE;
|
||||||
|
SFG_Window *iter;
|
||||||
|
|
||||||
|
for( iter = (SFG_Window*)fgStructure.Windows.First;
|
||||||
|
iter && used == GL_FALSE;
|
||||||
|
iter = (SFG_Window*)iter->Node.Next)
|
||||||
|
{
|
||||||
|
if( (iter->Window.Context == window->Window.Context) &&
|
||||||
|
(iter != window) )
|
||||||
|
used = GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !used )
|
||||||
eglDestroyContext(fgDisplay.pDisplay.egl.Display, window->Window.Context);
|
eglDestroyContext(fgDisplay.pDisplay.egl.Display, window->Window.Context);
|
||||||
|
}
|
||||||
window->Window.Context = EGL_NO_CONTEXT;
|
window->Window.Context = EGL_NO_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user