aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrAppliedClip.h
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-11-06 13:48:04 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-07 17:28:34 +0000
commit4c92d4aa3ed653afdff9996b90a1139ed1dc9420 (patch)
tree33ab60f731462de4747188e0307ba8f76d4ec19a /src/gpu/GrAppliedClip.h
parentfbe0793526526ae47f02c7a011e29c401ef191f4 (diff)
Don't use analytic clip FPs when drawing to stencil
It doesn't make sense to multiply by coverage when drawing to stencil. This could theoretically work with FPs that discard and/or modify the sample mask, but for the time being an analytic FP means one that calculates a coverage value. Bug: skia:7190 Change-Id: Ic40cf6c19c377cba80bad458993582f5cc07022a Reviewed-on: https://skia-review.googlesource.com/67423 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/GrAppliedClip.h')
-rw-r--r--src/gpu/GrAppliedClip.h90
1 files changed, 60 insertions, 30 deletions
diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h
index d96370ecc0..bfe3383e16 100644
--- a/src/gpu/GrAppliedClip.h
+++ b/src/gpu/GrAppliedClip.h
@@ -14,28 +14,21 @@
#include "SkClipStack.h"
+
/**
- * Produced by GrClip. It provides a set of modifications to the drawing state that are used to
- * create the final GrPipeline for a GrOp.
+ * Produced by GrHardClip. It provides a set of modifications to the hardware drawing state that
+ * implement the clip.
*/
-class GrAppliedClip {
+class GrAppliedHardClip {
public:
- GrAppliedClip() = default;
- GrAppliedClip(GrAppliedClip&& that) = default;
- GrAppliedClip(const GrAppliedClip&) = delete;
+ GrAppliedHardClip() = default;
+ GrAppliedHardClip(GrAppliedHardClip&& that) = default;
+ GrAppliedHardClip(const GrAppliedHardClip&) = delete;
const GrScissorState& scissorState() const { return fScissorState; }
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
- int numClipCoverageFragmentProcessors() const { return fClipCoverageFPs.count(); }
- const GrFragmentProcessor* clipCoverageFragmentProcessor(int i) const {
- SkASSERT(fClipCoverageFPs[i]);
- return fClipCoverageFPs[i].get();
- }
- std::unique_ptr<const GrFragmentProcessor> detachClipCoverageFragmentProcessor(int i) {
- SkASSERT(fClipCoverageFPs[i]);
- return std::move(fClipCoverageFPs[i]);
- }
- bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fClipStackID; }
+ uint32_t stencilStackID() const { return fStencilStackID; }
+ bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fStencilStackID; }
/**
* Intersects the applied clip with the provided rect. Returns false if the draw became empty.
@@ -56,26 +49,65 @@ public:
fWindowRectsState.set(windows, mode);
}
+ void addStencilClip(uint32_t stencilStackID) {
+ SkASSERT(SkClipStack::kInvalidGenID == fStencilStackID);
+ fStencilStackID = stencilStackID;
+ }
+
+ bool doesClip() const {
+ return fScissorState.enabled() || this->hasStencilClip() || fWindowRectsState.enabled();
+ }
+
+ bool operator==(const GrAppliedHardClip& that) const {
+ return fScissorState == that.fScissorState &&
+ fWindowRectsState == that.fWindowRectsState &&
+ fStencilStackID == that.fStencilStackID;
+ }
+ bool operator!=(const GrAppliedHardClip& that) const { return !(*this == that); }
+
+private:
+ GrScissorState fScissorState;
+ GrWindowRectsState fWindowRectsState;
+ uint32_t fStencilStackID = SkClipStack::kInvalidGenID;
+};
+
+/**
+ * Produced by GrClip. It provides a set of modifications to GrPipeline that implement the clip.
+ */
+class GrAppliedClip {
+public:
+ GrAppliedClip() = default;
+ GrAppliedClip(GrAppliedClip&& that) = default;
+ GrAppliedClip(const GrAppliedClip&) = delete;
+
+ const GrScissorState& scissorState() const { return fHardClip.scissorState(); }
+ const GrWindowRectsState& windowRectsState() const { return fHardClip.windowRectsState(); }
+ uint32_t stencilStackID() const { return fHardClip.stencilStackID(); }
+ bool hasStencilClip() const { return fHardClip.hasStencilClip(); }
+ int numClipCoverageFragmentProcessors() const { return fClipCoverageFPs.count(); }
+ const GrFragmentProcessor* clipCoverageFragmentProcessor(int i) const {
+ SkASSERT(fClipCoverageFPs[i]);
+ return fClipCoverageFPs[i].get();
+ }
+ std::unique_ptr<const GrFragmentProcessor> detachClipCoverageFragmentProcessor(int i) {
+ SkASSERT(fClipCoverageFPs[i]);
+ return std::move(fClipCoverageFPs[i]);
+ }
+
+ GrAppliedHardClip& hardClip() { return fHardClip; }
+
void addCoverageFP(std::unique_ptr<GrFragmentProcessor> fp) {
SkASSERT(fp);
fClipCoverageFPs.push_back(std::move(fp));
}
- void addStencilClip(uint32_t clipStackID) {
- SkASSERT(SkClipStack::kInvalidGenID == fClipStackID);
- fClipStackID = clipStackID;
- }
-
bool doesClip() const {
- return fScissorState.enabled() || !fClipCoverageFPs.empty() || this->hasStencilClip() ||
- fWindowRectsState.enabled();
+ return fHardClip.doesClip() || !fClipCoverageFPs.empty();
}
bool operator==(const GrAppliedClip& that) const {
- if (fScissorState != that.fScissorState ||
- fWindowRectsState != that.fWindowRectsState ||
- fClipCoverageFPs.count() != that.fClipCoverageFPs.count() ||
- fClipStackID != that.fClipStackID) {
+ if (fHardClip != that.fHardClip ||
+ fClipCoverageFPs.count() != that.fClipCoverageFPs.count()) {
return false;
}
for (int i = 0; i < fClipCoverageFPs.count(); ++i) {
@@ -102,10 +134,8 @@ public:
}
private:
- GrScissorState fScissorState;
- GrWindowRectsState fWindowRectsState;
+ GrAppliedHardClip fHardClip;
SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> fClipCoverageFPs;
- uint32_t fClipStackID = SkClipStack::kInvalidGenID;
};
#endif