Move texture domains onto a GrCustomStage, off of GrSamplerState.

This will require gyp changes to roll into Chrome.

http://codereview.appspot.com/6405050/



git-svn-id: http://skia.googlecode.com/svn/trunk@4641 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 4f549d0..49cb161 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -86,11 +86,6 @@
     *s = "uSampler";
     s->appendS32(stage);
 }
-
-inline void tex_domain_name(int stage, SkString* s) {
-    *s = "uTexDom";
-    s->appendS32(stage);
-}
 }
 
 GrGLProgram::GrGLProgram() {
@@ -1023,14 +1018,6 @@
                 GrAssert(kUnusedUniform != locations.fSamplerUni);
             }
 
-            if (kUseUniform == locations.fTexDomUni) {
-                SkString texDomName;
-                tex_domain_name(s, &texDomName);
-                GL_CALL_RET(locations.fTexDomUni,
-                            GetUniformLocation(fProgramID, texDomName.c_str()));
-                GrAssert(kUnusedUniform != locations.fTexDomUni);
-            }
-
             if (NULL != fProgramStage[s]) {
                 fProgramStage[s]->initUniforms(&builder, gl.interface(), fProgramID);
             }
@@ -1044,7 +1031,6 @@
             GL_CALL(Uniform1i(fUniLocations.fStages[s].fSamplerUni, s));
         }
         fTextureMatrices[s] = GrMatrix::InvalidMatrix();
-        fTextureDomain[s].setEmpty();
         // this is arbitrary, just initialize to something
         fTextureOrientation[s] = GrGLTexture::kBottomUp_Orientation;
         // Must not reset fStageOverride[] here.
@@ -1154,22 +1140,6 @@
         (StageDesc::kMulRGBByAlpha_RoundUp_InConfigFlag |
          StageDesc::kMulRGBByAlpha_RoundDown_InConfigFlag);
 
-    if (desc.fOptFlags & StageDesc::kCustomTextureDomain_OptFlagBit) {
-        SkString texDomainName;
-        tex_domain_name(stageNum, &texDomainName);
-        segments->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
-                             kVec4f_GrSLType, texDomainName.c_str());
-        SkString coordVar("clampCoord");
-        segments->fFSCode.appendf("\t%s %s = clamp(%s, %s.xy, %s.zw);\n",
-                                  float_vector_type_str(segments->fCoordDims),
-                                  coordVar.c_str(),
-                                  segments->fSampleCoords.c_str(),
-                                  texDomainName.c_str(),
-                                  texDomainName.c_str());
-        segments->fSampleCoords = coordVar;
-        locations.fTexDomUni = kUseUniform;
-    }
-
     // NOTE: GrGLProgramStages are now responsible for fetching
     if (NULL == customStage) {
         if (desc.fInConfigFlags & kMulByAlphaMask) {
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index c397d74..9381cfb 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -112,7 +112,6 @@
             enum OptFlagBits {
                 kNoPerspective_OptFlagBit       = 1 << 0,
                 kIdentityMatrix_OptFlagBit      = 1 << 1,
-                kCustomTextureDomain_OptFlagBit = 1 << 2,
                 kIsEnabled_OptFlagBit           = 1 << 7
             };
 
@@ -322,10 +321,9 @@
     GrColor                     fColor;
     GrColor                     fCoverage;
     GrColor                     fColorFilterColor;
+    /// When it is sent to GL, the texture matrix will be flipped if the texture orientation
+    /// (below) requires.
     GrMatrix                    fTextureMatrices[GrDrawState::kNumStages];
-    GrRect                      fTextureDomain[GrDrawState::kNumStages];
-    // The texture domain and texture matrix sent to GL depend upon the
-    // orientation.
     GrGLTexture::Orientation    fTextureOrientation[GrDrawState::kNumStages];
 
     GrGLProgramStage*           fProgramStage[GrDrawState::kNumStages];
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 077f807..7f982e7 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -248,30 +248,6 @@
             fCurrentProgram->fTextureMatrices[s] = samplerMatrix;
         }
 
-        const GrGLint& domUni =  fCurrentProgram->fUniLocations.fStages[s].fTexDomUni;
-        const GrRect &texDom = drawState.getSampler(s).getTextureDomain();
-        if (GrGLProgram::kUnusedUniform != domUni &&
-            (orientationChange ||fCurrentProgram->fTextureDomain[s] != texDom)) {
-
-            fCurrentProgram->fTextureDomain[s] = texDom;
-
-            float values[4] = {
-                GrScalarToFloat(texDom.left()),
-                GrScalarToFloat(texDom.top()),
-                GrScalarToFloat(texDom.right()),
-                GrScalarToFloat(texDom.bottom())
-            };
-
-            // vertical flip if necessary
-            if (GrGLTexture::kBottomUp_Orientation == texture->orientation()) {
-                values[1] = 1.0f - values[1];
-                values[3] = 1.0f - values[3];
-                // The top and bottom were just flipped, so correct the ordering
-                // of elements so that values = (l, t, r, b).
-                SkTSwap(values[1], values[3]);
-            }
-            GL_CALL(Uniform4fv(domUni, 1, values));
-        }
         fCurrentProgram->fTextureOrientation[s] = texture->orientation();
     }
 }
@@ -768,14 +744,6 @@
                 stage.fOptFlags |= StageDesc::kNoPerspective_OptFlagBit;
             }
 
-            if (sampler.hasTextureDomain()) {
-                GrAssert(GrSamplerState::kClamp_WrapMode ==
-                            sampler.getWrapX() &&
-                         GrSamplerState::kClamp_WrapMode ==
-                            sampler.getWrapY());
-                stage.fOptFlags |= StageDesc::kCustomTextureDomain_OptFlagBit;
-            }
-
             stage.fInConfigFlags = 0;
             if (!this->glCaps().textureSwizzleSupport()) {
                 if (GrPixelConfigIsAlphaOnly(texture->config())) {