Revert r6330 thru 6333 while we figure out what to do about Intel bots (possible...
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 22 Oct 2012 20:36:53 +0000 (20:36 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 22 Oct 2012 20:36:53 +0000 (20:36 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@6037 2bbb7eff-a529-9590-31e7-b0007b416f81

22 files changed:
src/effects/SkColorMatrixFilter.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMatrixConvolutionImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkTableColorFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointRadialGradient.cpp
src/gpu/GrAAHairLinePathRenderer.cpp
src/gpu/GrContext.cpp
src/gpu/effects/GrConvolutionEffect.cpp
src/gpu/effects/GrTextureDomainEffect.cpp
src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGLCaps.h
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLProgram.h
src/gpu/gl/GrGLProgramStage.cpp
src/gpu/gl/GrGLProgramStage.h
src/gpu/gl/GrGLShaderBuilder.cpp
src/gpu/gl/GrGLShaderBuilder.h

index feb2d62..f054f72 100644 (file)
@@ -383,7 +383,9 @@ public:
         }
 
         virtual void setData(const GrGLUniformManager& uniManager,
-                             const GrCustomStage& stage) SK_OVERRIDE {
+                                const GrCustomStage& stage,
+                                const GrRenderTarget*,
+                                int /* stageNum */) SK_OVERRIDE {
             const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(stage);
             const float* m = cme.fMatrix.fMat;
             // The GL matrix is transposed from SkColorMatrix.
index 07acde3..ddb3193 100644 (file)
@@ -42,7 +42,14 @@ void setUniformPoint3(const GrGLUniformManager& uman, UniformHandle uni, const S
 }
 
 void setUniformNormal3(const GrGLUniformManager& uman, UniformHandle uni, const SkPoint3& point) {
-    setUniformPoint3(uman, uni, SkPoint3(point.fX, point.fY, point.fZ));
+    setUniformPoint3(uman, uni, SkPoint3(point.fX, -point.fY, point.fZ));
+}
+
+void setUniformPoint3FlipY(const GrGLUniformManager& uman,
+                           UniformHandle uni,
+                           const SkPoint3& point,
+                           int height) {
+    setUniformPoint3(uman, uni, SkPoint3(point.fX, height-point.fY, point.fZ));
 }
 #endif
 
@@ -369,12 +376,12 @@ public:
     virtual void setupVariables(GrGLShaderBuilder* builder);
     virtual void emitVS(SkString* out) const {}
     virtual void emitFuncs(GrGLShaderBuilder* builder) {}
-    virtual void emitSurfaceToLight(GrGLShaderBuilder*,
+    virtual void emitSurfaceToLight(const GrGLShaderBuilder*,
                                     SkString* out,
                                     const char* z) const = 0;
     virtual void emitLightColor(GrGLShaderBuilder*,
                                 const char *surfaceToLight) const;
-    virtual void setData(const GrGLUniformManager&, const SkLight* light) const;
+    virtual void setData(const GrGLUniformManager&, const GrRenderTarget* rt, const SkLight* light) const;
 
 private:
     typedef SkRefCnt INHERITED;
@@ -389,8 +396,8 @@ class GrGLDistantLight : public GrGLLight {
 public:
     virtual ~GrGLDistantLight() {}
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const SkLight* light) const SK_OVERRIDE;
-    virtual void emitSurfaceToLight(GrGLShaderBuilder*,
+    virtual void setData(const GrGLUniformManager&, const GrRenderTarget* rt, const SkLight* light) const SK_OVERRIDE;
+    virtual void emitSurfaceToLight(const GrGLShaderBuilder*,
                                     SkString* out,
                                     const char* z) const SK_OVERRIDE;
 private:
@@ -404,9 +411,9 @@ class GrGLPointLight : public GrGLLight {
 public:
     virtual ~GrGLPointLight() {}
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const SkLight* light) const SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&, const GrRenderTarget* rt, const SkLight* light) const SK_OVERRIDE;
     virtual void emitVS(SkString* out) const SK_OVERRIDE;
-    virtual void emitSurfaceToLight(GrGLShaderBuilder*,
+    virtual void emitSurfaceToLight(const GrGLShaderBuilder*,
                                     SkString* out,
                                     const char* z) const SK_OVERRIDE;
 private:
@@ -421,10 +428,10 @@ class GrGLSpotLight : public GrGLLight {
 public:
     virtual ~GrGLSpotLight() {}
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const SkLight* light) const SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&, const GrRenderTarget* rt, const SkLight* light) const SK_OVERRIDE;
     virtual void emitVS(SkString* out) const SK_OVERRIDE;
     virtual void emitFuncs(GrGLShaderBuilder* builder);
-    virtual void emitSurfaceToLight(GrGLShaderBuilder* builder,
+    virtual void emitSurfaceToLight(const GrGLShaderBuilder* builder,
                                     SkString* out,
                                     const char* z) const SK_OVERRIDE;
     virtual void emitLightColor(GrGLShaderBuilder*,
@@ -957,7 +964,10 @@ public:
 
     static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
 
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
 private:
     typedef GrGLProgramStage INHERITED;
@@ -975,7 +985,10 @@ public:
                               const GrCustomStage& stage);
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
     virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
 private:
     typedef GrGLLightingEffect INHERITED;
@@ -991,7 +1004,10 @@ public:
                                const GrCustomStage& stage);
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
     virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
 private:
     typedef GrGLLightingEffect INHERITED;
@@ -1117,7 +1133,7 @@ void GrGLLightingEffect::emitFS(GrGLShaderBuilder* builder,
                           "pointToNormal",
                           SK_ARRAY_COUNT(gPointToNormalArgs),
                           gPointToNormalArgs,
-                          "\treturn normalize(vec3(-x * scale, y * scale, 1));\n",
+                          "\treturn normalize(vec3(-x * scale, -y * scale, 1));\n",
                           &pointToNormalName);
 
     static const GrGLShaderVar gInteriorNormalArgs[] =  {
@@ -1173,14 +1189,17 @@ GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrCustomStage& s,
     return static_cast<const GrLightingEffect&>(s).light()->type();
 }
 
-void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
+void GrGLLightingEffect::setData(const GrGLUniformManager& uman,
+                                 const GrCustomStage& data,
+                                 const GrRenderTarget* rt,
+                                 int stageNum) {
     const GrLightingEffect& effect =
         static_cast<const GrLightingEffect&>(data);
     GrGLTexture* texture = static_cast<GrGLTexture*>(data.texture(0));
     float ySign = texture->orientation() == GrGLTexture::kTopDown_Orientation ? -1.0f : 1.0f;
     uman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
     uman.set1f(fSurfaceScaleUni, effect.surfaceScale());
-    fLight->setData(uman, effect.light());
+    fLight->setData(uman, rt, effect.light());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1217,8 +1236,11 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri
                           funcName);
 }
 
-void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
-    INHERITED::setData(uman, data);
+void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman,
+                                        const GrCustomStage& data,
+                                        const GrRenderTarget* rt,
+                                        int stageNum) {
+    INHERITED::setData(uman, data, rt, stageNum);
     const GrDiffuseLightingEffect& effect =
         static_cast<const GrDiffuseLightingEffect&>(data);
     uman.set1f(fKDUni, effect.kd());
@@ -1297,8 +1319,10 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr
 }
 
 void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman,
-                                         const GrCustomStage& data) {
-    INHERITED::setData(uman, data);
+                                         const GrCustomStage& data,
+                                         const GrRenderTarget* rt,
+                                         int stageNum) {
+    INHERITED::setData(uman, data, rt, stageNum);
     const GrSpecularLightingEffect& effect = static_cast<const GrSpecularLightingEffect&>(data);
     uman.set1f(fKSUni, effect.ks());
     uman.set1f(fShininessUni, effect.shininess());
@@ -1318,6 +1342,7 @@ void GrGLLight::setupVariables(GrGLShaderBuilder* builder) {
 }
 
 void GrGLLight::setData(const GrGLUniformManager& uman,
+                        const GrRenderTarget* rt,
                         const SkLight* light) const {
     setUniformPoint3(uman, fColorUni, light->color() * SkScalarInvert(SkIntToScalar(255)));
 }
@@ -1330,14 +1355,16 @@ void GrGLDistantLight::setupVariables(GrGLShaderBuilder* builder) {
                                         "LightDirection");
 }
 
-void GrGLDistantLight::setData(const GrGLUniformManager& uman, const SkLight* light) const {
-    INHERITED::setData(uman, light);
+void GrGLDistantLight::setData(const GrGLUniformManager& uman,
+                               const GrRenderTarget* rt,
+                               const SkLight* light) const {
+    INHERITED::setData(uman, rt, light);
     SkASSERT(light->type() == SkLight::kDistant_LightType);
     const SkDistantLight* distantLight = static_cast<const SkDistantLight*>(light);
     setUniformNormal3(uman, fDirectionUni, distantLight->direction());
 }
 
-void GrGLDistantLight::emitSurfaceToLight(GrGLShaderBuilder* builder,
+void GrGLDistantLight::emitSurfaceToLight(const GrGLShaderBuilder* builder,
                                           SkString* out,
                                           const char* z) const {
     const char* dir = builder->getUniformCStr(fDirectionUni);
@@ -1353,21 +1380,22 @@ void GrGLPointLight::setupVariables(GrGLShaderBuilder* builder) {
 }
 
 void GrGLPointLight::setData(const GrGLUniformManager& uman,
+                             const GrRenderTarget* rt,
                              const SkLight* light) const {
-    INHERITED::setData(uman, light);
+    INHERITED::setData(uman, rt, light);
     SkASSERT(light->type() == SkLight::kPoint_LightType);
     const SkPointLight* pointLight = static_cast<const SkPointLight*>(light);
-    setUniformPoint3(uman, fLocationUni, pointLight->location());
+    setUniformPoint3FlipY(uman, fLocationUni, pointLight->location(), rt->height());
 }
 
 void GrGLPointLight::emitVS(SkString* out) const {
 }
 
-void GrGLPointLight::emitSurfaceToLight(GrGLShaderBuilder* builder,
+void GrGLPointLight::emitSurfaceToLight(const GrGLShaderBuilder* builder,
                                         SkString* out,
                                         const char* z) const {
     const char* loc = builder->getUniformCStr(fLocationUni);
-    out->appendf("normalize(%s - vec3(%s.xy, %s))", loc, builder->fragmentPosition(), z);
+    out->appendf("normalize(%s - vec3(gl_FragCoord.xy, %s))", loc, z);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1389,11 +1417,12 @@ void GrGLSpotLight::setupVariables(GrGLShaderBuilder* builder) {
 }
 
 void GrGLSpotLight::setData(const GrGLUniformManager& uman,
+                            const GrRenderTarget* rt,
                             const SkLight* light) const {
-    INHERITED::setData(uman, light);
+    INHERITED::setData(uman, rt, light);
     SkASSERT(light->type() == SkLight::kSpot_LightType);
     const SkSpotLight* spotLight = static_cast<const SkSpotLight *>(light);
-    setUniformPoint3(uman, fLocationUni, spotLight->location());
+    setUniformPoint3FlipY(uman, fLocationUni, spotLight->location(), rt->height());
     uman.set1f(fExponentUni, spotLight->specularExponent());
     uman.set1f(fCosInnerConeAngleUni, spotLight->cosInnerConeAngle());
     uman.set1f(fCosOuterConeAngleUni, spotLight->cosOuterConeAngle());
@@ -1434,11 +1463,11 @@ void GrGLSpotLight::emitFuncs(GrGLShaderBuilder* builder) {
                           &fLightColorFunc);
 }
 
-void GrGLSpotLight::emitSurfaceToLight(GrGLShaderBuilder* builder,
+void GrGLSpotLight::emitSurfaceToLight(const GrGLShaderBuilder* builder,
                                        SkString* out,
                                        const char* z) const {
     const char* location= builder->getUniformCStr(fLocationUni);
-    out->appendf("normalize(%s - vec3(%s.xy, %s))", location, builder->fragmentPosition(), z);
+    out->appendf("normalize(%s - vec3(gl_FragCoord.xy, %s))", location, z);
 }
 
 void GrGLSpotLight::emitLightColor(GrGLShaderBuilder* builder,
index 3b7f9e3..9871fc0 100644 (file)
@@ -86,7 +86,9 @@ public:
                         const TextureSamplerArray&) SK_OVERRIDE;
 
     virtual void setData(const GrGLUniformManager& uman,
-                         const GrCustomStage& data) SK_OVERRIDE;
+                         const GrCustomStage& data,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
 
@@ -165,7 +167,9 @@ void GrGLMagnifierEffect::emitFS(GrGLShaderBuilder* state,
 }
 
 void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
-                                  const GrCustomStage& data) {
+                                  const GrCustomStage& data,
+                                  const GrRenderTarget*,
+                                  int stageNum) {
     const GrMagnifierEffect& zoom =
         static_cast<const GrMagnifierEffect&>(data);
 
index e6067ea..234a74a 100644 (file)
@@ -293,7 +293,10 @@ public:
 
     static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
 
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
 private:
     typedef GrGLUniformManager::UniformHandle        UniformHandle;
@@ -423,7 +426,9 @@ GrGLProgramStage::StageKey GrGLMatrixConvolutionEffect::GenKey(const GrCustomSta
 }
 
 void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
-                                          const GrCustomStage& data) {
+                                   const GrCustomStage& data,
+                                   const GrRenderTarget*,
+                                   int stageNum) {
     const GrMatrixConvolutionEffect& effect =
         static_cast<const GrMatrixConvolutionEffect&>(data);
     GrGLTexture& texture =
index 3c2c284..9bddb9b 100644 (file)
@@ -281,7 +281,10 @@ public:
 
     static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
 
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
 private:
     int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
@@ -349,7 +352,10 @@ GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrCustomStage& s,
     return key;
 }
 
-void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
+void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman,
+                                   const GrCustomStage& data,
+                                   const GrRenderTarget*,
+                                   int stageNum) {
     const Gr1DKernelEffect& kern =
         static_cast<const Gr1DKernelEffect&>(data);
     GrGLTexture& texture =
index 6066e68..83049f2 100644 (file)
@@ -257,7 +257,10 @@ public:
                         const char* inputColor,
                         const TextureSamplerArray&) SK_OVERRIDE;
 
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE {}
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE {}
 
     static StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
 
index 443eec6..cc7e13c 100644 (file)
@@ -687,7 +687,10 @@ void GrGLGradientStage::setupVariables(GrGLShaderBuilder* builder) {
                                   kFloat_GrSLType, "GradientYCoordFS");
 }
 
-void GrGLGradientStage::setData(const GrGLUniformManager& uman, const GrCustomStage& stage) {
+void GrGLGradientStage::setData(const GrGLUniformManager& uman,
+                                const GrCustomStage& stage,
+                                const GrRenderTarget*,
+                                int stageNum) {
     GrScalar yCoord = static_cast<const GrGradientEffect&>(stage).getYCoord();
     if (yCoord != fCachedYCoord) {
         uman.set1f(fFSYUni, yCoord);
index 8c0bae9..61b9c35 100644 (file)
@@ -278,7 +278,10 @@ public:
     virtual ~GrGLGradientStage();
 
     virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     // emit code that gets a fragment's color from an expression for t; for now
     // this always uses the texture, but for simpler cases we'll be able to lerp
index b78b3fe..19b1228 100644 (file)
@@ -333,7 +333,10 @@ public:
                         const char* outputColor,
                         const char* inputColor,
                         const TextureSamplerArray&) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
 
@@ -626,8 +629,11 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* builder,
     }
 }
 
-void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrCustomStage& baseData) {
-    INHERITED::setData(uman, baseData);
+void GrGLConical2Gradient::setData(const GrGLUniformManager& uman,
+                                   const GrCustomStage& baseData,
+                                   const GrRenderTarget* target,
+                                   int stageNum) {
+    INHERITED::setData(uman, baseData, target, stageNum);
     const GrConical2Gradient& data =
         static_cast<const GrConical2Gradient&>(baseData);
     GrAssert(data.isDegenerate() == fIsDegenerate);
index 00578aa..3476c39 100644 (file)
@@ -368,7 +368,10 @@ public:
                         const char* outputColor,
                         const char* inputColor,
                         const TextureSamplerArray&) SK_OVERRIDE;
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
 
@@ -563,6 +566,7 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* builder,
         bVar = fFSVaryingName;
     } else {
         bVar = "b";
+        //bVar.appendS32(stageNum);
         code->appendf("\tfloat %s = 2.0 * (%s * %s.x - %s);\n",
                       bVar.c_str(), p2.c_str(),
                       builder->defaultTexCoordsName(), p3.c_str());
@@ -601,8 +605,11 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* builder,
     this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
 }
 
-void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrCustomStage& baseData) {
-    INHERITED::setData(uman, baseData);
+void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
+                                  const GrCustomStage& baseData,
+                                  const GrRenderTarget* target,
+                                  int stageNum) {
+    INHERITED::setData(uman, baseData, target, stageNum);
     const GrRadial2Gradient& data =
         static_cast<const GrRadial2Gradient&>(baseData);
     GrAssert(data.isDegenerate() == fIsDegenerate);
index 411b0e3..06d8e71 100644 (file)
@@ -458,7 +458,16 @@ void add_line(const SkPoint p[2],
     if (orthVec.setLength(SK_Scalar1)) {
         orthVec.setOrthog(orthVec);
 
-        SkScalar lineC = -(a.dot(orthVec));
+        // the values we pass down to the frag shader
+        // have to be in y-points-up space;
+        SkVector normal;
+        normal.fX = orthVec.fX;
+        normal.fY = -orthVec.fY;
+        SkPoint aYDown;
+        aYDown.fX = a.fX;
+        aYDown.fY = rtHeight - a.fY;
+
+        SkScalar lineC = -(aYDown.dot(normal));
         for (int i = 0; i < kVertsPerLineSeg; ++i) {
             (*vert)[i].fPos = (i < 2) ? a : b;
             if (0 == i || 3 == i) {
@@ -466,8 +475,8 @@ void add_line(const SkPoint p[2],
             } else {
                 (*vert)[i].fPos += orthVec;
             }
-            (*vert)[i].fLine.fA = orthVec.fX;
-            (*vert)[i].fLine.fB = orthVec.fY;
+            (*vert)[i].fLine.fA = normal.fX;
+            (*vert)[i].fLine.fB = normal.fY;
             (*vert)[i].fLine.fC = lineC;
         }
         if (NULL != toSrc) {
index e729e6d..81f9717 100644 (file)
@@ -1061,7 +1061,9 @@ void GrContext::drawOval(const GrPaint& paint,
     verts[3].fPos = SkPoint::Make(R, B);
 
     for (int i = 0; i < 4; ++i) {
-        verts[i].fCenter = center;
+        // this goes to fragment shader, it should be in y-points-up space.
+        verts[i].fCenter = SkPoint::Make(center.fX, rt->height() - center.fY);
+
         verts[i].fOuterRadius = outerRadius;
         verts[i].fInnerRadius = innerRadius;
     }
index d775082..c189ec0 100644 (file)
@@ -28,7 +28,10 @@ public:
                         const char* inputColor,
                         const TextureSamplerArray&) SK_OVERRIDE;
 
-    virtual void setData(const GrGLUniformManager& uman, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager& uman,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
 
@@ -88,7 +91,10 @@ void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* builder,
     GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
 }
 
-void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
+void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
+                                    const GrCustomStage& data,
+                                    const GrRenderTarget*,
+                                    int stageNum) {
     const GrConvolutionEffect& conv =
         static_cast<const GrConvolutionEffect&>(data);
     GrTexture& texture = *data.texture(0);
index 219a752..c00f40f 100644 (file)
@@ -22,7 +22,10 @@ public:
                         const char* inputColor,
                         const TextureSamplerArray&) SK_OVERRIDE;
 
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage&,
+                         const GrRenderTarget*,
+                         int stageNum) SK_OVERRIDE;
 
     static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&) { return 0; }
 
@@ -60,7 +63,10 @@ void GrGLTextureDomainEffect::emitFS(GrGLShaderBuilder* builder,
     builder->fFSCode.append(";\n");
 }
 
-void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
+void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
+                                      const GrCustomStage& data,
+                                      const GrRenderTarget*,
+                                      int stageNum) {
     const GrTextureDomainEffect& effect = static_cast<const GrTextureDomainEffect&>(data);
     const GrRect& domain = effect.domain();
 
index 646961b..52c480a 100644 (file)
@@ -36,7 +36,6 @@ void GrGLCaps::reset() {
     fTextureRedSupport = false;
     fImagingSupport = false;
     fTwoFormatLimit = false;
-    fFragCoordsConventionSupport = false;
 }
 
 GrGLCaps::GrGLCaps(const GrGLCaps& caps) {
@@ -66,7 +65,6 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
     fTextureRedSupport = caps.fTextureRedSupport;
     fImagingSupport = caps.fImagingSupport;
     fTwoFormatLimit = caps.fTwoFormatLimit;
-    fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
 
     return *this;
 }
@@ -160,9 +158,6 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
     // can change based on which render target is bound
     fTwoFormatLimit = kES2_GrGLBinding == binding;
 
-    fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration ||
-                                   ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions");
-
     this->initFSAASupport(ctxInfo);
     this->initStencilFormats(ctxInfo);
 }
index 9dfbf23..1cc50c2 100644 (file)
@@ -216,9 +216,6 @@ public:
     /// Is GL_ARB_IMAGING supported
     bool imagingSupport() const { return fImagingSupport; }
 
-    /// Is GL_ARB_fragment_coord_conventions supported?
-    bool fragCoordConventionsSupport() const { return fFragCoordsConventionSupport; }
-
     // Does ReadPixels support the provided format/type combo?
     bool readPixelsSupported(const GrGLInterface* intf,
                              GrGLenum format,
@@ -296,7 +293,6 @@ private:
     bool fTextureRedSupport : 1;
     bool fImagingSupport  : 1;
     bool fTwoFormatLimit : 1;
-    bool fFragCoordsConventionSupport : 1;
 };
 
 #endif
index aca42f7..066da35 100644 (file)
@@ -77,7 +77,6 @@ GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
     fViewportSize.set(-1, -1);
     fColor = GrColor_ILLEGAL;
     fColorFilterColor = GrColor_ILLEGAL;
-    fRTHeight = -1;
 
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         fProgramStage[s] = NULL;
@@ -235,57 +234,56 @@ static void addColorFilter(SkString* fsCode, const char * outputVar,
 }
 
 bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
-                                  GrGLShaderBuilder* builder) const {
+                                  GrGLShaderBuilder* segments) const {
     if (fDesc.fVertexLayout & GrDrawTarget::kEdge_VertexLayoutBit) {
         const char *vsName, *fsName;
-        builder->addVarying(kVec4f_GrSLType, "Edge", &vsName, &fsName);
-        builder->fVSAttrs.push_back().set(kVec4f_GrSLType,
-                                          GrGLShaderVar::kAttribute_TypeModifier,
-                                          EDGE_ATTR_NAME);
-        builder->fVSCode.appendf("\t%s = " EDGE_ATTR_NAME ";\n", vsName);
+        segments->addVarying(kVec4f_GrSLType, "Edge", &vsName, &fsName);
+        segments->fVSAttrs.push_back().set(kVec4f_GrSLType,
+            GrGLShaderVar::kAttribute_TypeModifier, EDGE_ATTR_NAME);
+        segments->fVSCode.appendf("\t%s = " EDGE_ATTR_NAME ";\n", vsName);
         switch (fDesc.fVertexEdgeType) {
         case GrDrawState::kHairLine_EdgeType:
-            builder->fFSCode.appendf("\tfloat edgeAlpha = abs(dot(vec3(%s.xy,1), %s.xyz));\n", builder->fragmentPosition(), fsName);
-            builder->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
+            segments->fFSCode.appendf("\tfloat edgeAlpha = abs(dot(vec3(gl_FragCoord.xy,1), %s.xyz));\n", fsName);
+            segments->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
             break;
         case GrDrawState::kQuad_EdgeType:
-            builder->fFSCode.append("\tfloat edgeAlpha;\n");
+            segments->fFSCode.append("\tfloat edgeAlpha;\n");
             // keep the derivative instructions outside the conditional
-            builder->fFSCode.appendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
-            builder->fFSCode.appendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
-            builder->fFSCode.appendf("\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsName, fsName);
+            segments->fFSCode.appendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
+            segments->fFSCode.appendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
+            segments->fFSCode.appendf("\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsName, fsName);
             // today we know z and w are in device space. We could use derivatives
-            builder->fFSCode.appendf("\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName, fsName);
-            builder->fFSCode.append ("\t} else {\n");
-            builder->fFSCode.appendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
-                                     "\t\t               2.0*%s.x*duvdy.x - duvdy.y);\n",
-                                     fsName, fsName);
-            builder->fFSCode.appendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
-            builder->fFSCode.append("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n"
-                                    "\t}\n");
+            segments->fFSCode.appendf("\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName, fsName);
+            segments->fFSCode.append ("\t} else {\n");
+            segments->fFSCode.appendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
+                                      "\t\t               2.0*%s.x*duvdy.x - duvdy.y);\n",
+                                      fsName, fsName);
+            segments->fFSCode.appendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
+            segments->fFSCode.append("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n"
+                                      "\t}\n");
             if (kES2_GrGLBinding == fContextInfo.binding()) {
-                builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
+                segments->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
         case GrDrawState::kHairQuad_EdgeType:
-            builder->fFSCode.appendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
-            builder->fFSCode.appendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
-            builder->fFSCode.appendf("\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
-                                     "\t               2.0*%s.x*duvdy.x - duvdy.y);\n",
-                                     fsName, fsName);
-            builder->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
-            builder->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
-            builder->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
+            segments->fFSCode.appendf("\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
+            segments->fFSCode.appendf("\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
+            segments->fFSCode.appendf("\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
+                                      "\t               2.0*%s.x*duvdy.x - duvdy.y);\n",
+                                      fsName, fsName);
+            segments->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
+            segments->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
+            segments->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
             if (kES2_GrGLBinding == fContextInfo.binding()) {
-                builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
+                segments->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
         case GrDrawState::kCircle_EdgeType:
-            builder->fFSCode.append("\tfloat edgeAlpha;\n");
-            builder->fFSCode.appendf("\tfloat d = distance(%s.xy, %s.xy);\n", builder->fragmentPosition(), fsName);
-            builder->fFSCode.appendf("\tfloat outerAlpha = smoothstep(d - 0.5, d + 0.5, %s.z);\n", fsName);
-            builder->fFSCode.appendf("\tfloat innerAlpha = %s.w == 0.0 ? 1.0 : smoothstep(%s.w - 0.5, %s.w + 0.5, d);\n", fsName, fsName, fsName);
-            builder->fFSCode.append("\tedgeAlpha = outerAlpha * innerAlpha;\n");
+            segments->fFSCode.append("\tfloat edgeAlpha;\n");
+            segments->fFSCode.appendf("\tfloat d = distance(gl_FragCoord.xy, %s.xy);\n", fsName);
+            segments->fFSCode.appendf("\tfloat outerAlpha = smoothstep(d - 0.5, d + 0.5, %s.z);\n", fsName);
+            segments->fFSCode.appendf("\tfloat innerAlpha = %s.w == 0.0 ? 1.0 : smoothstep(%s.w - 0.5, %s.w + 0.5, d);\n", fsName, fsName, fsName);
+            segments->fFSCode.append("\tedgeAlpha = outerAlpha * innerAlpha;\n");
             break;
         default:
             GrCrash("Unknown Edge Type!");
@@ -809,7 +807,6 @@ bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
 
     builder.finished(fProgramID);
     this->initSamplerUniforms();
-    fUniforms.fRTHeight = builder.getRTHeightUniform();
 
     return true;
 }
@@ -967,17 +964,15 @@ GrGLProgramStage* GrGLProgram::GenStageCode(const GrCustomStage* stage,
     return glStage;
 }
 
-void GrGLProgram::setData(const GrDrawState& drawState) {
-    int rtHeight = drawState.getRenderTarget()->height();
-    if (GrGLUniformManager::kInvalidUniformHandle != fUniforms.fRTHeight && fRTHeight != rtHeight) {
-        fUniformManager.set1f(fUniforms.fRTHeight, GrIntToScalar(rtHeight));
-        fRTHeight = rtHeight;
-    }
+void GrGLProgram::setData(const GrDrawState& drawState) const {
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         if (NULL != fProgramStage[s]) {
             const GrSamplerState& sampler = drawState.getSampler(s);
             GrAssert(NULL != sampler.getCustomStage());
-            fProgramStage[s]->setData(fUniformManager, *sampler.getCustomStage());
+            fProgramStage[s]->setData(fUniformManager,
+                                      *sampler.getCustomStage(),
+                                      drawState.getRenderTarget(),
+                                      s);
         }
     }
 }
index dd3378b..5f504f2 100644 (file)
@@ -72,7 +72,7 @@ public:
      * This function uploads uniforms and calls each GrCustomStage's setData. It is called before a
      * draw occurs using the program after the program has already been bound.
      */
-    void setData(const GrDrawState& drawState);
+    void setData(const GrDrawState& drawState) const;
 
     // Parameters that affect code generation
     // These structs should be kept compact; they are the input to an
@@ -221,16 +221,12 @@ private:
         UniformHandle fColorUni;
         UniformHandle fCoverageUni;
         UniformHandle fColorFilterUni;
-        // We use the render target height to provide a y-down frag coord when specifying
-        // origin_upper_left is not supported.
-        UniformHandle fRTHeight;
         StageUniforms fStages[GrDrawState::kNumStages];
         Uniforms() {
             fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle;
             fColorUni = GrGLUniformManager::kInvalidUniformHandle;
             fCoverageUni = GrGLUniformManager::kInvalidUniformHandle;
             fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle;
-            fRTHeight = GrGLUniformManager::kInvalidUniformHandle;
         }
     };
 
@@ -250,7 +246,6 @@ private:
     GrColor                     fColor;
     GrColor                     fCoverage;
     GrColor                     fColorFilterColor;
-    int                         fRTHeight;
     /// When it is sent to GL, the texture matrix will be flipped if the texture orientation
     /// (below) requires.
     GrMatrix                    fTextureMatrices[GrDrawState::kNumStages];
index 8a70608..b7d0c65 100644 (file)
@@ -21,7 +21,10 @@ void GrGLProgramStage::setupVariables(GrGLShaderBuilder*) {
 
 }
 
-void GrGLProgramStage::setData(const GrGLUniformManager&, const GrCustomStage&) {
+void GrGLProgramStage::setData(const GrGLUniformManager&,
+                               const GrCustomStage&,
+                               const GrRenderTarget*,
+                               int stageNum) {
 }
 
 GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrCustomStage& stage,
index 2cb5ae5..28d3f49 100644 (file)
@@ -73,7 +73,10 @@ public:
         that produces the same stage key; this function reads data from
         a stage and uploads any uniform variables required by the shaders
         created in emit*(). */
-    virtual void setData(const GrGLUniformManager&, const GrCustomStage& stage);
+    virtual void setData(const GrGLUniformManager&,
+                         const GrCustomStage& stage,
+                         const GrRenderTarget* renderTarget,
+                         int stageNum);
 
     const char* name() const { return fFactory.name(); }
 
index 677916e..3ce118c 100644 (file)
@@ -93,15 +93,13 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformMana
     , fContext(ctx)
     , fUniformManager(uniformManager)
     , fCurrentStage(kNonStageIdx)
-    , fSetupFragPosition(false)
-    , fRTHeightUniform(GrGLUniformManager::kInvalidUniformHandle)
     , fTexCoordVaryingType(kVoid_GrSLType) {
 }
 
 void GrGLShaderBuilder::setupTextureAccess(const char* varyingFSName, GrSLType varyingType) {
     // FIXME: We don't know how the custom stage will manipulate the coords. So we give up on using
     // projective texturing and always give the stage 2D coords. This will be fixed when custom
-    // stages are responsible for setting up their own tex coords / tex matrices.
+    // stages are repsonsible for setting up their own tex coords / tex matrices.
     switch (varyingType) {
         case kVec2f_GrSLType:
             fDefaultTexCoordsName = varyingFSName;
@@ -285,40 +283,6 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
     }
 }
 
-const char* GrGLShaderBuilder::fragmentPosition() {
-    if (fContext.caps().fragCoordConventionsSupport()) {
-        if (!fSetupFragPosition) {
-            fFSHeader.printf("#extension GL_ARB_fragment_coord_conventions: enable\n");
-            fFSHeader.append("layout(origin_upper_left) in vec4 gl_FragCoord;\n");
-            fSetupFragPosition = true;
-        }
-        return "gl_FragCoord";        
-    } else {
-        static const char* kCoordName = "fragCoordYDown";
-        if (!fSetupFragPosition) {
-            GrAssert(GrGLUniformManager::kInvalidUniformHandle == fRTHeightUniform);
-            const char* rtHeightName;
-        
-            // temporarily change the stage index because we're inserting a uniform whose name
-            // shouldn't be mangled to be stage-specific.
-            int oldStageIdx = fCurrentStage;
-            fCurrentStage = kNonStageIdx;
-            fRTHeightUniform = this->addUniform(kFragment_ShaderType,
-                                                kFloat_GrSLType,
-                                                "RTHeight",
-                                                &rtHeightName);
-            fCurrentStage = oldStageIdx;
-        
-            this->fFSCode.prependf("\tvec4 %s = vec4(gl_FragCoord.x, %s - gl_FragCoord.y, gl_FragCoord.zw);\n",
-                                   kCoordName, rtHeightName);
-            fSetupFragPosition = true;
-        }
-        GrAssert(GrGLUniformManager::kInvalidUniformHandle != fRTHeightUniform);
-        return kCoordName;
-    }
-}
-
-
 void GrGLShaderBuilder::emitFunction(ShaderType shader,
                                      GrSLType returnType,
                                      const char* name,
@@ -417,7 +381,6 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
             append_default_precision_qualifier(kDefaultFragmentPrecision,
                                                fContext.binding(),
                                                shaderStr);
-            shaderStr->append(fFSHeader);
             this->appendUniformDecls(kFragment_ShaderType, shaderStr);
             this->appendDecls(fFSInputs, shaderStr);
             // We shouldn't have declared outputs on 1.10
index aa88cf2..f143af3 100644 (file)
@@ -129,7 +129,7 @@ public:
         the generated shader code. This potentially allows greater reuse of cached shaders. */
     static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
 
-    /** Add a uniform variable to the current program, that has visibility in one or more shaders.
+    /** Add a uniform variable to the current program, that has visibilty in one or more shaders.
         visibility is a bitfield of ShaderType values indicating from which shaders the uniform
         should be accessible. At least one bit must be set. Geometry shader uniforms are not
         supported at this time. The actual uniform name will be mangled. If outName is not NULL then
@@ -151,7 +151,7 @@ public:
     const GrGLShaderVar& getUniformVariable(GrGLUniformManager::UniformHandle) const;
 
     /**
-     * Shortcut for getUniformVariable(u).c_str()
+     * Shorcut for getUniformVariable(u).c_str()
      */
     const char* getUniformCStr(GrGLUniformManager::UniformHandle u) const {
         return this->getUniformVariable(u).c_str();
@@ -165,10 +165,6 @@ public:
                     const char** vsOutName = NULL,
                     const char** fsInName = NULL);
 
-    /** Returns a variable name that represents the position of the fragment in the FS. The position
-        is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
-    const char* fragmentPosition();
-
     /** Called after building is complete to get the final shader string. */
     void getShader(ShaderType, SkString*) const;
 
@@ -184,8 +180,6 @@ public:
     void setCurrentStage(int stage) { fCurrentStage = stage; }
     void setNonStage() { fCurrentStage = kNonStageIdx; }
 
-    GrGLUniformManager::UniformHandle getRTHeightUniform() const { return fRTHeightUniform; }
-
 private:
 
     typedef GrTAllocator<GrGLShaderVar> VarArray;
@@ -217,14 +211,10 @@ private:
         kNonStageIdx = -1,
     };
 
-    const GrGLContextInfo&              fContext;
-    GrGLUniformManager&                 fUniformManager;
-    int                                 fCurrentStage;
-    SkString                            fFSFunctions;
-    SkString                            fFSHeader;
-
-    bool                                fSetupFragPosition;
-    GrGLUniformManager::UniformHandle   fRTHeightUniform;
+    const GrGLContextInfo&  fContext;
+    GrGLUniformManager&     fUniformManager;
+    int                     fCurrentStage;
+    SkString                fFSFunctions;
 
     /// Per-stage settings - only valid while we're inside GrGLProgram::genStageCode().
     //@{