Changed feature macros to reduce accidental enabling/disabling

Change-Id: Ieb1a0c55f412f2a1bb858522b2dfaa7a60aa7ddb
Reviewed-on: https://chromium-review.googlesource.com/226304
Reviewed-by: Brandon Jones <bajones@chromium.org>
Tested-by: Brandon Jones <bajones@chromium.org>
diff --git a/projects/src/libANGLE.vcxproj b/projects/src/libANGLE.vcxproj
index 0d6554c..b198df1 100644
--- a/projects/src/libANGLE.vcxproj
+++ b/projects/src/libANGLE.vcxproj
@@ -249,6 +249,7 @@
     <ClInclude Include="..\..\src\common\blocklayout.h"/>
     <ClInclude Include="..\..\src\common\debug.h"/>
     <ClInclude Include="..\..\src\common\event_tracer.h"/>
+    <ClInclude Include="..\..\src\common\features.h"/>
     <ClInclude Include="..\..\src\common\mathutil.h"/>
     <ClInclude Include="..\..\src\common\platform.h"/>
     <ClInclude Include="..\..\src\common\NativeWindow.h"/>
diff --git a/projects/src/libANGLE.vcxproj.filters b/projects/src/libANGLE.vcxproj.filters
index c424ec9..8c68ad8 100644
--- a/projects/src/libANGLE.vcxproj.filters
+++ b/projects/src/libANGLE.vcxproj.filters
@@ -193,6 +193,12 @@
     <Filter Include="src">
       <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
     </Filter>
+    <Filter Include="src\common">
+      <UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="src">
+      <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
+    </Filter>
     <Filter Include="src\libGLESv2">
       <UniqueIdentifier>{A62A9415-2E9D-A6D2-631D-1F25A5CD626F}</UniqueIdentifier>
     </Filter>
@@ -3564,6 +3570,9 @@
     <ClInclude Include="..\..\src\common\event_tracer.h">
       <Filter>src\common</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\common\features.h">
+      <Filter>src\common</Filter>
+    </ClInclude>
     <ClCompile Include="..\..\src\common\mathutil.cpp">
       <Filter>src\common</Filter>
     </ClCompile>
diff --git a/projects/winrt/windows/src/libANGLE.vcxproj b/projects/winrt/windows/src/libANGLE.vcxproj
index 38f772e..a79ad31 100644
--- a/projects/winrt/windows/src/libANGLE.vcxproj
+++ b/projects/winrt/windows/src/libANGLE.vcxproj
@@ -362,6 +362,7 @@
     <ClInclude Include="..\..\..\..\src\common\blocklayout.h"/>
     <ClInclude Include="..\..\..\..\src\common\debug.h"/>
     <ClInclude Include="..\..\..\..\src\common\event_tracer.h"/>
+    <ClInclude Include="..\..\..\..\src\common\features.h"/>
     <ClInclude Include="..\..\..\..\src\common\mathutil.h"/>
     <ClInclude Include="..\..\..\..\src\common\platform.h"/>
     <ClInclude Include="..\..\..\..\src\common\NativeWindow.h"/>
diff --git a/projects/winrt/windows/src/libANGLE.vcxproj.filters b/projects/winrt/windows/src/libANGLE.vcxproj.filters
index 4c05873..2a52d90 100644
--- a/projects/winrt/windows/src/libANGLE.vcxproj.filters
+++ b/projects/winrt/windows/src/libANGLE.vcxproj.filters
@@ -193,6 +193,12 @@
     <Filter Include="src">
       <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
     </Filter>
+    <Filter Include="src\common">
+      <UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="src">
+      <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
+    </Filter>
     <Filter Include="src\libGLESv2">
       <UniqueIdentifier>{A62A9415-2E9D-A6D2-631D-1F25A5CD626F}</UniqueIdentifier>
     </Filter>
@@ -3021,6 +3027,9 @@
     <ClInclude Include="..\..\..\..\src\common\event_tracer.h">
       <Filter>src\common</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\..\src\common\features.h">
+      <Filter>src\common</Filter>
+    </ClInclude>
     <ClCompile Include="..\..\..\..\src\common\mathutil.cpp">
       <Filter>src\common</Filter>
     </ClCompile>
