This CL cleans up the last remaining users of localCoordChange on paint
authorjoshualitt <joshualitt@chromium.org>
Mon, 22 Dec 2014 23:27:05 +0000 (15:27 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Dec 2014 23:27:05 +0000 (15:27 -0800)
NOTREECHECKS=True
BUG=skia:

Review URL: https://codereview.chromium.org/817853002

23 files changed:
expectations/gm/ignored-tests.txt
gm/convexpolyeffect.cpp
gm/rrects.cpp
include/gpu/GrPaint.h
src/effects/SkDisplacementMapEffect.cpp
src/gpu/GrAAConvexPathRenderer.cpp
src/gpu/GrBitmapTextContext.cpp
src/gpu/GrBitmapTextContext.h
src/gpu/GrClipMaskManager.cpp
src/gpu/GrContext.cpp
src/gpu/GrDefaultGeoProcFactory.cpp
src/gpu/GrDefaultGeoProcFactory.h
src/gpu/GrDrawState.cpp
src/gpu/GrDrawState.h
src/gpu/GrDrawTarget.h
src/gpu/GrInOrderDrawBuffer.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/effects/GrBezierEffect.cpp
src/gpu/effects/GrBitmapTextGeoProc.cpp
src/gpu/effects/GrBitmapTextGeoProc.h
src/gpu/effects/GrDashingEffect.cpp
src/gpu/effects/GrDistanceFieldTextureEffect.cpp
src/gpu/gl/builders/GrGLProgramBuilder.cpp

index 65740962147e58155e4aea677c1687769e8fa53c..fe87f05c12b1ab198a55b76fbe71625f6814ae84 100644 (file)
@@ -33,6 +33,9 @@
 ## epoger will rebaseline by 25 Dec 2013
 #gradtext
 
+#joshualitt
+gpusamplerstress
+
 # robertphillips - skia:2995
 blurrects
 
index 03b9ad25a77029f6a6911dbd3941a2142aa6bdcf..65a1816818ba4ba004ca493e5cdec680dc2a700f 100644 (file)
@@ -136,7 +136,6 @@ protected:
                 SkAutoTUnref<const GrGeometryProcessor> gp(
                         GrDefaultGeoProcFactory::Create(0xff000000));
                 ds.addCoverageProcessor(fp);
-                ds.setIdentityViewMatrix();
                 ds.setRenderTarget(rt);
 
                 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
@@ -193,7 +192,6 @@ protected:
                 SkAutoTUnref<const GrGeometryProcessor> gp(
                         GrDefaultGeoProcFactory::Create(0xff000000));
                 ds.addCoverageProcessor(fp);
-                ds.setIdentityViewMatrix();
                 ds.setRenderTarget(rt);
 
                 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, gp->getVertexStride(), 0);
index 6c672b930492c70d239ef71f42003ae6628e9d54..bacc819cbb97cbfb927e114b28ab990bb1820c0e 100644 (file)
@@ -121,7 +121,6 @@ protected:
                                                                                    rrect));
                         if (fp) {
                             drawState.addCoverageProcessor(fp);
-                            drawState.setIdentityViewMatrix();
                             drawState.setRenderTarget(rt);
 
                             SkRect bounds = rrect.getBounds();
index d60b47ffc3902e2d88d2ba6d8d8218251456782d..3c131a6fcfaf257cc5a3d44d521e692605b6ef5e 100644 (file)
@@ -147,32 +147,6 @@ public:
      */
     bool isOpaqueAndConstantColor(GrColor* constantColor) const;
 
-    /**
-     * DO NOT USE THESE
-     * TODO Remove remaining use cases and delete these
-     */
-    bool localCoordChangeInverse(const SkMatrix& newToOld) {
-        SkMatrix oldToNew;
-        bool computed = false;
-        for (int i = 0; i < fColorStages.count(); ++i) {
-            if (!computed && !newToOld.invert(&oldToNew)) {
-                return false;
-            } else {
-                computed = true;
-            }
-            fColorStages[i].localCoordChange(oldToNew);
-        }
-        for (int i = 0; i < fCoverageStages.count(); ++i) {
-            if (!computed && !newToOld.invert(&oldToNew)) {
-                return false;
-            } else {
-                computed = true;
-            }
-            fCoverageStages[i].localCoordChange(oldToNew);
-        }
-        return true;
-    }
-
 private:
     friend class GrContext; // To access above two functions
     friend class GrStencilAndCoverTextContext;  // To access above two functions
index 2c7f5ee8cee5b9e71217a886d10af662cbbaf3fb..d18d3c3b6a4e68f6c3f86dd577feee46e416f4fb 100644 (file)
@@ -564,9 +564,9 @@ void GrGLDisplacementMapEffect::emitCode(GrGLFPBuilder* builder,
     // Unpremultiply the displacement
     fsBuilder->codeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
                            dColor, dColor, nearZero, dColor, dColor);
-
+    SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 1);
     fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
