More prep work in Gr for landing AA hairline renderer.

Review URL: http://codereview.appspot.com/4944045



git-svn-id: http://skia.googlecode.com/svn/trunk@2164 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index 7bac3ba..6692023 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -551,7 +551,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler,
-                                          int width, int height) {
+                                          int width, int height) const {
     if (!fGpu->supports8BitPalette()) {
         return false;
     }
@@ -639,7 +639,10 @@
     if (!paint.fAntiAlias) {
         return false;
     }
-    if (isHairLines && target->willUseHWAALines()) {
+    // Line primitves are always rasterized as 1 pixel wide.
+    // Super-sampling would make them too thin but MSAA would be OK.
+    if (isHairLines &&
+        (!PREFER_MSAA_OFFSCREEN_AA || !fGpu->supportsFullsceneAA())) {
         return false;
     }
     if (target->getRenderTarget()->isMultisampled()) {
@@ -693,7 +696,7 @@
         record->fScale = 1;
         desc.fAALevel = kMed_GrAALevel;
     } else {
-        record->fDownsample = (fGpu->supports4x4DownsampleFilter()) ?
+        record->fDownsample = (fGpu->supportsShaders()) ?
                                 OffscreenRecord::k4x4SinglePass_Downsample :
                                 OffscreenRecord::k4x4TwoPass_Downsample;
         record->fScale = OFFSCREEN_SSAA_SCALE;
@@ -1492,6 +1495,10 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
+bool GrContext::supportsShaders() const {
+    return fGpu->supportsShaders();
+}
+
 void GrContext::flush(int flagsBitfield) {
     if (kDiscard_FlushBit & flagsBitfield) {
         fDrawBuffer->reset();
diff --git a/gpu/src/GrGpu.h b/gpu/src/GrGpu.h
index 1e9505b..1c947ec 100644
--- a/gpu/src/GrGpu.h
+++ b/gpu/src/GrGpu.h
@@ -184,6 +184,16 @@
     bool supportsHWAALines() const { return fAALineSupport; }
 
     /**
+     * Are shaders supported.
+     */
+    bool supportsShaders() const { return fShaderSupport; }
+
+    /**
+     * Are derivative instructions supported in fragment shaders
+     */
+    bool supportsShaderDerivatives() const { return fShaderDerivativeSupport; }
+
+    /**
      * Does the subclass support GrSamplerState::k4x4Downsample_Filter
      */
     bool supports4x4DownsampleFilter() const { return f4X4DownsampleFilterSupport; }
@@ -193,8 +203,8 @@
      * blending with partial coverage with certain blend modes (dst coeff is
      * not 1, ISA, or ISC)
      */
-    bool supportsDualSourceBlending() const { 
-        return fDualSourceBlendingSupport; 
+    bool supportsDualSourceBlending() const {
+        return fDualSourceBlendingSupport;
     }
 
     /**
@@ -363,6 +373,8 @@
     bool fTwoSidedStencilSupport;
     bool fStencilWrapOpsSupport;
     bool fAALineSupport;
+    bool fShaderSupport;
+    bool fShaderDerivativeSupport;
     bool fFSAASupport;
     bool f4X4DownsampleFilterSupport; // supports GrSamplerState::k4x4Downsample_Filter
     bool fDualSourceBlendingSupport;
diff --git a/gpu/src/GrGpuGLFixed.cpp b/gpu/src/GrGpuGLFixed.cpp
index 87b051b..69bf94f 100644
--- a/gpu/src/GrGpuGLFixed.cpp
+++ b/gpu/src/GrGpuGLFixed.cpp
@@ -62,7 +62,8 @@
 
 GrGpuGLFixed::GrGpuGLFixed(const GrGLInterface* gl)
     : GrGpuGL(gl, get_binding_in_use(gl)) {
-    f4X4DownsampleFilterSupport = false;
+    fShaderSupport = false;
+    fShaderDerivativeSupport = false;
     fDualSourceBlendingSupport = false;
 }
 
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index 11dc993..05b1e88 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -185,11 +185,11 @@
         pdesc.fFirstCoverageStage = idx;
 
         bool edgeAA = random.nextF() > .5f;
-        if (edgeAA) {
-            pdesc.fEdgeAANumEdges = random.nextF() * this->getMaxEdges() + 1;
-            pdesc.fEdgeAAConcave = random.nextF() > .5f;
-        } else {
-            pdesc.fEdgeAANumEdges = 0;
+        if (edgeAA) {

+            pdesc.fEdgeAANumEdges = random.nextF() * this->getMaxEdges() + 1;

+            pdesc.fEdgeAAConcave = random.nextF() > .5f;

+        } else {

+            pdesc.fEdgeAANumEdges = 0;

         }
 
         if (fDualSourceBlendingSupport) {
@@ -256,13 +256,16 @@
 GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
     : GrGpuGL(gl, get_binding_in_use(gl)) {
 
-    f4X4DownsampleFilterSupport = true;
+    fShaderSupport = true;
     if (kDesktop_GrGLBinding == this->glBinding()) {
         fDualSourceBlendingSupport =
                             fGLVersion >= 3.3f ||
                             this->hasExtension("GL_ARB_blend_func_extended");
+        fShaderDerivativeSupport = true;
     } else {
         fDualSourceBlendingSupport = false;
+        fShaderDerivativeSupport =
+                            this->hasExtension("GL_OES_standard_derivatives");
     }
 
     fProgramData = NULL;