diff --git a/src/common/features.h b/src/common/features.h
new file mode 100644
index 0000000..b49a0ee
--- /dev/null
+++ b/src/common/features.h
@@ -0,0 +1,35 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#define ANGLE_DISABLED 0
+#define ANGLE_ENABLED 1
+
+// Feature defaults
+
+// Direct3D9EX
+// The "Debug This Pixel..." feature in PIX often fails when using the
+// D3D9Ex interfaces.  In order to get debug pixel to work on a Vista/Win 7
+// machine, define "ANGLE_D3D9EX=0" in your project file.
+#if !defined(ANGLE_D3D9EX)
+#define ANGLE_D3D9EX ANGLE_ENABLED
+#endif
+
+// Vsync
+// ENABLED allows Vsync to be configured at runtime
+// DISABLED disallows Vsync
+#if !defined(ANGLE_VSYNC)
+#define ANGLE_VSYNC ANGLE_ENABLED
+#endif
+
+// Program binary loading
+#if !defined(ANGLE_PROGRAM_BINARY_LOAD)
+#define ANGLE_PROGRAM_BINARY_LOAD ANGLE_ENABLED
+#endif
+
+// Shader debug info
+#if !defined(ANGLE_SHADER_DEBUG_INFO)
+#define ANGLE_SHADER_DEBUG_INFO ANGLE_DISABLED
+#endif
diff --git a/src/libGLESv2.gypi b/src/libGLESv2.gypi
index 8f21ae4..b65c622 100644
--- a/src/libGLESv2.gypi
+++ b/src/libGLESv2.gypi
@@ -31,6 +31,7 @@
             'common/debug.h',
             'common/event_tracer.cpp',
             'common/event_tracer.h',
+            'common/features.h',
             'common/mathutil.cpp',
             'common/mathutil.h',
             'common/platform.h',
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index 900423f..40f1e8c 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -27,6 +27,7 @@
 #include "libGLESv2/Context.h"
 #include "libGLESv2/Buffer.h"
 #include "common/blocklayout.h"
+#include "common/features.h"
 
 namespace gl
 {
@@ -362,7 +363,7 @@
 
 LinkResult ProgramBinary::load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length)
 {
-#ifdef ANGLE_DISABLE_PROGRAM_BINARY_LOAD
+#if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_ENABLED
     return LinkResult(false, Error(GL_NO_ERROR));
 #else
     ASSERT(binaryFormat == mProgram->getBinaryFormat());
@@ -419,7 +420,7 @@
     }
 
     return LinkResult(true, Error(GL_NO_ERROR));
-#endif // #ifdef ANGLE_DISABLE_PROGRAM_BINARY_LOAD
+#endif // #if ANGLE_PROGRAM_BINARY_LOAD == ANGLE_ENABLED
 }
 
 Error ProgramBinary::save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length)
diff --git a/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp b/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp
index 59a6a2f..5c44fe0 100644
--- a/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp
+++ b/src/libGLESv2/renderer/d3d/HLSLCompiler.cpp
@@ -8,6 +8,7 @@
 #include "libGLESv2/Program.h"
 #include "libGLESv2/main.h"
 
+#include "common/features.h"
 #include "common/utilities.h"
 
 #include "third_party/trace_event/trace_event.h"
@@ -225,7 +226,7 @@
         {
             *outCompiledBlob = binary;
 
-#ifdef ANGLE_GENERATE_SHADER_DEBUG_INFO
+#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
             (*outDebugInfo) += "// COMPILER INPUT HLSL BEGIN\n\n" + hlsl + "\n// COMPILER INPUT HLSL END\n";
             (*outDebugInfo) += "\n\n// ASSEMBLY BEGIN\n\n";
             (*outDebugInfo) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n";
diff --git a/src/libGLESv2/renderer/d3d/ProgramD3D.cpp b/src/libGLESv2/renderer/d3d/ProgramD3D.cpp
index cf8566d..6681d75 100644
--- a/src/libGLESv2/renderer/d3d/ProgramD3D.cpp
+++ b/src/libGLESv2/renderer/d3d/ProgramD3D.cpp
@@ -8,6 +8,7 @@
 
 #include "libGLESv2/renderer/d3d/ProgramD3D.h"
 
+#include "common/features.h"
 #include "common/utilities.h"
 #include "libGLESv2/Framebuffer.h"
 #include "libGLESv2/FramebufferAttachment.h"
@@ -954,7 +955,7 @@
         }
     }
 
