diff options
Diffstat (limited to 'src/gpu/GrDefaultGeoProcFactory.cpp')
-rw-r--r-- | src/gpu/GrDefaultGeoProcFactory.cpp | 127 |
1 files changed, 10 insertions, 117 deletions
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 788833ed8c..e2bf87b277 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -27,13 +27,8 @@ enum GPFlag { 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 @@ public: const SkMatrix& viewMatrix, const SkMatrix& localMatrix, bool localCoordsWillBeRead, - uint8_t coverage, - const float* 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 @@ public: bool localCoordsWillBeRead() const { return fLocalCoordsWillBeRead; } uint8_t coverage() const { return fCoverage; } bool hasVertexCoverage() const { return fInCoverage.isInitialized(); } - const float* bones() const { return fBones; } - int boneCount() const { return fBoneCount; } - bool hasBones() const { return SkToBool(fBones); } class GLSLProcessor : public GrGLSLGeometryProcessor { public: @@ -109,37 +99,11 @@ public: &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 @@ public: 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 @@ public: 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 @@ public: UniformHandle fViewMatrixUniform; UniformHandle fColorUniform; UniformHandle fCoverageUniform; - UniformHandle fBonesUniform; GrGLSLColorSpaceXformHelper fColorSpaceHelper; typedef GrGLSLGeometryProcessor INHERITED; @@ -250,9 +209,7 @@ private: const SkMatrix& viewMatrix, const SkMatrix& localMatrix, uint8_t coverage, - bool localCoordsWillBeRead, - const float* bones, - int boneCount) + bool localCoordsWillBeRead) : INHERITED(kDefaultGeoProc_ClassID) , fColor(color) , fViewMatrix(viewMatrix) @@ -260,9 +217,7 @@ private: , fCoverage(coverage) , fFlags(gpTypeFlags) , fLocalCoordsWillBeRead(localCoordsWillBeRead) - , fColorSpaceXform(std::move(colorSpaceXform)) - , fBones(bones) - , fBoneCount(boneCount) { + , fColorSpaceXform(std::move(colorSpaceXform)) { fInPosition = {"inPosition", kFloat2_GrVertexAttribType}; int cnt = 1; if (fFlags & kColorAttribute_GPFlag) { @@ -277,32 +232,17 @@ private: 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); } 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; @@ -310,8 +250,6 @@ private: uint32_t fFlags; bool fLocalCoordsWillBeRead; sk_sp<GrColorSpaceXform> fColorSpaceXform; - const float* fBones; - int fBoneCount; GR_DECLARE_GEOMETRY_PROCESSOR_TEST @@ -321,14 +259,6 @@ private: GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DefaultGeoProc); #if GR_TEST_UTILS -static constexpr int kTestBoneCount = 4; -static constexpr float kTestBones[kTestBoneCount * kNumFloatsPerSkMatrix] = { - 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -}; - sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) { uint32_t flags = 0; if (d->fRandom->nextBool()) { @@ -343,9 +273,6 @@ sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) { if (d->fRandom->nextBool()) { flags |= kLocalCoordAttribute_GPFlag; } - if (d->fRandom->nextBool()) { - flags |= kBonesAttribute_GPFlag; - } return DefaultGeoProc::Make(flags, GrRandomColor(d->fRandom), @@ -353,9 +280,7 @@ sk_sp<GrGeometryProcessor> DefaultGeoProc::TestCreate(GrProcessorTestData* d) { GrTest::TestMatrix(d->fRandom), GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool(), - GrRandomCoverage(d->fRandom), - kTestBones, - kTestBoneCount); + GrRandomCoverage(d->fRandom)); } #endif @@ -382,9 +307,7 @@ sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::Make(const Color& color, viewMatrix, localCoords.fMatrix ? *localCoords.fMatrix : SkMatrix::I(), localCoordsWillBeRead, - inCoverage, - nullptr, - 0); + inCoverage); } sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace( @@ -407,33 +330,3 @@ sk_sp<GrGeometryProcessor> GrDefaultGeoProcFactory::MakeForDeviceSpace( 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); -} |