Revert "added skeletal animation support to GPU backend"

This reverts commit b6307340e8a6a9d3a7517def7f5eaaadffd07d14.

Reason for revert: patch/atlas failing in gold

Original change's description:
> added skeletal animation support to GPU backend
> 
> added caching of SkVertices
> 
> Docs-Preview: https://skia.org/?cl=138596
> Bug: skia:
> Change-Id: Ia750f55f5f6d0de250d9e9c5619f4d1ac856f9f5
> Reviewed-on: https://skia-review.googlesource.com/138596
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Ruiqi Mao <ruiqimao@google.com>

TBR=robertphillips@google.com,brianosman@google.com,reed@google.com,ruiqimao@google.com

Change-Id: Idfaf016a7ff4cdd8af2543d510706f489d04417a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/139281
Reviewed-by: Ruiqi Mao <ruiqimao@google.com>
Commit-Queue: Ruiqi Mao <ruiqimao@google.com>
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index c9108e3..e2bf87b 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -27,13 +27,8 @@
     kColorAttributeIsSkColor_GPFlag = 0x2,
     kLocalCoordAttribute_GPFlag     = 0x4,
     kCoverageAttribute_GPFlag       = 0x8,
-    kBonesAttribute_GPFlag          = 0x10,
 };
 
-static constexpr int kNumFloatsPerSkMatrix = 9;
-static constexpr int kMaxBones = 100; // Due to GPU memory limitations, only up to 100 bone
-                                      // matrices are accepted.
-
 class DefaultGeoProc : public GrGeometryProcessor {
 public:
     static sk_sp<GrGeometryProcessor> Make(uint32_t gpTypeFlags,
@@ -42,12 +37,10 @@
                                            const SkMatrix& viewMatrix,
                                            const SkMatrix& localMatrix,
                                            bool localCoordsWillBeRead,
-                                           uint8_t coverage,
-                                           const SkMatrix bones[],
-                                           int boneCount) {
+                                           uint8_t coverage) {
         return sk_sp<GrGeometryProcessor>(new DefaultGeoProc(
                 gpTypeFlags, color, std::move(colorSpaceXform), viewMatrix, localMatrix, coverage,
-                localCoordsWillBeRead, bones, boneCount));
+                localCoordsWillBeRead));
     }
 
     const char* name() const override { return "DefaultGeometryProcessor"; }
@@ -59,9 +52,6 @@
     bool localCoordsWillBeRead() const { return fLocalCoordsWillBeRead; }
     uint8_t coverage() const { return fCoverage; }
     bool hasVertexCoverage() const { return fInCoverage.isInitialized(); }
-    const float* bones() const { return fBones.data(); }
-    int boneCount() const { return fBones.size() / kNumFloatsPerSkMatrix; }
-    bool hasBones() const { return fBones.size() > 0; }
 
     class GLSLProcessor : public GrGLSLGeometryProcessor {
     public:
@@ -109,37 +99,11 @@
                                         &fColorUniform);
             }
 
-            // Setup bone transforms
-            const char* transformedPositionName = gp.fInPosition.name();
-            if (gp.hasBones()) {
-                const char* vertBonesUniformName;
-                fBonesUniform = uniformHandler->addUniformArray(kVertex_GrShaderFlag,
-                                                                kFloat3x3_GrSLType,
-                                                                "Bones",
-                                                                kMaxBones,
-                                                                &vertBonesUniformName);
-                vertBuilder->codeAppendf(
-                        "float2 transformedPosition = (%s[0] * float3(%s, 1)).xy;"
-                        "float3x3 influence = float3x3(0);"
-                        "for (int i = 0; i < 4; i++) {"
-                        "   int index = %s[i];"
-                        "   float weight = %s[i];"
-                        "   influence += %s[index] * weight;"
-                        "}"
-                        "transformedPosition = (influence * float3(transformedPosition, 1)).xy;",
-                        vertBonesUniformName,
-                        gp.fInPosition.name(),
-                        gp.fInBoneIndices.name(),
-                        gp.fInBoneWeights.name(),
-                        vertBonesUniformName);
-                transformedPositionName = "transformedPosition";
-            }
-
             // Setup position
             this->writeOutputPosition(vertBuilder,
                                       uniformHandler,
                                       gpArgs,
-                                      transformedPositionName,
+                                      gp.fInPosition.name(),
                                       gp.viewMatrix(),
                                       &fViewMatrixUniform);
 
