There were three different problems with lighting filters:

1)  Texture offsets (fImageIncrement) have to be signed depending on
whether the texture is "right way up" (texture upload) or "upside down"
(render target), so the surface normals were coming out upside down.
2)  Light normals have to y-negated on upload
These two bugs were cancelling each other out in SampleApp, (where we
were testing w/textures) but not in Chrome (where we were testing
w/render targets).
3)  The extract-the-height-from-the-view-matrix hack I was using to
compare light positions vs. gl_FragCoord doesn't work in Chrome where we
compile with GR_STATIC_RECT_VB, and the view matrix contains more than
the viewport transform (to accomodate the canonical vertex buffer).
Fixed by passing the destination render target to
GrGLProgramStage::setData(), so it can flip the light positions in Y on
the CPU.

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



git-svn-id: http://skia.googlecode.com/svn/trunk@4605 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 4970d62..33f61b6 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -29,6 +29,7 @@
 
     virtual void setData(const GrGLInterface*,
                          const GrCustomStage&,
+                         const GrRenderTarget*,
                          int stageNum) SK_OVERRIDE;
 
     static inline StageKey GenKey(const GrCustomStage&);
@@ -118,6 +119,7 @@
 
 void GrGLConvolutionEffect::setData(const GrGLInterface* gl,
                                     const GrCustomStage& data,
+                                    const GrRenderTarget*,
                                     int stageNum) {
     const GrConvolutionEffect& conv =
         static_cast<const GrConvolutionEffect&>(data);
diff --git a/src/gpu/effects/GrGradientEffects.cpp b/src/gpu/effects/GrGradientEffects.cpp
index d4719b3..3125657 100644
--- a/src/gpu/effects/GrGradientEffects.cpp
+++ b/src/gpu/effects/GrGradientEffects.cpp
@@ -88,6 +88,7 @@
     virtual void initUniforms(const GrGLInterface*, int programID) SK_OVERRIDE;
     virtual void setData(const GrGLInterface*,
                          const GrCustomStage&,
+                         const GrRenderTarget*,
                          int stageNum) SK_OVERRIDE;
 
     static StageKey GenKey(const GrCustomStage& s) {
@@ -258,6 +259,7 @@
 
 void GrGLRadial2Gradient::setData(const GrGLInterface* gl,
                                   const GrCustomStage& baseData,
+                                  const GrRenderTarget*,
                                   int stageNum) {
     const GrRadial2Gradient& data =
         static_cast<const GrRadial2Gradient&>(baseData);
@@ -344,6 +346,7 @@
     virtual void initUniforms(const GrGLInterface*, int programID) SK_OVERRIDE;
     virtual void setData(const GrGLInterface*,
                          const GrCustomStage&,
+                         const GrRenderTarget*,
                          int stageNum) SK_OVERRIDE;
 
     static StageKey GenKey(const GrCustomStage& s) {
@@ -573,6 +576,7 @@
 
 void GrGLConical2Gradient::setData(const GrGLInterface* gl,
                                    const GrCustomStage& baseData,
+                                   const GrRenderTarget*,
                                    int stageNum) {
     const GrConical2Gradient& data =
         static_cast<const GrConical2Gradient&>(baseData);
diff --git a/src/gpu/effects/GrMorphologyEffect.cpp b/src/gpu/effects/GrMorphologyEffect.cpp
index 3ea2cbd..180b5eb 100644
--- a/src/gpu/effects/GrMorphologyEffect.cpp
+++ b/src/gpu/effects/GrMorphologyEffect.cpp
@@ -32,6 +32,7 @@
     virtual void initUniforms(const GrGLInterface*, int programID) SK_OVERRIDE;
     virtual void setData(const GrGLInterface*, 
                          const GrCustomStage&,
+                         const GrRenderTarget*,
                          int stageNum) SK_OVERRIDE;
 
 private:
@@ -124,6 +125,7 @@
 
 void GrGLMorphologyEffect ::setData(const GrGLInterface* gl,
                                     const GrCustomStage& data,
+                                    const GrRenderTarget*,
                                     int stageNum) {
     const Gr1DKernelEffect& kern =
         static_cast<const Gr1DKernelEffect&>(data);
diff --git a/src/gpu/gl/GrGLProgramStage.cpp b/src/gpu/gl/GrGLProgramStage.cpp
index b5e4f40..c1d4942 100644
--- a/src/gpu/gl/GrGLProgramStage.cpp
+++ b/src/gpu/gl/GrGLProgramStage.cpp
@@ -27,6 +27,7 @@
 
 void GrGLProgramStage::setData(const GrGLInterface*,
                                const GrCustomStage&,
+                               const GrRenderTarget*,
                                int stageNum) {
 }
 
diff --git a/src/gpu/gl/GrGLProgramStage.h b/src/gpu/gl/GrGLProgramStage.h
index 9cf2c1a..d5c79b4 100644
--- a/src/gpu/gl/GrGLProgramStage.h
+++ b/src/gpu/gl/GrGLProgramStage.h
@@ -83,6 +83,7 @@
         created in emit*(). */
     virtual void setData(const GrGLInterface* gl,
                          const GrCustomStage& stage,
+                         const GrRenderTarget* renderTarget,
                          int stageNum);
 
     const char* name() const { return fFactory.name(); }
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index a7187d5..af9bb05 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -480,7 +480,8 @@
                             this->getDrawState().getTexture(s));
                     fProgramData->fCustomStage[s]->setData(
                         this->glInterface(),
-                        *sampler.getCustomStage(), s);
+                        *sampler.getCustomStage(),
+                        drawState.getRenderTarget(), s);
                 }
             }
         }