-#ifdef ANGLE_GENERATE_SHADER_DEBUG_INFO
+#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
     if (usesGeometryShader() && mGeometryExecutable)
     {
         // Geometry shaders are currently only used internally, so there is no corresponding shader object at the interface level
diff --git a/src/libGLESv2/renderer/d3d/ShaderD3D.cpp b/src/libGLESv2/renderer/d3d/ShaderD3D.cpp
index de35624..d08a81d 100644
--- a/src/libGLESv2/renderer/d3d/ShaderD3D.cpp
+++ b/src/libGLESv2/renderer/d3d/ShaderD3D.cpp
@@ -11,6 +11,7 @@
 #include "libGLESv2/Shader.h"
 #include "libGLESv2/main.h"
 
+#include "common/features.h"
 #include "common/utilities.h"
 
 // Definitions local to the translation unit
@@ -451,7 +452,7 @@
         }
     }
 
-#ifdef ANGLE_GENERATE_SHADER_DEBUG_INFO
+#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
     mDebugInfo += std::string("// ") + GetShaderTypeString(mType) + " SHADER BEGIN\n";
     mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n";
     mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + getTranslatedSource() + "\n// INITIAL HLSL END\n\n\n";
diff --git a/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp b/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
index 6865e06..13fc82e 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d11/SwapChain11.cpp
@@ -15,6 +15,7 @@
 #include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h"
 #include "libGLESv2/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h"
 
+#include "common/features.h"
 #include "common/NativeWindow.h"
 
 namespace rx
@@ -578,7 +579,7 @@
     // Draw
     deviceContext->Draw(4, 0);
 
-#ifdef ANGLE_FORCE_VSYNC_OFF
+#if ANGLE_VSYNC == ANGLE_DISABLED
     result = mSwapChain->Present(0, 0);
 #else
     result = mSwapChain->Present(mSwapInterval, 0);
diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
index 4ce8b88..a5607d0 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
@@ -39,6 +39,7 @@
 
 #include "libEGL/Display.h"
 
+#include "common/features.h"
 #include "common/utilities.h"
 
 #include "third_party/trace_event/trace_event.h"
@@ -48,14 +49,6 @@
 // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
 #define REF_RAST 0
 
-// The "Debug This Pixel..." feature in PIX often fails when using the
-// D3D9Ex interfaces.  In order to get debug pixel to work on a Vista/Win 7
-// machine, define "ANGLE_ENABLE_D3D9EX=0" in your project file.
-#if !defined(ANGLE_ENABLE_D3D9EX)
-// Enables use of the IDirect3D9Ex interface, when available
-#define ANGLE_ENABLE_D3D9EX 1
-#endif // !defined(ANGLE_ENABLE_D3D9EX)
-
 #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
 #define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
 #endif
@@ -207,7 +200,7 @@
     // Use Direct3D9Ex if available. Among other things, this version is less
     // inclined to report a lost context, for example when the user switches
     // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available.
-    if (ANGLE_ENABLE_D3D9EX && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
+    if (ANGLE_D3D9EX == ANGLE_ENABLED && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
     {
         TRACE_EVENT0("gpu", "D3d9Ex_QueryInterface");
         ASSERT(mD3d9Ex);
@@ -2288,7 +2281,7 @@
 {
     bool success = false;
 
-#ifdef ANGLE_ENABLE_D3D9EX
+#if ANGLE_D3D9EX == ANGLE_ENABLED
     IDirect3D9Ex *d3d9Ex = NULL;
     typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
     Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
diff --git a/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp b/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp
index cd8764c..8fdffe9 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/SwapChain9.cpp
@@ -11,6 +11,8 @@
 #include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
 #include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
 
+#include "common/features.h"
+
 namespace rx
 {
 
@@ -50,7 +52,7 @@
 
 static DWORD convertInterval(EGLint interval)
 {
-#ifdef ANGLE_FORCE_VSYNC_OFF
+#if ANGLE_VSYNC == ANGLE_DISABLED
     return D3DPRESENT_INTERVAL_IMMEDIATE;
 #else
     switch(interval)