-                           cCoords, coords[1].c_str(), scaleUni, dColor);
+                           cCoords, coords2D.c_str(), scaleUni, dColor);
 
     switch (fXChannelSelector) {
       case SkDisplacementMapEffect::kR_ChannelSelectorType:
@@ -611,7 +611,9 @@ void GrGLDisplacementMapEffect::emitCode(GrGLFPBuilder* builder,
         "bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0);\t\t",
         outOfBounds, cCoords, cCoords, cCoords, cCoords);
     fsBuilder->codeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds);
-    fsBuilder->appendTextureLookup(samplers[1], cCoords, coords[1].getType());
+
+    // cCoords is always a vec2f
+    fsBuilder->appendTextureLookup(samplers[1], cCoords, kVec2f_GrSLType);
     fsBuilder->codeAppend(";\n");
 }
 
index 311010fcd9e15dc571b9daf856950351f593b76f..6d69823caf53e8052b32c4bc2be2d0ac6aa40d20 100644 (file)
@@ -575,7 +575,8 @@ public:
                                   const GrGLCaps&,
                                   GrProcessorKeyBuilder* b) {
             const BatchTracker& local = bt.cast<BatchTracker>();
-            b->add32(local.fInputColorType);
+            b->add32((local.fInputColorType << 16) |
+                     (local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 : 0x0));
         }
 
         virtual void setData(const GrGLProgramDataManager& pdman,
index 732a514c4fb2ef38983d69059afa68328ffb0b2b..790590dbcc2c75707cae674aee366f230407bcc3 100755 (executable)
@@ -154,7 +154,8 @@ void GrBitmapTextContext::onDrawText(const GrPaint& paint, const SkPaint& skPain
     SkFixed fx = SkScalarToFixed(x) + halfSampleX;
     SkFixed fy = SkScalarToFixed(y) + halfSampleY;
 
-    if (!fPaint.localCoordChangeInverse(viewMatrix)) {
+    // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix
+    if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatrix)) {
         SkDebugf("Cannot invert viewmatrix\n");
     }
 
@@ -202,7 +203,9 @@ void GrBitmapTextContext::onDrawPosText(const GrPaint& paint, const SkPaint& skP
 
     // store original matrix before we reset, so we can use it to transform positions
     SkMatrix ctm = viewMatrix;
-    if (!fPaint.localCoordChangeInverse(viewMatrix)) {
+
+    // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix
+    if (kARGB_GrMaskFormat != fCurrMaskFormat && !viewMatrix.invert(&fLocalMatrix)) {
             SkDebugf("Cannot invert viewmatrix\n");
     }
 
@@ -559,7 +562,6 @@ void GrBitmapTextContext::flush() {
         }
 
         GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode);
-        // TODO cache these GPs
         if (kARGB_GrMaskFormat == fCurrMaskFormat) {
             uint32_t textureUniqueID = fCurrTexture->getUniqueID();
             if (textureUniqueID != fEffectTextureUniqueID ||
@@ -569,19 +571,22 @@ void GrBitmapTextContext::flush() {
                 fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture,
                                                                             SkMatrix::I(),
                                                                             params));
+                fEffectTextureUniqueID = textureUniqueID;
             }
             drawState.addColorProcessor(fCachedTextureProcessor.get());
         } else {
             uint32_t textureUniqueID = fCurrTexture->getUniqueID();
             if (textureUniqueID != fEffectTextureUniqueID ||
-                fCachedGeometryProcessor->color() != color) {
+                fCachedGeometryProcessor->color() != color ||
+                !fCachedGeometryProcessor->localMatrix().cheapEqualTo(fLocalMatrix)) {
                 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat;
                 bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor());
                 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color,
                                                                            fCurrTexture,
                                                                            params,
                                                                            hasColor,
-                                                                           opaqueVertexColors));
+                                                                           opaqueVertexColors,
+                                                                           fLocalMatrix));
                 fEffectTextureUniqueID = textureUniqueID;
             }
         }
