Add support for reading the dst pixel value in an effect. Use in a new effect for the kDarken xfer mode.

The current implementation is to always make a copy of the entire dst before the draw.
It will only succeed if the RT is also a texture.
Obviously, there is lots of room for improvement.
Review URL: https://codereview.chromium.org/13314002

git-svn-id: http://skia.googlecode.com/svn/trunk@8449 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 98280e2..6ed5473 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -9,6 +9,7 @@
 #include "GrBackendEffectFactory.h"
 #include "GrDrawEffect.h"
 #include "GrEffect.h"
+#include "GrGLShaderBuilder.h"
 #include "GrGpuGL.h"
 
 void GrGLProgramDesc::Build(const GrDrawState& drawState,
@@ -17,6 +18,7 @@
                             GrBlendCoeff srcCoeff,
                             GrBlendCoeff dstCoeff,
                             const GrGpuGL* gpu,
+                            const GrDeviceCoordTexture* dstCopy,
                             GrGLProgramDesc* desc) {
 
     // This should already have been caught
@@ -80,6 +82,7 @@
         desc->fCoverageInput = kAttribute_ColorInput;
     }
 
+    bool readsDst = false;
     int lastEnabledStage = -1;
 
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
@@ -93,11 +96,22 @@
                                         GrDrawState::kLocalCoords_AttribBindingsBit);
             GrDrawEffect drawEffect(drawState.getStage(s), explicitLocalCoords);
             desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps());
+            if (effect->willReadDst()) {
+                readsDst = true;
+            }
         } else {
             desc->fEffectKeys[s] = 0;
         }
     }
 
+    if (readsDst) {
+        GrAssert(NULL != dstCopy);
+        desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopy->texture(), gpu->glCaps());
+        GrAssert(0 != desc->fDstRead);
+    } else {
+        desc->fDstRead = 0;
+    }
+
     desc->fDualSrcOutput = kNone_DualSrcOutput;
 
     // Currently the experimental GS will only work with triangle prims (and it doesn't do anything