Add flush before drawing lines workaround for Adreno 3xx

Bug: skia:6309
Change-Id: I354c678ca4e833c523a89b3196804fbe1adcf9d1
Reviewed-on: https://skia-review.googlesource.com/19087
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 8467909..867fef3 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -57,6 +57,7 @@
     fClearTextureSupport = false;
     fDrawArraysBaseVertexIsBroken = false;
     fUseDrawToClearStencilClip = false;
+    fRequiresFlushToDrawLinesAfterNonLines = false;
 
     fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag;
 
@@ -530,6 +531,21 @@
         }
     }
 
+    // This was reproduced on the following configurations:
+    // - A Galaxy J5 (Adreno 306) running Android 6 with driver 140.0
+    // - A Nexus 7 2013 (Adreno 320) running Android 5 with driver 104.0
+    // - A Nexus 7 2013 (Adreno 320) running Android 6 with driver 127.0
+    // and not produced on:
+    // - A Nexus 7 2013 (Adreno 320) running Android 4 with driver 53.0
+    // - A Nexus 5 (Adreno 330) running Android 6 with driver 127.0
+    // The Nexus 5 and Nexus 7 with driver 127.0 had different git hashes in the GL_VERSION string
+    // so it seems that either the N5's branch didn't have the bug or the bug affects Adreno 320
+    // and 306 but not a 330. Further dissection is left to a future unfortunate soul if necessary.
+    if (kAdreno3xx_GrGLRenderer == ctxInfo.renderer() && kQualcomm_GrGLDriver == ctxInfo.driver() &&
+        ctxInfo.driverVersion() > GR_GL_DRIVER_VER(53, 0)) {
+        fRequiresFlushToDrawLinesAfterNonLines = true;
+    }
+
     // Texture uploads sometimes seem to be ignored to textures bound to FBOS on Tegra3.
     if (kTegra3_GrGLRenderer == ctxInfo.renderer()) {
         fUseDrawInsteadOfPartialRenderTargetWrite = true;