index ad21a2ffda56199c10e7ae4e8211dd782038dd57..f1e6b03212e40c30252f240b6fcce374bdc1a4b5 100644 (file)
@@ -35,6 +35,7 @@ private:
     SkAutoTUnref<const GrFragmentProcessor> fCachedTextureProcessor;
     // Used to check whether fCachedEffect is still valid.
     uint32_t                          fEffectTextureUniqueID;
+    SkMatrix                          fLocalMatrix;
 
     GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
 
index 5e2c0aa795522a85d0a82b15016e2d8c5a000cdb..e56f4dd77d523ad9f64df980c0435b82e7b552cd 100644 (file)
@@ -425,8 +425,6 @@ void GrClipMaskManager::mergeMask(GrDrawState* drawState,
                                   SkRegion::Op op,
                                   const SkIRect& dstBound,
                                   const SkIRect& srcBound) {
-    SkAssertResult(drawState->setIdentityViewMatrix());
-
     drawState->setRenderTarget(dstMask->asRenderTarget());
 
     // We want to invert the coverage here
@@ -606,11 +604,11 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
                 return NULL;
             }
 
-            GrDrawState backgroundDrawState(translate);
-            backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
-            backgroundDrawState.setRenderTarget(result->asRenderTarget());
-
             if (useTemp) {
+                GrDrawState backgroundDrawState;
+                backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
+                backgroundDrawState.setRenderTarget(result->asRenderTarget());
+
                 // Now draw into the accumulator using the real operation and the temp buffer as a
                 // texture
                 this->mergeMask(&backgroundDrawState,
@@ -620,6 +618,10 @@ GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t elementsGenID,
                                 maskSpaceIBounds,
                                 maskSpaceElementIBounds);
             } else {
+                GrDrawState backgroundDrawState(translate);
+                backgroundDrawState.enableState(GrDrawState::kClip_StateBit);
+                backgroundDrawState.setRenderTarget(result->asRenderTarget());
+
                 set_coverage_drawing_xpf(op, !invert, &backgroundDrawState);
                 // Draw to the exterior pixels (those with a zero stencil value).
                 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement,
index c637101d072881f2f3fc464df48cc7510fc39a97..2818aa92dd325090b2e97d0da5e0f2ab45174c82 100755 (executable)
@@ -555,29 +555,42 @@ void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix)
               SkIntToScalar(getRenderTarget()->width()),
               SkIntToScalar(getRenderTarget()->height()));
     SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
-    GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this);
+
+    // by definition this fills the entire clip, no need for AA
+    if (paint->isAntiAlias()) {
+        paint.writable()->setAntiAlias(false);
+    }
+
+    bool isPerspective = viewMatrix.hasPerspective();
 
     // We attempt to map r by the inverse matrix and draw that. mapRect will
     // map the four corners and bound them with a new rect. This will not
     // produce a correct result for some perspective matrices.
-    if (!viewMatrix.hasPerspective()) {
+    if (!isPerspective) {
         SkMatrix inverse;
         if (!viewMatrix.invert(&inverse)) {
             SkDebugf("Could not invert matrix\n");
             return;
         }
         inverse.mapRect(&r);
+        this->drawRect(*paint, viewMatrix, r);
     } else {
-        if (!paint.writable()->localCoordChangeInverse(viewMatrix)) {
+        SkMatrix localMatrix;
+        if (!viewMatrix.invert(&localMatrix)) {
             SkDebugf("Could not invert matrix\n");
             return;
         }
+
+        AutoCheckFlush acf(this);
+        GrDrawState drawState;
+        GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &SkMatrix::I(), &acf);
+        if (NULL == target) {
+            return;
+        }
+
+        GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target);
+        target->drawRect(&drawState, paint->getColor(), r, NULL, &localMatrix);
     }
-    // by definition this fills the entire clip, no need for AA
-    if (paint->isAntiAlias()) {
-        paint.writable()->setAntiAlias(false);
-    }
-    this->drawRect(*paint, viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix, r);
 }
 
 #ifdef SK_DEVELOPER
