aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar dvonbeck <dvonbeck@google.com>2016-08-01 11:01:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-01 11:01:56 -0700
commit9b03e7b29d963ea333a66dc5353e94f6391eb899 (patch)
tree8d888df5a95d0859e7748d53ad580d9e0bc1d2cf /include/gpu
parent6be452c80072b5ce4011126a27471ceaec72cfcb (diff)
GrFP can express distance vector field req., program builder declares variable for it
This update allows fragment processors to require a field of vectors to the nearest edge. This requirement propagates: - from child FPs to their parent - from parent FPs to the GrPaint - from GrPaint through the PipelineBuilder into GrPipeline - acessed from GrPipeline by GrGLSLProgramBuilder GrGLSL generates a variable for the distance vector and passes it down to the GeometryProcessor->emitCode() method. This CL's base is the CL for adding the BevelNormalSource API: https://codereview.chromium.org/2080993002 BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2114993002 Committed: https://skia.googlesource.com/skia/+/4ef6dfa7089c092c67b0d5ec34e89c1e319af196 Review-Url: https://codereview.chromium.org/2114993002
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrFragmentProcessor.h9
-rw-r--r--include/gpu/GrPaint.h9
2 files changed, 18 insertions, 0 deletions
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index 4b56fbf728..ffbf576dbe 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -65,6 +65,7 @@ public:
GrFragmentProcessor()
: INHERITED()
+ , fUsesDistanceVectorField(false)
, fUsesLocalCoords(false)
, fNumTexturesExclChildren(0)
, fNumBuffersExclChildren(0)
@@ -110,6 +111,9 @@ public:
/** Do any of the coordtransforms for this processor require local coords? */
bool usesLocalCoords() const { return fUsesLocalCoords; }
+ /** Does this FP need a vector to the nearest edge? */
+ bool usesDistanceVectorField() const { return fUsesDistanceVectorField; }
+
/** Returns true if this and other processor conservatively draw identically. It can only return
true when the two processor are of the same subclass (i.e. they return the same object from
from getFactory()).
@@ -173,6 +177,11 @@ protected:
*/
virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0;
+ /* Sub-classes should set this to true in their constructors if they need access to a distance
+ * vector field to the nearest edge
+ */
+ bool fUsesDistanceVectorField;
+
private:
void notifyRefCntIsZero() const final;
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 8be1d50744..ca9ba59818 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -78,6 +78,11 @@ 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.
*/
@@ -101,6 +106,7 @@ public:
*/
void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
+ fUsesDistanceVectorField |= fp->usesDistanceVectorField();
fColorFragmentProcessors.push_back(std::move(fp));
}
@@ -109,6 +115,7 @@ public:
*/
void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
+ fUsesDistanceVectorField |= fp->usesDistanceVectorField();
fCoverageFragmentProcessors.push_back(std::move(fp));
}
@@ -142,6 +149,7 @@ public:
fAntiAlias = paint.fAntiAlias;
fDisableOutputConversionToSRGB = paint.fDisableOutputConversionToSRGB;
fAllowSRGBInputs = paint.fAllowSRGBInputs;
+ fUsesDistanceVectorField = paint.fUsesDistanceVectorField;
fColor = paint.fColor;
fColorFragmentProcessors = paint.fColorFragmentProcessors;
@@ -168,6 +176,7 @@ private:
bool fAntiAlias;
bool fDisableOutputConversionToSRGB;
bool fAllowSRGBInputs;
+ bool fUsesDistanceVectorField;
GrColor4f fColor;
};