summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-04 16:23:16 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-04 21:24:05 +0100
commit29c5c13aa2860a0e8c1ac9a826b08330708d3f29 (patch)
treebac1808d9b184e87daa9b82586c7ce0bf75b025d
parentc90a55959980f9ef9678a45b9c9ded906d637b34 (diff)
downloadqtlocation-mapboxgl-29c5c13aa2860a0e8c1ac9a826b08330708d3f29.tar.gz
[core] move OpenGL debug information printing to core
-rwxr-xr-xplatform/android/src/native_map_view.cpp28
-rw-r--r--src/mbgl/gl/extension.cpp43
2 files changed, 31 insertions, 40 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 0026aaa708..a472525065 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -14,7 +14,6 @@
#include <mbgl/platform/event.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/gl/extension.hpp>
-#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/image.hpp>
@@ -38,23 +37,6 @@ void log_egl_string(EGLDisplay display, EGLint name, const char *label) {
}
}
-void log_gl_string(GLenum name, const char *label) {
- const GLubyte *str = glGetString(name);
- if (str == nullptr) {
- mbgl::Log::Error(mbgl::Event::OpenGL, "glGetString(%d) returned error %d", name,
- glGetError());
- throw std::runtime_error("glGetString() failed");
- } else {
- char buf[513];
- for (int len = std::strlen(reinterpret_cast<const char *>(str)), pos = 0; len > 0;
- len -= 512, pos += 512) {
- strncpy(buf, reinterpret_cast<const char *>(str) + pos, 512);
- buf[512] = 0;
- mbgl::Log::Info(mbgl::Event::OpenGL, "GL %s: %s", label, buf);
- }
- }
-}
-
NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio, int availableProcessors_, size_t totalMemory_)
: env(env_),
availableProcessors(availableProcessors_),
@@ -421,16 +403,6 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
throw std::runtime_error("eglMakeCurrent() failed");
}
- log_gl_string(GL_VENDOR, "Vendor");
- log_gl_string(GL_RENDERER, "Renderer");
- log_gl_string(GL_VERSION, "Version");
- if (!inEmulator()) {
- log_gl_string(GL_SHADING_LANGUAGE_VERSION,
- "SL Version"); // In the emulator this returns NULL with error code 0?
- // https://code.google.com/p/android/issues/detail?id=78977
- }
-
- log_gl_string(GL_EXTENSIONS, "Extensions");
mbgl::gl::InitializeExtensions([] (const char * name) {
return reinterpret_cast<mbgl::gl::glProc>(eglGetProcAddress(name));
});
diff --git a/src/mbgl/gl/extension.cpp b/src/mbgl/gl/extension.cpp
index ee94e8ecfd..40a2096f4f 100644
--- a/src/mbgl/gl/extension.cpp
+++ b/src/mbgl/gl/extension.cpp
@@ -1,9 +1,11 @@
#include <mbgl/gl/extension.hpp>
#include <mbgl/gl/gl.hpp>
+#include <mbgl/platform/log.hpp>
#include <mutex>
#include <string>
#include <vector>
+#include <cstring>
namespace mbgl {
namespace gl {
@@ -24,20 +26,37 @@ ExtensionFunctionBase::ExtensionFunctionBase(std::initializer_list<Probe> probes
static std::once_flag initializeExtensionsOnce;
+const char* getGLString(GLenum name) {
+ return reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(name)));
+}
+
void InitializeExtensions(glProc (*getProcAddress)(const char*)) {
std::call_once(initializeExtensionsOnce, [getProcAddress] {
- const char* extensionsPtr =
- reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)));
-
- if (!extensionsPtr)
- return;
-
- const std::string extensions = extensionsPtr;
- for (auto fn : detail::extensionFunctions()) {
- for (auto probe : fn.second) {
- if (extensions.find(probe.first) != std::string::npos) {
- *fn.first = getProcAddress(probe.second);
- break;
+#ifndef NDEBUG
+ if (const char* vendor = getGLString(GL_VENDOR)) {
+ mbgl::Log::Info(mbgl::Event::OpenGL, "Vendor: %s", vendor);
+ }
+ if (const char* renderer = getGLString(GL_RENDERER)) {
+ mbgl::Log::Info(mbgl::Event::OpenGL, "Renderer: %s", renderer);
+ }
+ if (const char* version = getGLString(GL_VERSION)) {
+ mbgl::Log::Info(mbgl::Event::OpenGL, "Version: %s", version);
+ }
+ if (const char* shaderVersion = getGLString(GL_SHADING_LANGUAGE_VERSION)) {
+ mbgl::Log::Info(mbgl::Event::OpenGL, "Shading Language Version: %s", shaderVersion);
+ }
+#endif
+
+ if (const char* extensions = getGLString(GL_EXTENSIONS)) {
+#ifndef NDEBUG
+ mbgl::Log::Info(mbgl::Event::OpenGL, "Extensions: %s", extensions);
+#endif
+ for (auto fn : detail::extensionFunctions()) {
+ for (auto probe : fn.second) {
+ if (strstr(extensions, probe.first) != nullptr) {
+ *fn.first = getProcAddress(probe.second);
+ break;
+ }
}
}
}