index a74565c5d744c38842439909c5adeaf9dcb66ce4..7f557b52b58c27933e5da0b6442d2144c1e3560a 100644 (file)
@@ -22,8 +22,9 @@ typedef GrDefaultGeoProcFactory Flag;
 class DefaultGeoProc : public GrGeometryProcessor {
 public:
     static GrGeometryProcessor* Create(GrColor color, uint8_t coverage, uint32_t gpTypeFlags,
-                                       bool opaqueVertexColors) {
-        return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueVertexColors));
+                                       bool opaqueVertexColors, const SkMatrix& localMatrix) {
+        return SkNEW_ARGS(DefaultGeoProc, (color, coverage, gpTypeFlags, opaqueVertexColors,
+                                           localMatrix));
     }
 
     virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; }
@@ -122,10 +123,11 @@ public:
                                   const GrGLCaps&,
                                   GrProcessorKeyBuilder* b) {
             const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
-            b->add32(def.fFlags);
-
             const BatchTracker& local = bt.cast<BatchTracker>();
-            b->add32(local.fInputColorType | local.fInputCoverageType << 16);
+            uint32_t key = def.fFlags;
+            key |= local.fInputColorType << 8 | local.fInputCoverageType << 16;
+            key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ? 0x1 << 24 : 0x0;
+            b->add32(key);
         }
 
         virtual void setData(const GrGLProgramDataManager& pdman,
@@ -164,8 +166,9 @@ public:
     }
 
 private:
-    DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool opaqueVertexColors)
-        : INHERITED(color, opaqueVertexColors)
+    DefaultGeoProc(GrColor color, uint8_t coverage, uint32_t gpTypeFlags, bool opaqueVertexColors,
+                   const SkMatrix& localMatrix)
+        : INHERITED(color, opaqueVertexColors, localMatrix)
         , fInPosition(NULL)
         , fInColor(NULL)
         , fInLocalCoords(NULL)
@@ -244,12 +247,14 @@ GrGeometryProcessor* DefaultGeoProc::TestCreate(SkRandom* random,
     }
 
     return DefaultGeoProc::Create(GrRandomColor(random), GrRandomCoverage(random),
-                                  flags, random->nextBool());
+                                  flags, random->nextBool(),
+                                  GrProcessorUnitTest::TestMatrix(random));
 }
 
 const GrGeometryProcessor* GrDefaultGeoProcFactory::Create(GrColor color,
                                                            uint32_t gpTypeFlags,
                                                            bool opaqueVertexColors,
-                                                           uint8_t coverage) {
-    return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColors);
+                                                           uint8_t coverage,
+                                                           const SkMatrix& localMatrix) {
+    return DefaultGeoProc::Create(color, coverage, gpTypeFlags, opaqueVertexColors, localMatrix);
 }
index f13ff85904463bbb66ca55e638dedd26ffbdf95b..b7db74d845f375940e606e732635bda1f2e8ad27 100644 (file)
@@ -83,7 +83,15 @@ public:
     static const GrGeometryProcessor* Create(GrColor,
                                              uint32_t gpTypeFlags = 0,
                                              bool opaqueVertexColors = false,
-                                             uint8_t coverage = 0xff);
+                                             uint8_t coverage = 0xff,
+                                             const SkMatrix& localMatrix = SkMatrix::I());
+
+    static const GrGeometryProcessor* Create(GrColor color,
+                                             uint32_t gpTypeFlags,
+                                             const SkMatrix& localMatrix) {
+        return Create(color, gpTypeFlags, false, 0xff, localMatrix);
+    }
+
     static size_t DefaultVertexStride() { return sizeof(PositionAttr); }
 };
 
index 68cd01c3d5ac38fb6248593255a52c5d434b76d8..643253efc0e05c1f77ca4a3252ff27fe772ad8cf 100644 (file)
@@ -112,24 +112,6 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
     fCoveragePrimProc = NULL;
 }
 