@@ -183,8 +147,8 @@
                                   GrProcessorKeyBuilder* b) {
             const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
             uint32_t key = def.fFlags;
-            key |= (def.coverage() == 0xff) ? 0x20 : 0;
-            key |= (def.localCoordsWillBeRead() && def.localMatrix().hasPerspective()) ? 0x40 : 0x0;
+            key |= (def.coverage() == 0xff) ? 0x10 : 0;
+            key |= (def.localCoordsWillBeRead() && def.localMatrix().hasPerspective()) ? 0x20 : 0x0;
             key |= ComputePosKey(def.viewMatrix()) << 20;
             b->add32(key);
             b->add32(GrColorSpaceXform::XformKey(def.fColorSpaceXform.get()));
@@ -216,10 +180,6 @@
             this->setTransformDataHelper(dgp.fLocalMatrix, pdman, &transformIter);
 
             fColorSpaceHelper.setData(pdman, dgp.fColorSpaceXform.get());
-
-            if (dgp.hasBones()) {
-                pdman.setMatrix3fv(fBonesUniform, dgp.boneCount(), dgp.bones());
-            }
         }
 
     private:
@@ -229,7 +189,6 @@
         UniformHandle fViewMatrixUniform;
         UniformHandle fColorUniform;
         UniformHandle fCoverageUniform;
-        UniformHandle fBonesUniform;
         GrGLSLColorSpaceXformHelper fColorSpaceHelper;
 
         typedef GrGLSLGeometryProcessor INHERITED;
@@ -250,9 +209,7 @@
                    const SkMatrix& viewMatrix,
                    const SkMatrix& localMatrix,
                    uint8_t coverage,
-                   bool localCoordsWillBeRead,
-                   const SkMatrix* bones,
-                   int boneCount)
+                   bool localCoordsWillBeRead)
             : INHERITED(kDefaultGeoProc_ClassID)
             , fColor(color)
             , fViewMatrix(viewMatrix)
@@ -260,8 +217,7 @@
             , fCoverage(coverage)
             , fFlags(gpTypeFlags)
             , fLocalCoordsWillBeRead(localCoordsWillBeRead)
