summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Antoine LaFayette <plafayet@codeaurora.org>2012-03-07 23:30:41 (GMT)
committerPierre-Antoine LaFayette <plafayet@codeaurora.org>2012-05-14 22:03:02 (GMT)
commit307d4a2b5b20f2609497ceaea1eca2e29a8a781f (patch)
treeee9bea7f2431e9a285c0f1f06e28c905bebd22ee
parent1cd2fe8616f76659cf630f6dd62279fbf4e1fc00 (diff)
Runtime enablement of WebGL logs
Allows enabling WebGL method level logging using: adb shell setprop debug.webgl 1 Change-Id: Ia4c6467fdf732b15497608e2135926f301c34b6f
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.h18
2 files changed, 20 insertions, 10 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
index 373d0fe2..6cb0132 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.cpp
@@ -99,6 +99,8 @@ private:
#define CANVAS_MAX_WIDTH 1280
#define CANVAS_MAX_HEIGHT 1280
+bool GraphicsContext3DInternal::s_loggingEnabled = false;
+
EGLint GraphicsContext3DInternal::checkEGLError(const char* s)
{
EGLint error = eglGetError();
@@ -149,6 +151,8 @@ GraphicsContext3DInternal::GraphicsContext3DInternal(HTMLCanvasElement* canvas,
, m_extensions(0)
, m_contextId(0)
{
+ enableLogging();
+
LOGWEBGL("GraphicsContext3DInternal() = %p, m_compositingLayer = %p", this, m_compositingLayer);
m_compositingLayer->ref();
m_proxy->setGraphicsContext(this);
@@ -1021,5 +1025,13 @@ void GraphicsContext3DInternal::viewport(long x, long y, unsigned long width, un
m_savedViewport.width = width;
m_savedViewport.height = height;
}
+
+void GraphicsContext3DInternal::enableLogging()
+{
+ char value[PROPERTY_VALUE_MAX];
+ property_get("debug.webgl", value, "0");
+ s_loggingEnabled = atoi(value) ? true : false;
+}
+
}
#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.h b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.h
index 98fca6c..67319b2 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsContext3DInternal.h
@@ -48,19 +48,15 @@
#include <ui/android_native_buffer.h>
#include <ui/GraphicBuffer.h>
-#include <utils/Log.h>
-
-#undef WEBGL_LOGGING
-//#define WEBGL_LOGGING 1
-#ifdef WEBGL_LOGGING
-#define LOGWEBGL(...) ((void)android_printLog(ANDROID_LOG_DEBUG, "WebGL", __VA_ARGS__))
-#else
-#define LOGWEBGL(...)
-#endif
-
// This can be increased to 3, for example, if that has a positive impact on performance.
#define NUM_BUFFERS 2
+#include <cutils/properties.h>
+#include <cutils/log.h>
+
+#define LOGWEBGL(...) (GraphicsContext3DInternal::s_loggingEnabled ? \
+ (void)android_printLog(ANDROID_LOG_DEBUG, "WebGL", __VA_ARGS__) : (void)0)
+
using namespace android;
namespace WebCore {
@@ -144,6 +140,8 @@ public:
static EGLint checkEGLError(const char* s);
static GLint checkGLError(const char* s);
+ static void enableLogging();
+ static bool s_loggingEnabled;
private:
bool initEGL();