-bool GrDrawState::setIdentityViewMatrix()  {
-    if (this->numFragmentStages()) {
-        SkMatrix invVM;
-        if (!fViewMatrix.invert(&invVM)) {
-            // sad trombone sound
-            return false;
-        }
-        for (int s = 0; s < this->numColorStages(); ++s) {
-            fColorStages[s].localCoordChange(invVM);
-        }
-        for (int s = 0; s < this->numCoverageStages(); ++s) {
-            fCoverageStages[s].localCoordChange(invVM);
-        }
-    }
-    fViewMatrix.reset();
-    return true;
-}
-
 void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRenderTarget* rt) {
     SkASSERT(0 == fBlockEffectRemovalCnt || 0 == this->numFragmentStages());
 
index 24f987d0ce535147e166526d95d355d9af681545..36e2b3a2fb1f3fc3b86eb684542375b2cc5f1c1b 100644 (file)
@@ -303,12 +303,6 @@ public:
         return false;
     }
 
-    /**
-     * Sets the view matrix to identity and updates any installed effects to compensate for the
-     * coord system change.
-     */
-    bool setIdentityViewMatrix();
-
     ////////////////////////////////////////////////////////////////////////////
 
     /**
index 64cbc8781eba2048ead8e786bd9e87b3e6a1b883..d2c20a1eedf97f94b50cb0c4168e49061d94c96b 100644 (file)
@@ -303,10 +303,10 @@ public:
      * @param rect        the rect to draw
      * @param localRect   optional rect that specifies local coords to map onto
      *                    rect. If NULL then rect serves as the local coords.
-     * @param localMatrix optional matrix applied to localRect. If
-     *                    srcRect is non-NULL and srcMatrix is non-NULL
-     *                    then srcRect will be transformed by srcMatrix.
-     *                    srcMatrix can be NULL when no srcMatrix is desired.
+     * @param localMatrix Optional local matrix. The local coordinates are specified by localRect,
+     *                    or if it is NULL by rect. This matrix applies to the coordinate implied by
+     *                    that rectangle before it is input to GrCoordTransforms that read local
+     *                    coordinates
      */
     void drawRect(GrDrawState* ds,
                   GrColor color,
index dc074b7b511e5ebf95fe7a1c13df9f1b9cd4132b..6e5c1fe778d7b19d140a277c746e62868a52ad7e 100644 (file)
@@ -62,13 +62,18 @@ void get_vertex_bounds(const void* vertices,
 
     The vertex attrib order is always pos, color, [local coords].
  */
-static const GrGeometryProcessor* create_rect_gp(GrDrawState* drawState,
-                                                 bool hasLocalCoords,
-                                                 GrColor color) {
+static const GrGeometryProcessor* create_rect_gp(bool hasExplicitLocalCoords,
+                                                 GrColor color,
+                                                 const SkMatrix* localMatrix) {
     uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
                      GrDefaultGeoProcFactory::kColor_GPType;
-    flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
-    return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color));
+    flags |= hasExplicitLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
+    if (localMatrix) {
+        return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color), 0xff,
+                                               *localMatrix);
+    } else {
+        return GrDefaultGeoProcFactory::Create(color, flags, GrColorIsOpaque(color));
+    }
 }
 
 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettings) {
@@ -115,7 +120,11 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
                                      const SkMatrix* localMatrix) {
     GrDrawState::AutoRestoreEffects are(ds);
 
-    SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(ds, SkToBool(localRect), color));
+    bool hasExplicitLocalCoords = SkToBool(localRect);
+    SkAutoTUnref<const GrGeometryProcessor> gp(
+            create_rect_gp(hasExplicitLocalCoords,
+                           color,
+                           hasExplicitLocalCoords ? NULL : localMatrix));
 
     size_t vstride = gp->getVertexStride();
     SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) :
