Implement NV_path_rendering on OpenGL ES

Implement support for NV_path_rendering on OpenGL ES. Use
glProgramPathFragmentInputGenNV function call instead of glPathTexGenNV to
communicate transforms to fragment shader.

The intention is that the NVPR paths will be drawn with the same shader program
as non-NVPR geometry. For NVPR calls, the GPU will skip the vertex shader and
just run the fragment shader.

After program is linked, query the locations of the fragment shader inputs with
glGetResourceLocation. The location will be used to set the transforms with
glProgramPathFragmentInputGenNV.

The functions and their workings are documented in:

glProgramPathFragmentInputGenNV
https://www.opengl.org/registry/specs/NV/path_rendering.txt
(note: addition as of API version 1.3)

glGetResourceLocation
https://www.opengl.org/registry/specs/ARB/program_interface_query.txt
http://www.opengl.org/registry/doc/glspec44.core.pdf
(function is in core Open GL 4.4)

Note: glProgramPathFragmentInputGenNV could be used also for OpenGL. However,
using seems to trigger a bug in the driver. Disable this feature on OpenGL at
least until the driver is fixed and released. The bug manifests in shadertext
test, where the lower-left text pair is missing. Valgrind catches a bad read
for the test and causes the context to OOM reproducibly.

R=bsalomon@google.com, cdalton@nvidia.com, joshualitt@google.com, joshualitt@chromium.org

Author: kkinnunen@nvidia.com

Review URL: https://codereview.chromium.org/367643004
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 7cdbcd0..286924e 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -21,7 +21,7 @@
                                                  uint16_t* effectKeySize,
                                                  bool* setTrueIfReadsDst,
                                                  bool* setTrueIfReadsPos,
-                                                 bool* setTrueIfHasVertexCode) {
+                                                 bool* setTrueIfRequiresVertexShader) {
     const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
     GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
     if (stage.getEffect()->willReadDstColor()) {
@@ -30,8 +30,8 @@
     if (stage.getEffect()->willReadFragmentPosition()) {
         *setTrueIfReadsPos = true;
     }
-    if (stage.getEffect()->hasVertexCode()) {
-        *setTrueIfHasVertexCode = true;
+    if (stage.getEffect()->requiresVertexShader()) {
+        *setTrueIfRequiresVertexShader = true;
     }
     factory.getGLEffectKey(drawEffect, caps, b);
     size_t size = b->size();
@@ -102,9 +102,10 @@
 
     bool readsDst = false;
     bool readFragPosition = false;
-    // We use vertexshader-less shader programs only when drawing paths.
-    bool hasVertexCode = !(GrGpu::kDrawPath_DrawType == drawType ||
-                           GrGpu::kDrawPaths_DrawType == drawType);
+
+    // Provide option for shader programs without vertex shader only when drawing paths.
+    bool requiresVertexShader = !GrGpu::IsPathRenderingDrawType(drawType);
+
     int numStages = 0;
     if (!skipColor) {
         numStages += drawState.numColorStages() - firstEffectiveColorStage;
@@ -118,7 +119,6 @@
     desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
 
     int offsetAndSizeIndex = 0;
-
     bool effectKeySuccess = true;
     if (!skipColor) {
         for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) {
@@ -133,7 +133,7 @@
                                     drawState.getColorStage(s), gpu->glCaps(),
                                     requiresLocalCoordAttrib, &b,
                                     &effectKeySize, &readsDst,
-                                    &readFragPosition, &hasVertexCode);
+                                    &readFragPosition, &requiresVertexShader);
             effectKeySuccess |= (effectOffset <= SK_MaxU16);
 
             offsetAndSize[0] = SkToU16(effectOffset);
@@ -154,7 +154,7 @@
                                     drawState.getCoverageStage(s), gpu->glCaps(),
                                     requiresLocalCoordAttrib, &b,
                                     &effectKeySize, &readsDst,
-                                    &readFragPosition, &hasVertexCode);
+                                    &readFragPosition, &requiresVertexShader);
             effectKeySuccess |= (effectOffset <= SK_MaxU16);
 
             offsetAndSize[0] = SkToU16(effectOffset);
@@ -174,7 +174,7 @@
     // Because header is a pointer into the dynamic array, we can't push any new data into the key
     // below here.
 
-    header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib;
+    header->fRequiresVertexShader = requiresVertexShader || requiresLocalCoordAttrib;
     header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
 
     // Currently the experimental GS will only work with triangle prims (and it doesn't do anything
@@ -192,7 +192,7 @@
         header->fColorInput = kUniform_ColorInput;
     } else {
         header->fColorInput = kAttribute_ColorInput;
-        header->fHasVertexCode = true;
+        header->fRequiresVertexShader = true;
     }
 
     bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == drawState.getCoverageColor();
@@ -203,7 +203,7 @@
         header->fCoverageInput = kUniform_ColorInput;
     } else {
         header->fCoverageInput = kAttribute_ColorInput;
-        header->fHasVertexCode = true;
+        header->fRequiresVertexShader = true;
     }
 
     if (readsDst) {