Enable NVPR with command buffer

Set Chromium command-line flag --enable-gl-path-rendering
before creating command buffer context. This is needed for
the command buffer to expose NVPR at the moment.

BUG=skia:2992
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1538863002

Review URL: https://codereview.chromium.org/1538863002
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index 35f5284..d685b2a 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -49,6 +49,8 @@
 
         '../src/ports/SkGlobalInitialization_default.cpp',
         '../src/ports/SkMemory_malloc.cpp',
+        '../src/ports/SkOSEnvironment.h',
+        '../src/ports/SkOSEnvironment.cpp',
         '../src/ports/SkOSFile_posix.cpp',
         '../src/ports/SkOSFile_stdio.cpp',
         '../src/ports/SkOSFile_win.cpp',
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
index 61eab4b..cf9da93 100644
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
+++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
@@ -9,6 +9,7 @@
 #include "gl/GrGLInterface.h"
 #include "gl/GrGLAssembleInterface.h"
 #include "gl/command_buffer/SkCommandBufferGLContext.h"
+#include "../ports/SkOSEnvironment.h"
 #include "../ports/SkOSLibrary.h"
 
 #if defined SK_BUILD_FOR_MAC
@@ -189,6 +190,8 @@
         return;
     }
 
+    // Make sure CHROMIUM_path_rendering is enabled for NVPR support.
+    sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering");
     fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY);
     if (EGL_NO_DISPLAY == fDisplay) {
         SkDebugf("Command Buffer: Could not create EGL display.\n");
diff --git a/src/ports/SkOSEnvironment.cpp b/src/ports/SkOSEnvironment.cpp
new file mode 100644
index 0000000..cc7aa18
--- /dev/null
+++ b/src/ports/SkOSEnvironment.cpp
@@ -0,0 +1,19 @@
+
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkOSEnvironment.h"
+#include <stdlib.h>
+
+void sk_setenv(const char* key, const char* value) {
+#ifdef SK_BUILD_FOR_WIN32
+    _putenv_s(key, value);
+#else
+    setenv(key, value, 1);
+#endif
+}
+
diff --git a/src/ports/SkOSEnvironment.h b/src/ports/SkOSEnvironment.h
new file mode 100644
index 0000000..fdbce7a
--- /dev/null
+++ b/src/ports/SkOSEnvironment.h
@@ -0,0 +1,15 @@
+
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkOSEnvironment_DEFINED
+#define SkOSEnvironment_DEFINED
+
+void sk_setenv(const char* key, const char* value);
+
+#endif
+
diff --git a/tests/RTConfRegistryTest.cpp b/tests/RTConfRegistryTest.cpp
index 84ce942..be019f7 100644
--- a/tests/RTConfRegistryTest.cpp
+++ b/tests/RTConfRegistryTest.cpp
@@ -6,28 +6,19 @@
  */
 
 #include "SkRTConf.h"
+#include "SkOSEnvironment.h"
 #include "Test.h"
 
-#include <stdlib.h>
-
 // Friended proxy for SkRTConfRegistry::parse()
 template <typename T>
 bool test_rt_conf_parse(SkRTConfRegistry* reg, const char* key, T* value) {
     return reg->parse(key, value);
 }
 
-static void portable_setenv(const char* key, const char* value) {
-#ifdef SK_BUILD_FOR_WIN32
-    _putenv_s(key, value);
-#else
-    setenv(key, value, 1);
-#endif
-}
-
 DEF_TEST(SkRTConfRegistry, reporter) {
     SkRTConfRegistry reg;
 
-    portable_setenv("skia_nonexistent_item", "132");
+    sk_setenv("skia_nonexistent_item", "132");
     int result = 0;
     test_rt_conf_parse(&reg, "nonexistent.item", &result);
     REPORTER_ASSERT(reporter, result == 132);