index 304d6d69adea0d60e8e092f488461a93639b600d..05838cf6e503a8ce0ee6f56c82bdb92850352e8d 100644 (file)
@@ -123,7 +123,9 @@ public:
                            GrProcessorKeyBuilder* b) {
             const BatchTracker& local = bt.cast<BatchTracker>();
             const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>();
-            b->add32(circleEffect.isStroked() << 16 | local.fInputColorType);
+            uint16_t key = circleEffect.isStroked() ? 0x1 : 0x0;
+            key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
+            b->add32(key << 16 | local.fInputColorType);
         }
 
         virtual void setData(const GrGLProgramDataManager& pdman,
@@ -306,7 +308,9 @@ public:
                            GrProcessorKeyBuilder* b) {
             const BatchTracker& local = bt.cast<BatchTracker>();
             const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>();
-            b->add32(ellipseEffect.isStroked() << 16 | local.fInputColorType);
+            uint16_t key = ellipseEffect.isStroked() ? 0x1 : 0x0;
+            key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x2 : 0x0;
+            b->add32(key << 16 | local.fInputColorType);
         }
 
         virtual void setData(const GrGLProgramDataManager& pdman,
@@ -510,7 +514,10 @@ public:
                            GrProcessorKeyBuilder* b) {
             const BatchTracker& local = bt.cast<BatchTracker>();
             const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>();
-            b->add32(ellipseEffect.getMode() << 16 | local.fInputColorType);
+            uint16_t key = ellipseEffect.getMode();
+            key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 8 :
+                                                                                        0x0;
+            b->add32(key << 16 | local.fInputColorType);
         }
 
         virtual void setData(const GrGLProgramDataManager& pdman,
@@ -1086,7 +1093,7 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target,
     if (applyAA) {
         bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
     }
-    target->drawRect(drawState, color, bounds, NULL, NULL);
+    target->drawSimpleRect(drawState, color, bounds);
     return true;
 }
 
index 2a4ef3692f5eb42f83e7a93185fe318c56f7965a..0ba7beeb88491e2a07ff7c7f66bc579544f7d1e3 100644 (file)
@@ -165,6 +165,7 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
     uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
     key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
     key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
+    key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
     b->add32(key);
 }
 
@@ -374,6 +375,7 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
     uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
     key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x0;
     key |= 0xff != local.fCoverageScale ? 0x8 : 0x0;
+    key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
     b->add32(key);
 }
 
@@ -605,6 +607,7 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
     const CubicBatchTracker& local = bt.cast<CubicBatchTracker>();
     uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
     key |= kUniform_GrGPInput == local.fInputColorType ? 0x4 : 0x8;
+    key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x10 : 0x0;
     b->add32(key);
 }
 
index 09eee1c70d1ba106be2843d0acf130a178798ae9..44de98a348d75f0b279aedcd9ed6d5b5b9fcca69 100644 (file)
@@ -75,8 +75,10 @@ public:
         // on addVertexAttrib.
         // TODO When we have deferred geometry we can fix this
         const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
-        b->add32(SkToBool(gp.inColor()));
-        b->add32(local.fInputColorType);
+        uint32_t key = 0;
+        key |= SkToBool(gp.inColor()) ? 0x1 : 0x0;
+        key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x2 : 0x0;
+        b->add32(local.fInputColorType << 16 | key);
     }
 
 private:
@@ -90,8 +92,10 @@ private:
 
 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture,
                                          const GrTextureParams& params, bool useColorAttrib,
-                                         bool opaqueVertexColors)
-    : INHERITED(color, opaqueVertexColors), fTextureAccess(texture, params), fInColor(NULL) {
+                                         bool opaqueVertexColors, const SkMatrix& localMatrix)
+    : INHERITED(color, opaqueVertexColors, localMatrix)
+    , fTextureAccess(texture, params)
+    , fInColor(NULL) {
     this->initClassID<GrBitmapTextGeoProc>();
     fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType));
     if (useColorAttrib) {
@@ -172,5 +176,6 @@ GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
                                                            GrTextureParams::kNone_FilterMode);
 
     return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx], params,
-                                       random->nextBool(), random->nextBool());
+                                       random->nextBool(), random->nextBool(),
+                                       GrProcessorUnitTest::TestMatrix(random));
 }
index 507515bedb2002f012ca828335967d6248f3b4a9..c69ffd7a1b72998b7483a47de450a7567772611d 100644 (file)
@@ -22,8 +22,10 @@ class GrInvariantOutput;
 class GrBitmapTextGeoProc : public GrGeometryProcessor {
 public:
     static GrGeometryProcessor* Create(GrColor color, GrTexture* tex, const GrTextureParams& p,
-                                       bool useColorAttrib, bool opaqueVertexColors) {
-        return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors));
+                                       bool useColorAttrib, bool opaqueVertexColors,
+                                       const SkMatrix& localMatrix) {
+        return SkNEW_ARGS(GrBitmapTextGeoProc, (color, tex, p, useColorAttrib, opaqueVertexColors,
+                                                localMatrix));
     }
 
     virtual ~GrBitmapTextGeoProc() {}