-            , fColorSpaceXform(std::move(colorSpaceXform))
-            , fBones() {
+            , fColorSpaceXform(std::move(colorSpaceXform)) {
         fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
         int cnt = 1;
         if (fFlags & kColorAttribute_GPFlag) {
@@ -276,49 +232,17 @@
             fInCoverage = {"inCoverage", kHalf_GrVertexAttribType};
             ++cnt;
         }
-        if (fFlags & kBonesAttribute_GPFlag) {
-            SkASSERT(bones && (boneCount > 0));
-            fInBoneIndices = {"inBoneIndices", kInt4_GrVertexAttribType};
-            ++cnt;
-            fInBoneWeights = {"inBoneWeights", kFloat4_GrVertexAttribType};
-            ++cnt;
-        }
         this->setVertexAttributeCnt(cnt);
-
-        // Set bone data
-        if (bones) {
-            fBones.reserve(boneCount * kNumFloatsPerSkMatrix);
-            for (int i = 0; i < boneCount; i ++) {
-                const SkMatrix& matrix = bones[i];
-                fBones.push_back(matrix.get(SkMatrix::kMScaleX));
-                fBones.push_back(matrix.get(SkMatrix::kMSkewY));
-                fBones.push_back(matrix.get(SkMatrix::kMPersp0));
-                fBones.push_back(matrix.get(SkMatrix::kMSkewX));
-                fBones.push_back(matrix.get(SkMatrix::kMScaleY));
-                fBones.push_back(matrix.get(SkMatrix::kMPersp1));
-                fBones.push_back(matrix.get(SkMatrix::kMTransX));
-                fBones.push_back(matrix.get(SkMatrix::kMTransY));
-                fBones.push_back(matrix.get(SkMatrix::kMPersp2));
-            }
-        }
     }
 
     const Attribute& onVertexAttribute(int i) const override {
-        return IthInitializedAttribute(i,
-                                       fInPosition,
-                                       fInColor,
-                                       fInLocalCoords,
-                                       fInCoverage,
-                                       fInBoneIndices,
-                                       fInBoneWeights);
+        return IthInitializedAttribute(i, fInPosition, fInColor, fInLocalCoords, fInCoverage);
     }
 
     Attribute fInPosition;
     Attribute fInColor;
     Attribute fInLocalCoords;
     Attribute fInCoverage;
-    Attribute fInBoneIndices;
-    Attribute fInBoneWeights;
     GrColor fColor;
     SkMatrix fViewMatrix;
     SkMatrix fLocalMatrix;
@@ -326,7 +250,6 @@
     uint32_t fFlags;
     bool fLocalCoordsWillBeRead;
     sk_sp<GrColorSpaceXform> fColorSpaceXform;
-    std::vector<float> fBones;
 
     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
 
@@ -350,17 +273,6 @@
     if (d->fRandom->nextBool()) {
         flags |= kLocalCoordAttribute_GPFlag;
     }
-    if (d->fRandom->nextBool()) {
-        flags |= kBonesAttribute_GPFlag;
-    }
-
-    int numBones = d->fRandom->nextRangeU(0, kMaxBones);
-    std::vector<SkMatrix> bones(numBones);
-    for (int i = 0; i < numBones; i++) {
-        for (int j = 0; j < kNumFloatsPerSkMatrix; j++) {
-            bones[i][j] = d->fRandom->nextF();
-        }
-    }
 
     return DefaultGeoProc::Make(flags,
                                 GrRandomColor(d->fRandom),
@@ -368,9 +280,7 @@
                                 GrTest::TestMatrix(d->fRandom),
                                 GrTest::TestMatrix(d->fRandom),
                                 d->fRandom->nextBool(),
-                                GrRandomCoverage(d->fRandom),
-                                bones.data(),
-                                numBones);
+                                GrRandomCoverage(d->fRandom));
 }
 #endif
 
@@ -397,9 +307,7 @@
                                 viewMatrix,
                                 localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
                                 localCoordsWillBeRead,
-                                inCoverage,
-                                nullptr,
-                                0);
+                                inCoverage);
 }
 
 sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace(
@@ -422,33 +330,3 @@
     LocalCoords inverted(LocalCoords::kUsePosition_Type, &invert);
     return Make(color, coverage, inverted, SkMatrix::I());
 }
-
-sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeWithBones(const Color& color,
-                                                                  const Coverage& coverage,
-                                                                  const LocalCoords& localCoords,
-                                                                  const Bones& bones,
-                                                                  const SkMatrix& viewMatrix) {
-    uint32_t flags = 0;
-    if (Color::kPremulGrColorAttribute_Type == color.fType) {
-        flags |= kColorAttribute_GPFlag;
-    } else if (Color::kUnpremulSkColorAttribute_Type == color.fType) {
-        flags |= kColorAttribute_GPFlag | kColorAttributeIsSkColor_GPFlag;
-    }
-    flags |= coverage.fType == Coverage::kAttribute_Type ? kCoverageAttribute_GPFlag : 0;
-    flags |= localCoords.fType == LocalCoords::kHasExplicit_Type ? kLocalCoordAttribute_GPFlag : 0;
-    flags |= kBonesAttribute_GPFlag;
-
-    uint8_t inCoverage = coverage.fCoverage;
-    bool localCoordsWillBeRead = localCoords.fType != LocalCoords::kUnused_Type;
-
-    GrColor inColor = color.fColor;
-    return DefaultGeoProc::Make(flags,
-                                inColor,
-                                color.fColorSpaceXform,
-                                viewMatrix,
-                                localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(),
-                                localCoordsWillBeRead,
-                                inCoverage,
-                                bones.fBones,
-                                bones.fBoneCount);
-}