diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrFragmentProcessor.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrFragmentProcessor.h | 12 | ||||
-rw-r--r-- | src/gpu/GrPaint.h | 8 | ||||
-rw-r--r-- | src/gpu/GrPipeline.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrPipeline.h | 10 | ||||
-rw-r--r-- | src/gpu/GrPrimitiveProcessor.h | 4 | ||||
-rw-r--r-- | src/gpu/GrProcessorSet.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrProcessorSet.h | 4 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 1 | ||||
-rw-r--r-- | src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp | 13 | ||||
-rw-r--r-- | src/gpu/effects/GrBlurredEdgeFragmentProcessor.h | 3 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentProcessor.cpp | 3 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentProcessor.h | 28 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp | 4 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.h | 6 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLPrimitiveProcessor.h | 3 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLProgramBuilder.cpp | 15 | ||||
-rw-r--r-- | src/gpu/ops/GrAnalyticRectOp.cpp | 31 | ||||
-rw-r--r-- | src/gpu/ops/GrOvalOpFactory.cpp | 74 | ||||
-rw-r--r-- | src/gpu/ops/GrOvalOpFactory.h | 1 | ||||
-rw-r--r-- | src/gpu/ops/GrRectOpFactory.h | 6 |
21 files changed, 34 insertions, 201 deletions
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp index 70de1650ed..d69b34d94d 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -81,9 +81,6 @@ int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child if (child->usesLocalCoords()) { fFlags |= kUsesLocalCoords_Flag; } - if (child->usesDistanceVectorField()) { - fFlags |= kUsesDistanceVectorField_Flag; - } int index = fChildProcessors.count(); fChildProcessors.push_back(child.release()); diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h index ec8f317381..a4b28c21c0 100644 --- a/src/gpu/GrFragmentProcessor.h +++ b/src/gpu/GrFragmentProcessor.h @@ -114,11 +114,6 @@ public: /** Do any of the coordtransforms for this processor require local coords? */ bool usesLocalCoords() const { return SkToBool(fFlags & kUsesLocalCoords_Flag); } - /** Does this FP need a vector to the nearest edge? */ - bool usesDistanceVectorField() const { - return SkToBool(fFlags & kUsesDistanceVectorField_Flag); - } - /** * A GrDrawOp may premultiply its antialiasing coverage into its GrGeometryProcessor's color * output under the following scenario: @@ -295,12 +290,6 @@ protected: */ int registerChildProcessor(sk_sp<GrFragmentProcessor> child); - /** - * Sub-classes should call this in their constructors if they need access to a distance - * vector field to the nearest edge - */ - void setWillUseDistanceVectorField() { fFlags |= kUsesDistanceVectorField_Flag; } - private: void addPendingIOs() const override { GrResourceIOProcessor::addPendingIOs(); } void removeRefs() const override { GrResourceIOProcessor::removeRefs(); } @@ -334,7 +323,6 @@ private: enum PrivateFlags { kFirstPrivateFlag = kAll_OptimizationFlags + 1, kUsesLocalCoords_Flag = kFirstPrivateFlag, - kUsesDistanceVectorField_Flag = kFirstPrivateFlag << 1, }; mutable uint32_t fFlags = 0; diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h index 6fe561ab33..e2b494ff6f 100644 --- a/src/gpu/GrPaint.h +++ b/src/gpu/GrPaint.h @@ -70,11 +70,6 @@ public: bool getAllowSRGBInputs() const { return fAllowSRGBInputs; } /** - * Does one of the fragment processors need a field of distance vectors to the nearest edge? - */ - bool usesDistanceVectorField() const { return fUsesDistanceVectorField; } - - /** * Should rendering be gamma-correct, end-to-end. Causes sRGB render targets to behave * as such (with linear blending), and sRGB inputs to be filtered and decoded correctly. */ @@ -97,7 +92,6 @@ public: */ void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { SkASSERT(fp); - fUsesDistanceVectorField |= fp->usesDistanceVectorField(); fColorFragmentProcessors.push_back(std::move(fp)); fTrivial = false; } @@ -107,7 +101,6 @@ public: */ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) { SkASSERT(fp); - fUsesDistanceVectorField |= fp->usesDistanceVectorField(); fCoverageFragmentProcessors.push_back(std::move(fp)); fTrivial = false; } @@ -182,7 +175,6 @@ private: SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors; bool fDisableOutputConversionToSRGB = false; bool fAllowSRGBInputs = false; - bool fUsesDistanceVectorField = false; bool fTrivial = true; GrColor4f fColor = GrColor4f::OpaqueWhite(); }; diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 394d545242..8d1b926be1 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -33,9 +33,6 @@ void GrPipeline::init(const InitArgs& args) { } fWindowRectsState = args.fAppliedClip->windowRectsState(); } - if (args.fProcessors->usesDistanceVectorField()) { - fFlags |= kUsesDistanceVectorField_Flag; - } if (!args.fUserStencil->isDisabled(fFlags & kHasStencilClip_Flag)) { fFlags |= kStencilEnabled_Flag; } diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 4f2f010188..078cb68437 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -212,9 +212,6 @@ public: bool getAllowSRGBInputs() const { return SkToBool(fFlags & kAllowSRGBInputs_Flag); } - bool usesDistanceVectorField() const { - return SkToBool(fFlags & kUsesDistanceVectorField_Flag); - } bool hasStencilClip() const { return SkToBool(fFlags & kHasStencilClip_Flag); } @@ -236,10 +233,9 @@ private: /** This is a continuation of the public "Flags" enum. */ enum PrivateFlags { - kUsesDistanceVectorField_Flag = 0x10, - kHasStencilClip_Flag = 0x20, - kStencilEnabled_Flag = 0x40, - kIsBad_Flag = 0x80, + kHasStencilClip_Flag = 0x10, + kStencilEnabled_Flag = 0x20, + kIsBad_Flag = 0x40, }; using RenderTarget = GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>; diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index 63265f02a6..3b90689aca 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -114,10 +114,6 @@ public: return 0.0; } - /* Sub-class should override and return true if this primitive processor implements the distance - * vector field, a field of vectors to the nearest point in the edge of the shape. */ - virtual bool implementsDistanceVector() const { return false; } - protected: /** * Subclasses call these from their constructor to register vertex and instance attributes. diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp index 22fa63589f..01de53d94d 100644 --- a/src/gpu/GrProcessorSet.cpp +++ b/src/gpu/GrProcessorSet.cpp @@ -28,9 +28,6 @@ GrProcessorSet::GrProcessorSet(GrPaint&& paint) : fXP(paint.getXPFactory()) { for (auto& fp : paint.fCoverageFragmentProcessors) { fFragmentProcessors[i++] = fp.release(); } - if (paint.usesDistanceVectorField()) { - fFlags |= kUseDistanceVectorField_Flag; - } } else { SkDebugf("Insane number of color fragment processors in paint. Dropping all processors."); fColorFragmentProcessorCnt = 0; diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h index b13175ab10..d7cecedc47 100644 --- a/src/gpu/GrProcessorSet.h +++ b/src/gpu/GrProcessorSet.h @@ -52,8 +52,6 @@ public: return sk_ref_sp(fXP.fProcessor); } - bool usesDistanceVectorField() const { return SkToBool(fFlags & kUseDistanceVectorField_Flag); } - /** Comparisons are only legal on finalized processor sets. */ bool operator==(const GrProcessorSet& that) const; bool operator!=(const GrProcessorSet& that) const { return !(*this == that); } @@ -143,7 +141,7 @@ private: // This absurdly large limit allows Analysis and this to pack fields together. static constexpr int kMaxColorProcessors = UINT8_MAX; - enum Flags : uint16_t { kUseDistanceVectorField_Flag = 0x1, kFinalized_Flag = 0x2 }; + enum Flags : uint16_t { kFinalized_Flag = 0x1 }; union XP { XP(const GrXPFactory* factory) : fFactory(factory) {} diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index c72c4d1d6f..0bbfbf65b3 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -929,7 +929,6 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip, if (GrAAType::kCoverage == aaType) { const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeRRectOp(std::move(paint), - paint.usesDistanceVectorField(), viewMatrix, rrect, stroke, diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp index a37c173c0b..1996a942c2 100644 --- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp +++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp @@ -21,17 +21,8 @@ public: GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor); - if (!args.fGpImplementsDistanceVector) { - fragBuilder->codeAppendf("// assuming interpolant is set in vertex colors\n"); - fragBuilder->codeAppendf("float factor = 1.0 - color.a;"); - } else { - fragBuilder->codeAppendf("// using distance to edge to compute interpolant\n"); - fragBuilder->codeAppend("float radius = color.r*256.0*64.0 + color.g*64.0;"); - fragBuilder->codeAppend("float pad = color.b*64.0;"); - - fragBuilder->codeAppendf("float factor = 1.0 - clamp((%s.z - pad)/radius, 0.0, 1.0);", - fragBuilder->distanceVectorName()); - } + fragBuilder->codeAppendf("// assuming interpolant is set in vertex colors\n"); + fragBuilder->codeAppendf("float factor = 1.0 - color.a;"); switch (mode) { case GrBlurredEdgeFP::kGaussian_Mode: fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;"); diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h index d0864ed864..cfcc17adaf 100644 --- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h +++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h @@ -46,9 +46,6 @@ private: GrBlurredEdgeFP(Mode mode) : INHERITED(kNone_OptimizationFlags) , fMode(mode) { - // enable output of distance information for shape - this->setWillUseDistanceVectorField(); - this->initClassID<GrBlurredEdgeFP>(); } diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp index 28e5a211a8..006fe587f7 100644 --- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp +++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp @@ -59,8 +59,7 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu coordVars, textureSamplers, texelBuffers, - imageStorages, - args.fGpImplementsDistanceVector); + imageStorages); this->childProcessor(childIndex)->emitCode(childArgs); fragBuilder->codeAppend("}\n"); diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h index fe7775a9c4..355d490225 100644 --- a/src/gpu/glsl/GrGLSLFragmentProcessor.h +++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h @@ -105,9 +105,6 @@ public: @param imageStorages Contains one entry for each ImageStorageAccess of the GrProcessor. These can be passed to the builder to emit image loads and stores in the generated code. - @param gpImplementsDistanceVector - Does the GrGeometryProcessor implement the feature where it - provides a vector to the nearest edge of the shape being rendered. */ struct EmitArgs { EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder, @@ -119,19 +116,17 @@ public: const TransformedCoordVars& transformedCoordVars, const TextureSamplers& textureSamplers, const TexelBuffers& texelBuffers, - const ImageStorages& imageStorages, - bool gpImplementsDistanceVector) - : fFragBuilder(fragBuilder) - , fUniformHandler(uniformHandler) - , fShaderCaps(caps) - , fFp(fp) - , fOutputColor(outputColor) - , fInputColor(inputColor) - , fTransformedCoords(transformedCoordVars) - , fTexSamplers(textureSamplers) - , fTexelBuffers(texelBuffers) - , fImageStorages(imageStorages) - , fGpImplementsDistanceVector(gpImplementsDistanceVector) {} + const ImageStorages& imageStorages) + : fFragBuilder(fragBuilder) + , fUniformHandler(uniformHandler) + , fShaderCaps(caps) + , fFp(fp) + , fOutputColor(outputColor) + , fInputColor(inputColor) + , fTransformedCoords(transformedCoordVars) + , fTexSamplers(textureSamplers) + , fTexelBuffers(texelBuffers) + , fImageStorages(imageStorages) {} GrGLSLFPFragmentBuilder* fFragBuilder; GrGLSLUniformHandler* fUniformHandler; const GrShaderCaps* fShaderCaps; @@ -142,7 +137,6 @@ public: const TextureSamplers& fTexSamplers; const TexelBuffers& fTexelBuffers; const ImageStorages& fImageStorages; - bool fGpImplementsDistanceVector; }; virtual void emitCode(EmitArgs&) = 0; diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp index 484bd78211..4fd886b4fb 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp @@ -124,10 +124,6 @@ SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords) return coords2D; } -const char* GrGLSLFragmentShaderBuilder::distanceVectorName() const { - return "fsDistanceVector"; -} - void GrGLSLFragmentShaderBuilder::appendOffsetToSample(const char* sampleIdx, Coordinates coords) { SkASSERT(fProgramBuilder->header().fSamplePatternKey); SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kSampleLocations_RequiredFeature); diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h index 65bcb8dae6..73fe51f171 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h @@ -89,10 +89,6 @@ public: */ virtual void maskSampleCoverage(const char* mask, bool invert = false) = 0; - /** Returns a variable name that represents a vector to the nearest edge of the shape, in source - space coordinates. */ - virtual const char* distanceVectorName() const = 0; - /** * Overrides the default precision for the entire fragment program. Processors that require * high precision input (eg from incoming texture samples) may use this. For calculations that @@ -168,7 +164,6 @@ public: // Shared GrGLSLFragmentBuilder interface. bool enableFeature(GLSLFeature) override; virtual SkString ensureCoords2D(const GrShaderVar&) override; - const char* distanceVectorName() const override; // GrGLSLFPFragmentBuilder interface. void appendOffsetToSample(const char* sampleIdx, Coordinates) override; @@ -239,7 +234,6 @@ private: bool fHasSecondaryOutput; uint8_t fUsedSampleOffsetArrays; bool fHasInitializedSampleMask; - SkString fDistanceVectorOutput; GrSLPrecision fDefaultPrecision; #ifdef SK_DEBUG diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h index 2443f4745e..c4f3115f5a 100644 --- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.h +++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.h @@ -75,7 +75,6 @@ public: const GrPrimitiveProcessor& gp, const char* outputColor, const char* outputCoverage, - const char* distanceVectorName, const char* rtAdjustName, const SamplerHandle* texSamplers, const TexelBufferHandle* texelBuffers, @@ -90,7 +89,6 @@ public: , fGP(gp) , fOutputColor(outputColor) , fOutputCoverage(outputCoverage) - , fDistanceVectorName(distanceVectorName) , fRTAdjustName(rtAdjustName) , fTexSamplers(texSamplers) , fTexelBuffers(texelBuffers) @@ -105,7 +103,6 @@ public: const GrPrimitiveProcessor& fGP; const char* fOutputColor; const char* fOutputCoverage; - const char* fDistanceVectorName; const char* fRTAdjustName; const SamplerHandle* fTexSamplers; const TexelBufferHandle* fTexelBuffers; diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp index 337ee6d0ea..0d87c4f5a2 100644 --- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp +++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp @@ -76,17 +76,6 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr this->nameExpression(outputColor, "outputColor"); this->nameExpression(outputCoverage, "outputCoverage"); - const char* distanceVectorName = nullptr; - if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVector()) { - // Each individual user (FP) of the distance vector must be able to handle having this - // variable be undeclared. There is no single default value that will yield a reasonable - // result for all users. - distanceVectorName = fFS.distanceVectorName(); - fFS.codeAppend( "// Normalized vector to the closest geometric edge (in device space)\n"); - fFS.codeAppend( "// Distance to the edge encoded in the z-component\n"); - fFS.codeAppendf("vec4 %s;", distanceVectorName); - } - SkASSERT(!fUniformHandles.fRTAdjustmentUni.isValid()); GrShaderFlags rtAdjustVisibility = kVertex_GrShaderFlag; if (proc.willUseGeoShader()) { @@ -124,7 +113,6 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr proc, outputColor->c_str(), outputCoverage->c_str(), - distanceVectorName, rtAdjustName, texSamplers.begin(), texelBuffers.begin(), @@ -199,8 +187,7 @@ SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& coords, textureSamplers, texelBuffers, - imageStorages, - this->primitiveProcessor().implementsDistanceVector()); + imageStorages); fragProc->emitCode(args); diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index 358b5622e3..f62f0c628e 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -60,8 +60,6 @@ public: fInWidthHeight = &this->addVertexAttrib("inWidthHeight", kVec2f_GrVertexAttribType); } - bool implementsDistanceVector() const override { return true; } - const Attribute* inPosition() const { return fInPosition; } const Attribute* inColor() const { return fInColor; } const Attribute* inRectEdge() const { return fInRectEdge; } @@ -141,46 +139,17 @@ public: fragBuilder->codeAppendf("float perpDot = abs(offset.x * %s.w - offset.y * %s.z);", rectEdgeVary.fsIn(), rectEdgeVary.fsIn()); - if (args.fDistanceVectorName) { - fragBuilder->codeAppendf("float widthDistance = %s.x - perpDot;", - widthHeightVary.fsIn()); - } - fragBuilder->codeAppendf( "float coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0);", widthHeightVary.fsIn()); // Compute the coverage for the rect's height and merge with the width fragBuilder->codeAppendf("perpDot = abs(dot(offset, %s.zw));", rectEdgeVary.fsIn()); - if (args.fDistanceVectorName) { - fragBuilder->codeAppendf("float heightDistance = %s.y - perpDot;", - widthHeightVary.fsIn()); - } - fragBuilder->codeAppendf( "coverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0.0, 1.0);", widthHeightVary.fsIn()); fragBuilder->codeAppendf("%s = vec4(coverage);", args.fOutputCoverage); - - if (args.fDistanceVectorName) { - fragBuilder->codeAppend("// Calculating distance vector\n"); - fragBuilder->codeAppend("vec2 dvAxis;"); - fragBuilder->codeAppend("float dvLength;"); - - fragBuilder->codeAppend("if (heightDistance < widthDistance) {"); - fragBuilder->codeAppendf(" dvAxis = %s.zw;", rectEdgeVary.fsIn()); - fragBuilder->codeAppend(" dvLength = heightDistance;"); - fragBuilder->codeAppend("} else {"); - fragBuilder->codeAppendf(" dvAxis = vec2(-%s.w, %s.z);", rectEdgeVary.fsIn(), - rectEdgeVary.fsIn()); - fragBuilder->codeAppend(" dvLength = widthDistance;"); - fragBuilder->codeAppend("}"); - - fragBuilder->codeAppend("float dvSign = sign(dot(offset, dvAxis));"); - fragBuilder->codeAppendf("%s = vec4(dvSign * dvAxis, dvLength, 0.0);", - args.fDistanceVectorName); - } } static void GenKey(const GrGeometryProcessor& gp, diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 174dc4015e..2b9d1c8e56 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -57,12 +57,6 @@ static inline bool circle_stays_circle(const SkMatrix& m) { return m.isSimilarit * p is the position in the normalized space. * outerRad is the outerRadius in device space. * innerRad is the innerRadius in normalized space (ignored if not stroking). - * If fUsesDistanceVectorField is set in fragment processors in the same program, then - * an additional vertex attribute is available via args.fFragBuilder->distanceVectorName(): - * vec4f : (v.xy, outerDistance, innerDistance) - * v is a normalized vector pointing to the outer edge - * outerDistance is the distance to the outer edge, < 0 if we are outside of the shape - * if stroking, innerDistance is the distance to the inner edge, < 0 if outside * Additional clip planes are supported for rendering circular arcs. The additional planes are * either intersected or unioned together. Up to three planes are supported (an initial plane, * a plane intersected with the initial plane, and a plane unioned with the first two). Only two @@ -99,8 +93,6 @@ public: fStroke = stroke; } - bool implementsDistanceVector() const override { return !fInClipPlane; } - ~CircleGeometryProcessor() override {} const char* name() const override { return "CircleEdge"; } @@ -170,21 +162,6 @@ private: fragBuilder->codeAppend("edgeAlpha *= innerAlpha;"); } - if (args.fDistanceVectorName) { - const char* innerEdgeDistance = cgp.fStroke ? "distanceToInnerEdge" : "0.0"; - fragBuilder->codeAppendf( - "if (d == 0.0) {" // if on the center of the circle - " %s = vec4(1.0, 0.0, distanceToOuterEdge, " - " %s);", // no normalize - args.fDistanceVectorName, - innerEdgeDistance); - fragBuilder->codeAppendf( - "} else {" - " %s = vec4(normalize(circleEdge.xy)," - " distanceToOuterEdge, %s);" - "}", - args.fDistanceVectorName, innerEdgeDistance); - } if (cgp.fInClipPlane) { fragBuilder->codeAppend( "float clip = clamp(circleEdge.z * dot(circleEdge.xy, clipPlane.xy) + " @@ -1689,7 +1666,6 @@ enum RRectType { kFill_RRectType, kStroke_RRectType, kOverstroke_RRectType, - kFillWithDist_RRectType }; static int rrect_type_to_vert_count(RRectType type) { @@ -1698,7 +1674,6 @@ static int rrect_type_to_vert_count(RRectType type) { case kStroke_RRectType: return kVertsPerStandardRRect; case kOverstroke_RRectType: - case kFillWithDist_RRectType: return kVertsPerOverstrokeRRect; } SkFAIL("Invalid type"); @@ -1712,7 +1687,6 @@ static int rrect_type_to_index_count(RRectType type) { case kStroke_RRectType: return kIndicesPerStrokeRRect; case kOverstroke_RRectType: - case kFillWithDist_RRectType: return kIndicesPerOverstrokeRRect; } SkFAIL("Invalid type"); @@ -1725,7 +1699,6 @@ static const uint16_t* rrect_type_to_indices(RRectType type) { case kStroke_RRectType: return gStandardRRectIndices; case kOverstroke_RRectType: - case kFillWithDist_RRectType: return gOverstrokeRRectIndices; } SkFAIL("Invalid type"); @@ -1752,16 +1725,14 @@ public: // A devStrokeWidth <= 0 indicates a fill only. If devStrokeWidth > 0 then strokeOnly indicates // whether the rrect is only stroked or stroked and filled. - static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, bool needsDistance, - const SkMatrix& viewMatrix, const SkRect& devRect, - float devRadius, float devStrokeWidth, bool strokeOnly) { - return Helper::FactoryHelper<CircularRRectOp>(std::move(paint), needsDistance, viewMatrix, - devRect, devRadius, devStrokeWidth, - strokeOnly); + static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkMatrix& viewMatrix, + const SkRect& devRect, float devRadius, + float devStrokeWidth, bool strokeOnly) { + return Helper::FactoryHelper<CircularRRectOp>(std::move(paint), viewMatrix, devRect, + devRadius, devStrokeWidth, strokeOnly); } - CircularRRectOp(Helper::MakeArgs& helperArgs, GrColor color, bool needsDistance, - const SkMatrix& viewMatrix, const SkRect& devRect, float devRadius, - float devStrokeWidth, bool strokeOnly) + CircularRRectOp(Helper::MakeArgs& helperArgs, GrColor color, const SkMatrix& viewMatrix, + const SkRect& devRect, float devRadius, float devStrokeWidth, bool strokeOnly) : INHERITED(ClassID()) , fViewMatrixIfUsingLocalCoords(viewMatrix) , fHelper(helperArgs, GrAAType::kCoverage) { @@ -1791,9 +1762,6 @@ public: outerRadius += halfWidth; bounds.outset(halfWidth, halfWidth); } - if (kFill_RRectType == type && needsDistance) { - type = kFillWithDist_RRectType; - } // The radii are outset for two reasons. First, it allows the shader to simply perform // simpler computation because the computed alpha is zero, rather than 50%, at the radius. @@ -1958,10 +1926,9 @@ private: SkScalar yOuterRadii[4] = {-1, 0, 0, 1}; // The inner radius in the vertex data must be specified in normalized space. // For fills, specifying -1/outerRadius guarantees an alpha of 1.0 at the inner radius. - SkScalar innerRadius = - rrect.fType != kFill_RRectType && rrect.fType != kFillWithDist_RRectType - ? rrect.fInnerRadius / rrect.fOuterRadius - : -1.0f / rrect.fOuterRadius; + SkScalar innerRadius = rrect.fType != kFill_RRectType + ? rrect.fInnerRadius / rrect.fOuterRadius + : -1.0f / rrect.fOuterRadius; for (int i = 0; i < 4; ++i) { verts->fPos = SkPoint::Make(bounds.fLeft, yCoords[i]); verts->fColor = color; @@ -2011,15 +1978,6 @@ private: overstrokeOuterRadius, 0.0f, rrect.fColor); } - if (kFillWithDist_RRectType == rrect.fType) { - SkScalar halfMinDim = 0.5f * SkTMin(bounds.width(), bounds.height()); - - SkScalar xOffset = 1.0f - outerRadius / halfMinDim; - - FillInOverstrokeVerts(&verts, bounds, outerRadius, halfMinDim, xOffset, halfMinDim, - -1.0f, rrect.fColor); - } - const uint16_t* primIndices = rrect_type_to_indices(rrect.fType); const int primIndexCount = rrect_type_to_index_count(rrect.fType); for (int i = 0; i < primIndexCount; ++i) { @@ -2321,7 +2279,6 @@ private: }; static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint, - bool needsDistance, const SkMatrix& viewMatrix, const SkRRect& rrect, const SkStrokeRec& stroke) { @@ -2382,8 +2339,8 @@ static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint, // if the corners are circles, use the circle renderer if (isCircular) { - return CircularRRectOp::Make(std::move(paint), needsDistance, viewMatrix, bounds, xRadius, - scaledStroke.fX, isStrokeOnly); + return CircularRRectOp::Make(std::move(paint), viewMatrix, bounds, xRadius, scaledStroke.fX, + isStrokeOnly); // otherwise we use the ellipse renderer } else { return EllipticalRRectOp::Make(std::move(paint), viewMatrix, bounds, xRadius, yRadius, @@ -2392,7 +2349,6 @@ static std::unique_ptr<GrDrawOp> make_rrect_op(GrPaint&& paint, } std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrPaint&& paint, - bool needsDistance, const SkMatrix& viewMatrix, const SkRRect& rrect, const SkStrokeRec& stroke, @@ -2405,7 +2361,7 @@ std::unique_ptr<GrDrawOp> GrOvalOpFactory::MakeRRectOp(GrPaint&& paint, return nullptr; } - return make_rrect_op(std::move(paint), needsDistance, viewMatrix, rrect, stroke); + return make_rrect_op(std::move(paint), viewMatrix, rrect, stroke); } /////////////////////////////////////////////////////////////////////////////// @@ -2508,9 +2464,7 @@ GR_DRAW_OP_TEST_DEFINE(DIEllipseOp) { GR_DRAW_OP_TEST_DEFINE(RRectOp) { SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); const SkRRect& rrect = GrTest::TestRRectSimple(random); - bool needsDistance = random->nextBool(); - return make_rrect_op(std::move(paint), needsDistance, viewMatrix, rrect, - GrTest::TestStrokeRec(random)); + return make_rrect_op(std::move(paint), viewMatrix, rrect, GrTest::TestStrokeRec(random)); } #endif diff --git a/src/gpu/ops/GrOvalOpFactory.h b/src/gpu/ops/GrOvalOpFactory.h index 8a51c5301e..4c85ee84f5 100644 --- a/src/gpu/ops/GrOvalOpFactory.h +++ b/src/gpu/ops/GrOvalOpFactory.h @@ -33,7 +33,6 @@ public: const GrShaderCaps*); static std::unique_ptr<GrDrawOp> MakeRRectOp(GrPaint&&, - bool needsDistance, const SkMatrix&, const SkRRect&, const SkStrokeRec&, diff --git a/src/gpu/ops/GrRectOpFactory.h b/src/gpu/ops/GrRectOpFactory.h index f4b1b803fb..58927ef91b 100644 --- a/src/gpu/ops/GrRectOpFactory.h +++ b/src/gpu/ops/GrRectOpFactory.h @@ -31,11 +31,7 @@ inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(const GrPaint& paint, const SkRect& rect, const SkRect& croppedRect, const SkRect& devRect) { - if (!paint.usesDistanceVectorField()) { - return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect); - } else { - return GrAnalyticRectOp::Make(paint.getColor(), viewMatrix, rect, croppedRect, devRect); - } + return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect); } inline std::unique_ptr<GrLegacyMeshDrawOp> MakeAAFill(GrColor color, |