inline size_t indent() { // For OSX we need avoid REGAL_GET_CONTEXT implicitly // trying to create a RegalContext and triggering more // (recursive) logging. #if !REGAL_SYS_WGL && !REGAL_NO_TLS if (!Thread::currentContextKey || !pthread_getspecific(Thread::currentContextKey)) return 0; #endif RegalContext *rCtx = REGAL_GET_CONTEXT(); // Clamp indentation to avoid underflow situation (more pops than pushes) // If size_t depthBeginEnd wraps around to a huge number, we probably won't have // enough RAM for all those spaces... const size_t indentMax = size_t(128); size_t indent = 0; if (rCtx) { indent += std::min(indentMax,rCtx->depthBeginEnd *2); indent += std::min(indentMax,rCtx->depthPushMatrix*2); indent += std::min(indentMax,rCtx->depthPushAttrib*2); indent += std::min(indentMax,rCtx->depthNewList *2); indent += std::min(indentMax,rCtx->marker ? rCtx->marker->indent() : 0); } return indent; }
REGAL_GLOBAL_BEGIN #include "RegalConfig.h" #include "RegalThread.h" #include "RegalContext.h" #include "RegalDispatcher.h" #include "RegalCacheShader.h" REGAL_GLOBAL_END REGAL_NAMESPACE_BEGIN static void REGAL_CALL cache_glShaderSource(GLuint shader, GLsizei count, const GLchar * const * string, const GLint *length) { RegalContext *_context = REGAL_GET_CONTEXT(); RegalAssert(_context); DispatchTableGL *_next = _context->dispatcher.cache.next(); RegalAssert(_next); if (Config::cache && Config::cacheShader) Cache::shaderSource(_next->call(&_next->glShaderSource), shader, count, string, length); else _next->call(&_next->glShaderSource)(shader, count, string, length); }
void Output(const Mode mode, const char *file, const int line, const char *prefix, const char *delim, const char *name, const string &str) { if (initialized && str.length()) { string m = message(prefix,delim,name,str); // TODO - optional Regal source line numbers. #if 1 UNUSED_PARAMETER(file); UNUSED_PARAMETER(line); #else m = print_string(file,":",line," ",m); #endif #if REGAL_LOG_ONCE if (once) switch (mode) { case LOG_WARNING: { Thread::ScopedLock lock(uniqueMutex); if (uniqueWarnings.find(m)!=uniqueWarnings.end()) return; uniqueWarnings.insert(m); break; } case LOG_ERROR: { Thread::ScopedLock lock(uniqueMutex); if (uniqueErrors.find(m)!=uniqueErrors.end()) return; uniqueErrors.insert(m); break; } default: break; } #endif RegalContext *rCtx = NULL; #if !REGAL_SYS_WGL && !REGAL_NO_TLS if (Thread::currentContextKey && pthread_getspecific(Thread::currentContextKey)) rCtx = REGAL_GET_CONTEXT(); #else rCtx = REGAL_GET_CONTEXT(); #endif #if REGAL_LOG_CALLBACK if (callback && rCtx && rCtx->logCallback) rCtx->logCallback(GL_LOG_INFO_REGAL, (GLsizei) m.length(), m.c_str(), reinterpret_cast<void *>(rCtx->sysCtx)); #endif #if REGAL_SYS_WGL OutputDebugStringA(m.c_str()); #elif REGAL_SYS_ANDROID // ANDROID_LOG_INFO // ANDROID_LOG_WARN // ANDROID_LOG_ERROR __android_log_write(ANDROID_LOG_INFO, REGAL_LOG_TAG, m.c_str()); #endif #if REGAL_LOG_JSON && !REGAL_NO_JSON if (json && jsonOutput) { string m = jsonObject(prefix,name,str) + ",\n"; fwrite(m.c_str(),m.length(),1,jsonOutput); } #endif #if REGAL_LOG if (log && logOutput) { #if REGAL_SYS_ANDROID #else fprintf(logOutput, "%s", m.c_str()); fflush(logOutput); #endif } #endif append(m); } }