Rework tracing and perf defines.
Changed ANGLE_DISABLE_* to ANGLE_ENABLE_* for perf and tracing defines so
they are disabled by default. Updated the gyp files to only turn on perf
by default for windows debug builds.
Change-Id: I71706674e6d12fbf4208acc8f100d963b82c7674
Reviewed-on: https://chromium-review.googlesource.com/183250
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/common/debug.cpp b/src/common/debug.cpp
index 5b0f9c1..523802d 100644
--- a/src/common/debug.cpp
+++ b/src/common/debug.cpp
@@ -9,13 +9,13 @@
#include "common/debug.h"
#include "common/system.h"
-#if defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
#include <d3d9.h>
#endif
namespace gl
{
-#if defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
#else
typedef void (*PerfOutputFunction)(unsigned int, const wchar_t*);
@@ -23,7 +23,7 @@
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
{
-#if !defined(ANGLE_DISABLE_PERF)
+#if defined(ANGLE_ENABLE_PERF)
if (perfActive())
{
char message[32768];
@@ -43,15 +43,15 @@
perfFunc(0, wideMessage);
}
-#endif
+#endif // ANGLE_ENABLE_PERF
-#if !defined(ANGLE_DISABLE_TRACE)
+#if defined(ANGLE_ENABLE_TRACE)
#if defined(NDEBUG)
if (traceFileDebugOnly)
{
return;
}
-#endif
+#endif // NDEBUG
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
if (file)
@@ -59,50 +59,50 @@
vfprintf(file, format, vararg);
fclose(file);
}
-#endif
+#endif // ANGLE_ENABLE_TRACE
}
void trace(bool traceFileDebugOnly, const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
-#if defined(ANGLE_DISABLE_PERF) || !defined(ANGLE_ENABLE_D3D_EVENTS)
- output(traceFileDebugOnly, NULL, format, vararg);
-#else
+#if defined(ANGLE_ENABLE_PERF)
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
+#else
+ output(traceFileDebugOnly, NULL, format, vararg);
#endif
va_end(vararg);
}
bool perfActive()
{
-#if defined(ANGLE_DISABLE_PERF) || !defined(ANGLE_ENABLE_D3D_EVENTS)
- return false;
-#else
+#if defined(ANGLE_ENABLE_PERF)
static bool active = D3DPERF_GetStatus() != 0;
return active;
+#else
+ return false;
#endif
}
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
{
-#if !defined(ANGLE_DISABLE_PERF) && defined(ANGLE_ENABLE_D3D_EVENTS)
-#if defined(ANGLE_DISABLE_TRACE)
+#if defined(ANGLE_ENABLE_PERF)
+#if !defined(ANGLE_ENABLE_TRACE)
if (!perfActive())
{
return;
}
-#endif
+#endif // !ANGLE_ENABLE_TRACE
va_list vararg;
va_start(vararg, format);
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
va_end(vararg);
-#endif
+#endif // ANGLE_ENABLE_PERF
}
ScopedPerfEventHelper::~ScopedPerfEventHelper()
{
-#if !defined(ANGLE_DISABLE_PERF) && defined(ANGLE_ENABLE_D3D_EVENTS)
+#if defined(ANGLE_ENABLE_PERF)
if (perfActive())
{
D3DPERF_EndEvent();