@@ -47,7 +49,7 @@ public:
 
 private:
     GrBitmapTextGeoProc(GrColor, GrTexture* texture, const GrTextureParams& params,
-                        bool useColorAttrib, bool opaqueVertexColors);
+                        bool useColorAttrib, bool opaqueVertexColors, const SkMatrix& localMatrix);
 
     virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE;
 
index 35b763788a229b2b5fff983364f4fcc051622a87..d5b0b48e9b4e843f4fcd8dcfbda45a0609da1207 100644 (file)
@@ -624,6 +624,7 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor,
                                    GrProcessorKeyBuilder* b) {
     const DashingCircleBatchTracker& local = bt.cast<DashingCircleBatchTracker>();
     const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
+    b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective());
     b->add32(dce.getEdgeType() << 16 | local.fInputColorType);
 }
 
@@ -913,6 +914,7 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor,
                                  GrProcessorKeyBuilder* b) {
     const DashingLineBatchTracker& local = bt.cast<DashingLineBatchTracker>();
     const DashingLineEffect& de = processor.cast<DashingLineEffect>();
+    b->add32(local.fUsesLocalCoords && processor.localMatrix().hasPerspective());
     b->add32(de.getEdgeType() << 16 | local.fInputColorType);
 }
 
index 0f930af371d151d131c5d665bf622f12b9e67c02..f5510d478ba9c915d72ff4bc7ef1dd8e18922193 100755 (executable)
@@ -166,8 +166,10 @@ public:
         const GrDistanceFieldTextureEffect& dfTexEffect =
                 processor.cast<GrDistanceFieldTextureEffect>();
         const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTracker>();
-        b->add32(dfTexEffect.getFlags());
-        b->add32(local.fInputColorType);
+        uint32_t key = dfTexEffect.getFlags();
+        key |= local.fInputColorType << 16;
+        key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+        b->add32(key);
     }
 
 private:
@@ -422,8 +424,10 @@ public:
             proc.cast<GrDistanceFieldNoGammaTextureEffect>();
 
         const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoGammaBatchTracker>();
-        b->add32(dfTexEffect.getFlags());
-        b->add32(local.fInputColorType);
+        uint32_t key = dfTexEffect.getFlags();
+        key |= local.fInputColorType << 16;
+        key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+        b->add32(key);
     }
 
 private:
@@ -724,8 +728,10 @@ public:
                 processor.cast<GrDistanceFieldLCDTextureEffect>();
 
         const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatchTracker>();
-        b->add32(dfTexEffect.getFlags());
-        b->add32(local.fInputColorType);
+        uint32_t key = dfTexEffect.getFlags();
+        key |= local.fInputColorType << 16;
+        key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective() ? 0x1 << 24: 0x0;
+        b->add32(key);
     }
 
 private:
index cfb1d38b6137e762feba29a9c4c87af24ae82dc6..13a14534cf42b03c8fe50f8b29b06d4bf7737605 100644 (file)
@@ -378,8 +378,22 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
 
     for (int t = 0; t < numTransforms; t++) {
         const char* uniName = "StageMatrix";
-        GrSLType varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType :
-                                                                      kVec2f_GrSLType;
+        GrSLType varyingType;
+
+        // TODO when we have deleted the coord change matrices we can get rid of the below check
+        GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
+        const SkMatrix& localMatrix = fOptState.getPrimitiveProcessor()->localMatrix();
+        if (localMatrix.isIdentity()) {
+            varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType :
+                                                                 kVec2f_GrSLType;
+        } else {
+            uint32_t type = processor->coordTransform(t).getMatrix().getType();
+            if (kLocal_GrCoordSet == coordType) {
+                type |= localMatrix.getType();
+            }
+            varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
+                                                                         kVec2f_GrSLType;
+        }
         GrSLPrecision precision = processor->coordTransform(t).precision();
 
         SkString suffixedUniName;
@@ -401,7 +415,6 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
             varyingName = suffixedVaryingName.c_str();
         }
 
-        GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
         GrGLVertToFrag v(varyingType);
         this->addVarying(varyingName, &v, precision);
         fCoordVaryings.push_back(TransformVarying(v, uniName, coordType));